update bootstrap to work for macos too

* Directives can have arbitrary expressions as parameters
 * Fix switch statement not generating code sometimes
 * Rename "main" fn in bootstrap.zig to "zig_user_main" to
   avoid name collisions
 * codegen: fix badref when unreachable is last thing in an
   expression
 * support #condition directive on exported functions
This commit is contained in:
Andrew Kelley
2016-02-15 23:30:05 -07:00
parent 91101f08c2
commit 77ffb5075b
8 changed files with 208 additions and 141 deletions

View File

@@ -339,6 +339,7 @@ void ast_print(FILE *f, AstNode *node, int indent) {
break;
case NodeTypeDirective:
fprintf(f, "%s\n", node_type_str(node->type));
ast_print(f, node->data.directive.expr, indent + 2);
break;
case NodeTypePrefixOpExpr:
fprintf(f, "%s %s\n", node_type_str(node->type),
@@ -631,8 +632,9 @@ static void render_node(AstRender *ar, AstNode *node) {
fprintf(ar->f, "}");
break;
case NodeTypeDirective:
fprintf(ar->f, "#%s(\"%s\")\n", buf_ptr(&node->data.directive.name),
buf_ptr(&node->data.directive.param));
fprintf(ar->f, "#%s(", buf_ptr(&node->data.directive.name));
render_node(ar, node->data.directive.expr);
fprintf(ar->f, ")\n");
break;
case NodeTypeReturnExpr:
zig_panic("TODO");