adding compilation of if-else statements

This commit is contained in:
cozis
2021-10-31 07:01:15 +00:00
parent 5e8fb7ef6b
commit 9eaa82297f
16 changed files with 269 additions and 25 deletions
+21
View File
@@ -126,6 +126,27 @@ static xj_value *convert_node(Node *node, xj_error *error, xj_alloc **alloc)
}
break;
case NODE_IFELSE:
{
IfElseNode *ifelse = (IfElseNode*) node;
xj_value *condition = convert_node(ifelse->condition, error, alloc);
if(condition == NULL) return NULL;
xj_value *true_branch = convert_node(ifelse->true_branch, error, alloc);
if(true_branch == NULL) return NULL;
xj_value *false_branch = convert_node(ifelse->false_branch, error, alloc);
if(false_branch == NULL) return NULL;
return xj_decodef(error, alloc,
"{"
"\t\"node-kind\": \"if-else\", \n"
"\t\"condition\": %v, \n"
"\t\"true-branch\": %v, \n"
"\t\"false-branch\": %v\n"
"}", condition, true_branch, false_branch);
}
default:
UNREACHABLE;