From e579011a6e6311be9b854e17c3a6583b72126b1b Mon Sep 17 00:00:00 2001 From: Josh Wolfe Date: Wed, 25 Nov 2015 15:44:05 -0700 Subject: inline AstNodeStatement --- src/codegen.cpp | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) (limited to 'src/codegen.cpp') 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); } } -- cgit v1.2.3