diff options
| author | Josh Wolfe <thejoshwolfe@gmail.com> | 2015-11-25 15:44:05 -0700 |
|---|---|---|
| committer | Josh Wolfe <thejoshwolfe@gmail.com> | 2015-11-25 15:45:10 -0700 |
| commit | e579011a6e6311be9b854e17c3a6583b72126b1b (patch) | |
| tree | caaf3903dfbd34ab02665cb07c92d751ee61abc8 /src/codegen.cpp | |
| parent | 079ed9e3569b60f45f5a0362a67c1d3a8b2d3665 (diff) | |
| download | zig-e579011a6e6311be9b854e17c3a6583b72126b1b.tar.gz zig-e579011a6e6311be9b854e17c3a6583b72126b1b.zip | |
inline AstNodeStatement
Diffstat (limited to 'src/codegen.cpp')
| -rw-r--r-- | src/codegen.cpp | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/src/codegen.cpp b/src/codegen.cpp index e9269ced64..79213c27b4 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -292,15 +292,11 @@ static void analyze_node(CodeGen *g, AstNode *node) { analyze_node(g, child); } break; - case NodeTypeStatement: - switch (node->data.statement.type) { - case AstNodeStatementTypeExpression: - analyze_node(g, node->data.statement.data.expr.expression); - break; - case AstNodeStatementTypeReturn: - analyze_node(g, node->data.statement.data.retrn.expression); - break; - } + case NodeTypeStatementExpression: + analyze_node(g, node->data.statement_expression.expression); + break; + case NodeTypeStatementReturn: + analyze_node(g, node->data.statement_return.expression); break; case NodeTypeExpression: switch (node->data.expression.type) { @@ -514,23 +510,34 @@ static void gen_block(CodeGen *g, AstNode *block_node) { for (int i = 0; i < block_node->data.block.statements.length; i += 1) { AstNode *statement_node = block_node->data.block.statements.at(i); - assert(statement_node->type == NodeTypeStatement); - switch (statement_node->data.statement.type) { - case AstNodeStatementTypeReturn: + switch (statement_node->type) { + case NodeTypeStatementReturn: { - AstNode *expr_node = statement_node->data.statement.data.retrn.expression; + AstNode *expr_node = statement_node->data.statement_return.expression; LLVMValueRef value = gen_expr(g, expr_node); add_debug_source_node(g, statement_node); LLVMBuildRet(g->builder, value); break; } - case AstNodeStatementTypeExpression: + case NodeTypeStatementExpression: { - AstNode *expr_node = statement_node->data.statement.data.expr.expression; + AstNode *expr_node = statement_node->data.statement_expression.expression; gen_expr(g, expr_node); break; } + case NodeTypeRoot: + case NodeTypeFnProto: + case NodeTypeFnDef: + case NodeTypeFnDecl: + case NodeTypeParamDecl: + case NodeTypeType: + case NodeTypeBlock: + case NodeTypeExpression: + case NodeTypeFnCall: + case NodeTypeExternBlock: + case NodeTypeDirective: + assert(false); } } |
