mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-19 16:54:08 +10:00
Got the compiler partially working
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
|
||||
void freeNode(Node* node) {
|
||||
switch(node->type) {
|
||||
case NODE_ATOMIC:
|
||||
case NODE_LITERAL:
|
||||
freeLiteral(node->atomic.literal);
|
||||
break;
|
||||
|
||||
@@ -23,18 +23,27 @@ void freeNode(Node* node) {
|
||||
FREE(Node, node);
|
||||
}
|
||||
|
||||
void emitAtomicLiteral(Node** nodeHandle, Literal literal) {
|
||||
void emitNodeLiteral(Node** nodeHandle, Literal literal) {
|
||||
//allocate a new node
|
||||
*nodeHandle = ALLOCATE(Node, 1);
|
||||
|
||||
(*nodeHandle)->type = NODE_ATOMIC;
|
||||
(*nodeHandle)->type = NODE_LITERAL;
|
||||
(*nodeHandle)->atomic.literal = literal;
|
||||
}
|
||||
|
||||
void emitNodeUnary(Node** nodeHandle, Opcode opcode) {
|
||||
//allocate a new node
|
||||
*nodeHandle = ALLOCATE(Node, 1);
|
||||
|
||||
(*nodeHandle)->type = NODE_UNARY;
|
||||
(*nodeHandle)->unary.opcode = opcode;
|
||||
(*nodeHandle)->unary.child = NULL;
|
||||
}
|
||||
|
||||
void printNode(Node* node) {
|
||||
switch(node->type) {
|
||||
case NODE_ATOMIC:
|
||||
printf("atomic:");
|
||||
case NODE_LITERAL:
|
||||
printf("literal:");
|
||||
printLiteral(node->atomic.literal);
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user