WIP: dev #1
@@ -99,6 +99,7 @@ public class Generator
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#define FLAG_STRING_LITERAL 1
|
||||||
""");
|
""");
|
||||||
|
|
||||||
while (referencedTypes.Count != 0)
|
while (referencedTypes.Count != 0)
|
||||||
@@ -131,6 +132,7 @@ public class Generator
|
|||||||
writer.WriteLine("char *data;");
|
writer.WriteLine("char *data;");
|
||||||
writer.WriteLine("size_t length;");
|
writer.WriteLine("size_t length;");
|
||||||
writer.WriteLine("uint32_t ref;");
|
writer.WriteLine("uint32_t ref;");
|
||||||
|
writer.WriteLine("uint32_t flags;");
|
||||||
}
|
}
|
||||||
writer.WriteLine("};");
|
writer.WriteLine("};");
|
||||||
writer.WriteLine();
|
writer.WriteLine();
|
||||||
@@ -462,6 +464,7 @@ public class Generator
|
|||||||
writer.WriteLine($"{name}->data = \"{expression.Value.Value}\";");
|
writer.WriteLine($"{name}->data = \"{expression.Value.Value}\";");
|
||||||
writer.WriteLine($"{name}->length = {expression.Value.Value.Length};");
|
writer.WriteLine($"{name}->length = {expression.Value.Value.Length};");
|
||||||
writer.WriteLine($"{name}->ref = 1;");
|
writer.WriteLine($"{name}->ref = 1;");
|
||||||
|
writer.WriteLine($"{name}->flags = FLAG_STRING_LITERAL;");
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
@@ -601,6 +604,13 @@ public class Generator
|
|||||||
writer.WriteLine("{");
|
writer.WriteLine("{");
|
||||||
using (writer.Indent())
|
using (writer.Indent())
|
||||||
{
|
{
|
||||||
|
writer.WriteLine($"if (({value}->flags & FLAG_STRING_LITERAL) == 0)");
|
||||||
|
writer.WriteLine("{");
|
||||||
|
using (writer.Indent())
|
||||||
|
{
|
||||||
|
writer.WriteLine($"free({value}->data);");
|
||||||
|
}
|
||||||
|
writer.WriteLine("}");
|
||||||
writer.WriteLine($"free({value});");
|
writer.WriteLine($"free({value});");
|
||||||
}
|
}
|
||||||
writer.WriteLine("}");
|
writer.WriteLine("}");
|
||||||
|
|||||||
Reference in New Issue
Block a user