private void visitBlock(BlockContext block) { symbolTable.newScope(); for (BlockStatementContext blockStatement : block.blockStatement()) { visitBlockStatement(blockStatement); } symbolTable.dropScope(); }
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()); }