public override void visit(for_node fn) { ProcessNode(fn.statements); var b = HasStatementVisitor <yield_node> .Has(fn); if (!b) { return; } var gt1 = goto_statement.New; var gt2 = goto_statement.New; var endtemp = new ident(newVarName()); var ass1 = new var_statement(fn.loop_variable, fn.type_name, fn.initial_value); var ass2 = new var_statement(endtemp, fn.type_name, fn.finish_value); var if0 = new if_node(bin_expr.Greater(fn.loop_variable, fn.finish_value), gt1); var lb2 = new labeled_statement(gt2.label, if0); var lb1 = new labeled_statement(gt1.label); var Inc = new procedure_call(new method_call(new ident("Inc"), new expression_list(fn.loop_variable))); ReplaceStatement(fn, SeqStatements(ass1, ass2, lb2, fn.statements, Inc, gt2, lb1)); // в declarations ближайшего блока добавить описание labels block bl = listNodes.FindLast(x => x is block) as block; bl.defs.Add(new label_definitions(gt1.label, gt2.label)); }
public for_node NewForStmt(bool opt_var, ident identifier, type_definition for_stmt_decl_or_assign, expression expr1, for_cycle_type fc_type, expression expr2, token_info opt_tk_do, statement stmt, LexLocation loc) { var nfs = new for_node(identifier, expr1, expr2, stmt, fc_type, null, for_stmt_decl_or_assign, opt_var != false, loc); if (opt_tk_do == null) { file_position fp = expr2.source_context.end_position; syntax_tree_node err_stn = stmt; if (err_stn == null) { err_stn = expr2; } parsertools.errors.Add(new PABCNETUnexpectedToken(parsertools.CurrentFileName, StringResources.Get("TKDO"), new SourceContext(fp.line_num, fp.column_num + 1, fp.line_num, fp.column_num + 1, 0, 0), err_stn)); } if (!opt_var && for_stmt_decl_or_assign == null) { parsertools.AddWarningFromResource("USING_UNLOCAL_FOR_VARIABLE", identifier.source_context); } return(nfs); }
public override void visit(for_node f) { if (f.create_loop_variable || f.type_name != null) { AddSymbol(f.loop_variable, SymKind.var, f.type_name); } base.visit(f); }
private void get_fornext_statement(statement_list sl, ICSharpCode.NRefactory.Ast.ForNextStatement stmt) { for_node for_stmt = new for_node(); for_stmt.loop_variable = new ident(stmt.VariableName); sl.subnodes.Add(for_stmt); }
private void VisitFor(for_node stmt) { VisitStatement(stmt.init_while_expr); VisitStatement(stmt.initialization_statement); VisitStatement(stmt.increment_statement); VisitExpression(stmt.while_expr); VisitStatement(stmt.body); }
public override void visit(for_node fn) { if (fn.create_loop_variable) { CheckVariableAlreadyDefined(fn.loop_variable); } base.visit(fn); }
public override void visit(for_node _for_node) { prepare_node(_for_node.loop_variable, "loop variable"); prepare_node(_for_node.type_name, "type_name"); prepare_node(_for_node.initial_value, "initial value"); prepare_node(_for_node.finish_value, "finish_value"); prepare_node(_for_node.increment_value, "increment_value"); prepare_node(_for_node.statements, "body"); }
public override void visit(for_node fn) { if (fn.create_loop_variable == false) { ForsWithoutVar++; } if (fn.create_loop_variable == true) { ForsWithVar++; } base.visit(fn); }
public override void visit(for_node _for_node) { AddPossibleComments(_for_node, true, false); _for_node.loop_variable.visit(this); if (_for_node.type_name != null) { _for_node.type_name.visit(this); } _for_node.initial_value.visit(this); _for_node.finish_value.visit(this); _for_node.statements.visit(this); }
public override void visit(loop_stmt loop) { // тут возможно ошибка более глубокая - в semantic_check_sugared_statement_node(asstup) возможно остаются во вложенных лямбдах другие assign_tuple var sl = new statement_list(); sl.Add(new semantic_check_sugared_statement_node(typeof(loop_stmt), new List <syntax_tree_node> { loop.count }, loop.source_context)); var tname = "#loop_var" + UniqueNumStr(); var fn = new for_node(new ident(tname), new int32_const(1), loop.count, loop.stmt, loop.source_context); sl.Add(fn); ReplaceUsingParent(loop, sl); visit(fn); }
public override void visit(for_node _for_node) { if (!_for_node.create_loop_variable && (_for_node.type_name == null)) { throw new OpenMPException("Счетчик цикла должен быть обьявлен в заголовке цикла", _for_node.source_context); } bool _isForNode = isForNode; isForNode = false; isLoopVariable = true; ProcessNode(_for_node.loop_variable); isLoopVariable = false; ProcessNode(_for_node.initial_value); ProcessNode(_for_node.increment_value); ProcessNode(_for_node.finish_value); ProcessNode(_for_node.type_name); ProcessNode(_for_node.statements); isForNode = _isForNode; }
public virtual void visit(for_node _for_node) { DefaultVisit(_for_node); }
public virtual void post_do_visit(for_node _for_node) { }
public override void visit(for_node _for_node) { DefaultVisit(_for_node); pre_do_visit(_for_node); visit(for_node.loop_variable); visit(for_node.initial_value); visit(for_node.finish_value); visit(for_node.statements); visit(for_node.increment_value); visit(for_node.type_name); post_do_visit(_for_node); }
public virtual void visit(for_node _for_node) { }
public override void visit(for_node _for_node) { executer.visit(_for_node); if (_for_node.loop_variable != null) this.visit((dynamic)_for_node.loop_variable); if (_for_node.initial_value != null) this.visit((dynamic)_for_node.initial_value); if (_for_node.finish_value != null) this.visit((dynamic)_for_node.finish_value); if (_for_node.statements != null) this.visit((dynamic)_for_node.statements); if (_for_node.increment_value != null) this.visit((dynamic)_for_node.increment_value); if (_for_node.type_name != null) this.visit((dynamic)_for_node.type_name); if (_for_node.attributes != null) this.visit((dynamic)_for_node.attributes); }
public override void visit(for_node fn) { var b = HasStatementVisitor <yield_node> .Has(fn); if (!b) { return; } var gotoContinue = goto_statement.New; var gotoBreak = goto_statement.New; var gotoStart = goto_statement.New; ReplaceBreakContinueWithGotoLabelVisitor replaceBreakContinueVis = new ReplaceBreakContinueWithGotoLabelVisitor(gotoContinue, gotoBreak); fn.statements.visit(replaceBreakContinueVis); ProcessNode(fn.statements); var newNames = this.NewVarNames(fn.loop_variable); var newLoopVar = fn.create_loop_variable ? new ident(newNames.VarName) : fn.loop_variable; // Нужно заменить fn.loop_variable -> newLoopVar в теле цикла var replacerVis = new ReplaceVariableNameVisitor(fn.loop_variable, newLoopVar); fn.visit(replacerVis); fn.loop_variable = newLoopVar; var endtemp = new ident(newNames.VarEndName); //new ident(newVarName()); //var ass1 = new var_statement(fn.loop_variable, fn.type_name, fn.initial_value); //var ass1 = new var_statement(fn.loop_variable, fn.type_name, fn.initial_value); //var ass2 = new var_statement(endtemp, fn.type_name, fn.finish_value); // Исправления в связи с #1254 (новый алгоритм) // цикл for i:=a to b do // i := a // if i > b then goto break //Start: stmts // if i >= b then goto break //Continue: Inc(i) // goto Start //Break: // цикл for i:=a downto b do // i := a // if i < b then goto break //Start: stmts // if i <= b then goto break //Continue: Dec(i) // goto Start //Break: // frninja 05/06/16 - фиксим для !fn.create_variable var ass1 = fn.create_loop_variable ? new var_statement(fn.loop_variable, fn.type_name, fn.initial_value) as statement : new assign(fn.loop_variable, fn.initial_value) as statement; var if0 = new if_node((fn.cycle_type == for_cycle_type.to) ? bin_expr.Greater(fn.loop_variable, fn.finish_value) : bin_expr.Less(fn.loop_variable, fn.finish_value), gotoBreak); var if1 = new if_node((fn.cycle_type == for_cycle_type.to) ? bin_expr.GreaterEqual(fn.loop_variable, fn.finish_value) : bin_expr.LessEqual(fn.loop_variable, fn.finish_value), gotoBreak); var lb1 = new labeled_statement(gotoStart.label); var lb2 = new labeled_statement(gotoBreak.label); // пустой оператор var Inc = new procedure_call(new method_call((fn.cycle_type == for_cycle_type.to) ? new ident("Inc") : new ident("Dec"), new expression_list(fn.loop_variable))); var lbInc = new labeled_statement(gotoContinue.label, Inc); ReplaceStatement(fn, SeqStatements(ass1, if0, lb1, fn.statements, if1, lbInc, gotoStart, lb2)); /*var if0 = new if_node((fn.cycle_type == for_cycle_type.to) ? * bin_expr.Greater(fn.loop_variable, fn.finish_value) : * bin_expr.Less(fn.loop_variable, fn.finish_value), gotoBreak); * * var lb2 = new labeled_statement(gotoStart.label, if0); * var lb1 = new labeled_statement(gotoBreak.label); // пустой оператор * var Inc = new procedure_call(new method_call((fn.cycle_type == for_cycle_type.to) ? * new ident("Inc") : * new ident("Dec"), new expression_list(fn.loop_variable))); * * var lbInc = new labeled_statement(gotoContinue.label, Inc); * * ReplaceStatement(fn, SeqStatements(ass1, lb2, fn.statements, lbInc, gotoStart, lb1));*/ // в declarations ближайшего блока добавить описание labels block bl = listNodes.FindLast(x => x is block) as block; bl.defs.Add(new label_definitions(gotoContinue.label, gotoBreak.label, gotoStart.label)); }
public override void visit(for_node _for_node) { text = "Cycle type: " + _for_node.cycle_type.ToString(); }
public override void visit(for_node fn) { var b = HasStatementVisitor <yield_node> .Has(fn); if (!b) { return; } var gotoContinue = goto_statement.New; var gotoBreak = goto_statement.New; var gotoStart = goto_statement.New; ReplaceBreakContinueWithGotoLabelVisitor replaceBreakContinueVis = new ReplaceBreakContinueWithGotoLabelVisitor(gotoContinue, gotoBreak); fn.statements.visit(replaceBreakContinueVis); ProcessNode(fn.statements); var newNames = this.NewVarNames(fn.loop_variable); var newLoopVar = fn.create_loop_variable ? new ident(newNames.VarName) : fn.loop_variable; // Нужно заменить fn.loop_variable -> newLoopVar в теле цикла var replacerVis = new ReplaceVariableNameVisitor(fn.loop_variable, newLoopVar); fn.visit(replacerVis); fn.loop_variable = newLoopVar; var endtemp = new ident(newNames.VarEndName); //new ident(newVarName()); //var ass1 = new var_statement(fn.loop_variable, fn.type_name, fn.initial_value); //var ass1 = new var_statement(fn.loop_variable, fn.type_name, fn.initial_value); //var ass2 = new var_statement(endtemp, fn.type_name, fn.finish_value); // frninja 05/06/16 - фиксим для !fn.create_variable var ass1 = fn.create_loop_variable ? new var_statement(fn.loop_variable, fn.type_name, fn.initial_value) as statement : new assign(fn.loop_variable, fn.initial_value) as statement; var if0 = new if_node((fn.cycle_type == for_cycle_type.to) ? bin_expr.Greater(fn.loop_variable, fn.finish_value) : bin_expr.Less(fn.loop_variable, fn.finish_value), gotoBreak); var lb2 = new labeled_statement(gotoStart.label, if0); var lb1 = new labeled_statement(gotoBreak.label); var Inc = new procedure_call(new method_call((fn.cycle_type == for_cycle_type.to) ? new ident("Inc") : new ident("Dec"), new expression_list(fn.loop_variable))); var lbInc = new labeled_statement(gotoContinue.label, Inc); ReplaceStatement(fn, SeqStatements(ass1, lb2, fn.statements, lbInc, gotoStart, lb1)); // в declarations ближайшего блока добавить описание labels block bl = listNodes.FindLast(x => x is block) as block; bl.defs.Add(new label_definitions(gotoContinue.label, gotoBreak.label, gotoStart.label)); }