mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 23:04:08 +10:00
Eventually gonna squash all of today's work
This commit is contained in:
@@ -15,6 +15,36 @@ int main() {
|
||||
freeNode(node);
|
||||
}
|
||||
|
||||
{
|
||||
//test compound (dictionary)
|
||||
char* idn = "foobar";
|
||||
char* str = "hello world";
|
||||
|
||||
Node* dictionary;
|
||||
Node* left;
|
||||
Node* right;
|
||||
|
||||
emitNodeCompound(&dictionary, LITERAL_DICTIONARY);
|
||||
emitNodeLiteral(&left, TO_IDENTIFIER_LITERAL(copyString(idn, strlen(idn)), strlen(idn)) );
|
||||
emitNodeLiteral(&right, TO_STRING_LITERAL(copyString(str, strlen(str)), strlen(str)) );
|
||||
|
||||
//grow the node if needed
|
||||
if (dictionary->compound.capacity < dictionary->compound.count + 1) {
|
||||
int oldCapacity = dictionary->compound.capacity;
|
||||
|
||||
dictionary->compound.capacity = GROW_CAPACITY(oldCapacity);
|
||||
dictionary->compound.nodes = GROW_ARRAY(Node, dictionary->compound.nodes, oldCapacity, dictionary->compound.capacity);
|
||||
}
|
||||
|
||||
//store the left and right in the node
|
||||
Node* pair = NULL;
|
||||
emitNodePair(&pair, left, right);
|
||||
dictionary->compound.nodes[dictionary->compound.count++] = *pair;
|
||||
|
||||
//the real test
|
||||
freeNode(dictionary);
|
||||
}
|
||||
|
||||
printf(NOTICE "All good\n" RESET);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user