AST* node = ast(AST_VAR);
node->value.var.name = name;
node->value.var.value = value;
- node->value.var.type = type;
node->value.var.flags = flags;
return node;
}
AST* Func(AST* args, AST* body, AST* type)
{
AST* node = ast(AST_FUNC);
- node->value.func.args = args;
- node->value.func.body = body;
+ node->value.nodes[0] = args;
+ node->value.nodes[1] = body;
return node;
}
AST* func_args(AST* func) {
assert(func->nodetype == AST_FUNC);
- return func->value.func.args;
+ return func->value.nodes[0];
}
AST* func_body(AST* func) {
assert(func->nodetype == AST_FUNC);
- return func->value.func.body;
+ return func->value.nodes[1];
}
AST* ExpList(void) {
AST* If(AST* cond, AST* b1, AST* b2) {
AST* node = ast(AST_IF);
- node->value.ifexp.cond = cond;
- node->value.ifexp.b1 = b1;
- node->value.ifexp.b2 = b2;
+ node->value.nodes[0] = cond;
+ node->value.nodes[1] = b1;
+ node->value.nodes[2] = b2;
return node;
}
AST* if_cond(AST* ifexp) {
assert(ifexp->nodetype == AST_IF);
- return ifexp->value.ifexp.cond;
+ return ifexp->value.nodes[0];
}
AST* if_then(AST* ifexp) {
assert(ifexp->nodetype == AST_IF);
- return ifexp->value.ifexp.b1;
+ return ifexp->value.nodes[1];
}
AST* if_else(AST* ifexp) {
assert(ifexp->nodetype == AST_IF);
- return ifexp->value.ifexp.b2;
+ return ifexp->value.nodes[2];
}
AST* Apply(AST* func, AST* args) {
AST* node = ast(AST_APPLY);
- node->value.apply.func = func;
- node->value.apply.args = args;
+ node->value.nodes[0] = func;
+ node->value.nodes[1] = args;
return node;
}
AST* apply_func(AST* apply) {
assert(apply->nodetype == AST_APPLY);
- return apply->value.apply.func;
+ return apply->value.nodes[0];
}
AST* apply_args(AST* apply) {
assert(apply->nodetype == AST_APPLY);
- return apply->value.apply.args;
+ return apply->value.nodes[1];
}