private void visitBlockStatement(BlockStatementContext blockStatement) { if (blockStatement.variableDeclarationStatement() != null) { new VariableDeclarationVisitor(symbolTable, method) .visitVariableDeclaration( blockStatement.variableDeclarationStatement().variableDeclaration()); } else { visitStatement(blockStatement.statement()); } }
private void checkReturn(BlockContext block) { if (returnType == ValueType.VOID) { method.visitInsn(Opcodes.RETURN); return; } if (block.blockStatement() != null) { int lastStatement = block.blockStatement().size() - 1; BlockStatementContext blockStatement = block.blockStatement(lastStatement); if (blockStatement.statement() != null) { StatementContext statement = blockStatement.statement(); if (statement.jumpStatement() != null) { JumpStatementContext jumpStatement = statement.jumpStatement(); if (jumpStatement.returnSt != null) { return; } } } } throw new GenerationException( "Last statement of function with non-null return type must be return. String: " + block.getText()); }