public override void visit(foreach_stmt _foreach_stmt) { //throw new Exception("The method or operation is not implemented."); SymScope tmp = cur_scope; if (_foreach_stmt.type_name != null) { SymScope stmt_scope = new BlockScope(cur_scope); cur_scope.AddName("$block_scope",stmt_scope); stmt_scope.loc = get_location(_foreach_stmt); if (_foreach_stmt.type_name is no_type_foreach) { _foreach_stmt.in_what.visit(this); if (returned_scope != null) returned_scope = returned_scope.GetElementType(); } else { _foreach_stmt.type_name.visit(this); } if (returned_scope != null) { cur_scope = stmt_scope; ElementScope es = new ElementScope(new SymInfo(_foreach_stmt.identifier.name, SymbolKind.Variable,_foreach_stmt.identifier.name),returned_scope,cur_scope); es.loc = get_location(_foreach_stmt.identifier); stmt_scope.AddName(_foreach_stmt.identifier.name,es); } } if (_foreach_stmt.stmt != null) _foreach_stmt.stmt.visit(this); cur_scope = tmp; }
public override void visit(PascalABCCompiler.SyntaxTree.for_node _for_node) { //throw new Exception("The method or operation is not implemented."); SymScope tmp = cur_scope; //if (_for_node.type_name != null) { SymScope stmt_scope = new BlockScope(cur_scope); cur_scope.AddName("$block_scope",stmt_scope); stmt_scope.loc = get_location(_for_node); returned_scope = null; if (_for_node.type_name != null) _for_node.type_name.visit(this); if (returned_scope != null) { cur_scope = stmt_scope; ElementScope es = new ElementScope(new SymInfo(_for_node.loop_variable.name, SymbolKind.Variable,_for_node.loop_variable.name),returned_scope,cur_scope); stmt_scope.AddName(_for_node.loop_variable.name,es); es.loc = get_location(_for_node.loop_variable); returned_scope = null; } else { _for_node.initial_value.visit(this); if (returned_scope != null) { cur_scope = stmt_scope; if (_for_node.create_loop_variable) { ElementScope es = new ElementScope(new SymInfo(_for_node.loop_variable.name, SymbolKind.Variable,_for_node.loop_variable.name),returned_scope,cur_scope); stmt_scope.AddName(_for_node.loop_variable.name,es); es.loc = get_location(_for_node.loop_variable); } returned_scope = null; } } } if (_for_node.statements != null) _for_node.statements.visit(this); cur_scope = tmp; }
public override void visit(exception_handler _exception_handler) { SymScope tmp = cur_scope; SymScope stmt_scope = new BlockScope(cur_scope); cur_scope.AddName("$block_scope",stmt_scope); stmt_scope.loc = get_location(_exception_handler); stmt_scope.loc = new location(stmt_scope.loc.begin_line_num,stmt_scope.loc.begin_column_num, _exception_handler.statements.source_context.end_position.line_num, _exception_handler.statements.source_context.end_position.column_num,stmt_scope.loc.doc); returned_scope = null; if (_exception_handler.variable == null) return; if (_exception_handler.type_name != null) _exception_handler.type_name.visit(this); else returned_scope = cur_scope.FindName(_exception_handler.variable.name); if (returned_scope != null) { cur_scope = stmt_scope; ElementScope es = new ElementScope(new SymInfo(_exception_handler.variable.name, SymbolKind.Variable,_exception_handler.variable.name),returned_scope,cur_scope); es.loc = get_location(_exception_handler.variable); stmt_scope.AddName(_exception_handler.variable.name,es); } _exception_handler.statements.visit(this); cur_scope = tmp; }