Minimal build of the refstrings in the literal structure

This commit is contained in:
2022-11-23 12:52:49 +00:00
parent c7465e1204
commit 923cf70c06
21 changed files with 186 additions and 75 deletions

View File

@@ -5,8 +5,11 @@ CFLAGS +=$(addprefix -I,$(IDIR)) -g -Wall -W -Wno-unused-parameter -Wno-unused-f
LIBS +=
ODIR = obj
TARGETS = $(wildcard ../source/*.c) $(wildcard ../repl/lib_*.c)
TESTS = $(wildcard *.c)
#TARGETS = $(wildcard ../source/*.c) $(wildcard ../repl/lib_*.c)
TARGETS = ../source/memory.c ../source/refstring.c ../source/literal.c ../source/literal_array.c ../source/literal_dictionary.c ../source/scope.c
TESTS = $(wildcard test_*.c)
OBJ = $(addprefix $(ODIR)/,$(TARGETS:../source/%.c=%.o)) $(addprefix $(ODIR)/,$(TESTS:.c=.o))
.PRECIOUS: $(TESTS:%.c=../$(TOY_OUTDIR)/%.exe)

View File

@@ -29,22 +29,18 @@ int main() {
{
//test string literals
char* buffer = ALLOCATE(char, 128);
char* buffer = "Hello world";
snprintf(buffer, 128, "Hello world");
Literal literal = TO_STRING_LITERAL(buffer, 128);
Literal literal = TO_STRING_LITERAL(createRefString(buffer));
freeLiteral(literal);
}
{
//test identifier literals
char* buffer = ALLOCATE(char, 128);
char buffer[] = "Hello world";
snprintf(buffer, 128, "foobar");
Literal literal = TO_IDENTIFIER_LITERAL(buffer, 128);
Literal literal = TO_IDENTIFIER_LITERAL(createRefString(buffer));
freeLiteral(literal);
}

View File

@@ -46,10 +46,10 @@ int main() {
char* str_raw = "hello world";
char* idn_raw = "foobar";
Literal string = TO_STRING_LITERAL(copyString(str_raw, strlen(str_raw)), strlen(str_raw));
Literal identifier = TO_IDENTIFIER_LITERAL(copyString(idn_raw, strlen(idn_raw)), strlen(idn_raw));
Literal string = TO_STRING_LITERAL(createRefString(str_raw));
Literal identifier = TO_IDENTIFIER_LITERAL(createRefString(idn_raw));
//[string, string]
//[string : string]
Literal type = TO_TYPE_LITERAL(LITERAL_DICTIONARY, false);
TYPE_PUSH_SUBTYPE(&type, TO_TYPE_LITERAL(LITERAL_STRING, false));
TYPE_PUSH_SUBTYPE(&type, TO_TYPE_LITERAL(LITERAL_STRING, false));

View File

@@ -18,8 +18,8 @@ int main() {
char* idn_raw = "foobar";
char* str_raw = "hello world";
Literal identifier = TO_IDENTIFIER_LITERAL(copyString(idn_raw, strlen(idn_raw)), strlen(idn_raw));
Literal string = TO_STRING_LITERAL(copyString(str_raw, strlen(str_raw)), strlen(str_raw));
Literal identifier = TO_IDENTIFIER_LITERAL(createRefString(idn_raw));
Literal string = TO_STRING_LITERAL(createRefString(str_raw));
LiteralDictionary dictionary;
initLiteralDictionary(&dictionary);

View File

@@ -63,7 +63,7 @@ int main() {
testMemoryAllocation();
//test the custom allocator
setAllocator(allocator);
setMemoryAllocator(allocator);
testMemoryAllocation();
if (callCount != 8) {

View File

@@ -16,7 +16,7 @@ int main() {
//prerequisites
char* idn_raw = "foobar";
Literal identifier = TO_IDENTIFIER_LITERAL(copyString(idn_raw, strlen(idn_raw)), strlen(idn_raw));
Literal identifier = TO_IDENTIFIER_LITERAL(createRefString(idn_raw));
Literal value = TO_INTEGER_LITERAL(42);
Literal type = TO_TYPE_LITERAL(value.type, false);
@@ -46,7 +46,7 @@ int main() {
//prerequisites
char* idn_raw = "foobar";
Literal identifier = TO_IDENTIFIER_LITERAL(copyString(idn_raw, strlen(idn_raw)), strlen(idn_raw));
Literal identifier = TO_IDENTIFIER_LITERAL(createRefString(idn_raw));
Literal type = TO_TYPE_LITERAL(LITERAL_INTEGER, false);
//test declarations & assignments