mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 23:04:08 +10:00
Added ternary operator, resolved #46
This commit is contained in:
@@ -29,6 +29,12 @@ void freeASTNodeCustom(ASTNode* node, bool freeSelf) {
|
||||
freeASTNode(node->binary.right);
|
||||
break;
|
||||
|
||||
case AST_NODE_TERNARY:
|
||||
freeASTNode(node->ternary.condition);
|
||||
freeASTNode(node->ternary.thenPath);
|
||||
freeASTNode(node->ternary.elsePath);
|
||||
break;
|
||||
|
||||
case AST_NODE_GROUPING:
|
||||
freeASTNode(node->grouping.child);
|
||||
break;
|
||||
@@ -169,6 +175,17 @@ void emitASTNodeBinary(ASTNode** nodeHandle, ASTNode* rhs, Opcode opcode) {
|
||||
*nodeHandle = tmp;
|
||||
}
|
||||
|
||||
void emitASTNodeTernary(ASTNode** nodeHandle, ASTNode* condition, ASTNode* thenPath, ASTNode* elsePath) {
|
||||
ASTNode* tmp = ALLOCATE(ASTNode, 1);
|
||||
|
||||
tmp->type = AST_NODE_TERNARY;
|
||||
tmp->ternary.condition = condition;
|
||||
tmp->ternary.thenPath = thenPath;
|
||||
tmp->ternary.elsePath = elsePath;
|
||||
|
||||
*nodeHandle = tmp;
|
||||
}
|
||||
|
||||
void emitASTNodeGrouping(ASTNode** nodeHandle) {
|
||||
ASTNode* tmp = ALLOCATE(ASTNode, 1);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user