private void TargetAcquired(Destructible target) { if (canAttack) { if (SpookLevel == ReportState.Attacking || target.CurrentGrowth == (int)Sizes.Small) { if (CurrentInstruction != null) { Instructions.Push(CurrentInstruction); } _navMeshAgent.SetDestination(this.transform.position); Instructions.Push(new Attack(target, "Soldier", this)); CurrentInstruction = Instructions.Pop(); } else if (target.CurrentGrowth == (int)Sizes.Medium) { canAttack = false; NumberOfSoldiersToSend = mediumResponse; Instructions.Clear(); Instructions.Push(new Interact(barracks, this)); CurrentInstruction = new Goto(barracks.transform.position, 0, this); reportPosition = target.transform.position; } else if (target.CurrentGrowth == (int)Sizes.Large) { canAttack = false; NumberOfSoldiersToSend = largeResponse; Instructions.Clear(); Instructions.Push(new Interact(barracks, this)); CurrentInstruction = new Goto(barracks.transform.position, 0, this); reportPosition = target.transform.position; } } }
public static Label ResolveLabel(this Goto @goto) { var all_labels = @goto.Hierarchy().Last().Family().OfType <Label>(); var label = all_labels.SingleOrDefault2(l => l.Id == @goto.LabelId); return(label ?? new Label(@goto.LabelId)); }
public override string ToString() { g = (Goto)base.Tag; Binding myBinding = new Binding("context"); myBinding.Mode = BindingMode.TwoWay; myBinding.Source = g; cmbcontext.SetBinding(ComboBox.TextProperty, myBinding); Binding myBinding2 = new Binding("extension"); myBinding2.Mode = BindingMode.TwoWay; myBinding2.Source = g; txtextension.SetBinding(TextBox.TextProperty, myBinding2); Binding myBinding3 = new Binding("pri"); myBinding3.Mode = BindingMode.TwoWay; myBinding3.Source = g; txtprio.SetBinding(TextBox.TextProperty, myBinding3); Binding descbinding = new Binding("Description"); descbinding.Mode = BindingMode.TwoWay; descbinding.Source = g; txtdesc.SetBinding(TextBox.TextProperty, descbinding); return base.ToString(); }
private void HandleGoto(IMutableControlFlowGraph cfg, Goto @goto, IMutableBasicBlock block, int lineNumber) { block.Add(@goto); if (@goto.Destination.IsConstant) { var dest = @goto.Destination.StaticEvaluate(); if (dest.Type == Execution.Type.Number) { // We know exactly where this is going, jump to that line var line = Math.Clamp((int)dest.Number, 1, _maxLines); var destBlock = GetLineEntryBlock(cfg, line); cfg.CreateEdge(block, destBlock, EdgeType.GotoConstNum); } else if (dest.Type == Execution.Type.String) { // We tried to statically jump to a string (which is always an error), fallthrough to the next line AddFallthrough(cfg, block, lineNumber, EdgeType.GotoConstStr); } } else { // We don't know where this is going, so goto every line for (var j = 1; j <= _maxLines; j++) { cfg.CreateEdge(block, GetLineEntryBlock(cfg, j), EdgeType.GotoExpression); } } }
public override string ToString() { g = (Goto)base.Tag; Binding myBinding = new Binding("context"); myBinding.Mode = BindingMode.TwoWay; myBinding.Source = g; cmbcontext.SetBinding(ComboBox.TextProperty, myBinding); Binding myBinding2 = new Binding("extension"); myBinding2.Mode = BindingMode.TwoWay; myBinding2.Source = g; txtextension.SetBinding(TextBox.TextProperty, myBinding2); Binding myBinding3 = new Binding("pri"); myBinding3.Mode = BindingMode.TwoWay; myBinding3.Source = g; txtprio.SetBinding(TextBox.TextProperty, myBinding3); Binding descbinding = new Binding("Description"); descbinding.Mode = BindingMode.TwoWay; descbinding.Source = g; txtdesc.SetBinding(TextBox.TextProperty, descbinding); return(base.ToString()); }
public void CompileGoto(Goto _goto) { XmlElement tmpElement = document.CreateElement("Goto"); tmpElement.SetAttribute("LabelName", _goto.LabelName); currentElement.AppendChild(tmpElement); }
public async void ContinueButtonPressed() { if (MusicGameEngine.loadedFromAVG) { var naniCamera = Engine.GetService <ICameraManager>().Camera; naniCamera.enabled = true; var inputManager = Engine.GetService <IInputManager>(); inputManager.ProcessInput = true; if (fail) { if (MusicGameEngine.scriptName_FailLevel != null && MusicGameEngine.label_FailLevel != null) { Goto gtcmd = new Goto(); gtcmd.Path = new NamedString(MusicGameEngine.scriptName_FailLevel, MusicGameEngine.label_FailLevel); await gtcmd.ExecuteAsync(); } } else { if (MusicGameEngine.scriptName_ClearLevel != null && MusicGameEngine.label_ClearLevel != null) { Goto gtcmd = new Goto(); gtcmd.Path = new NamedString(MusicGameEngine.scriptName_ClearLevel, MusicGameEngine.label_ClearLevel); await gtcmd.ExecuteAsync(); } } SceneManager.UnloadSceneAsync(1); return; } if (async != null) { bgm.stop(FMOD.Studio.STOP_MODE.IMMEDIATE); async.allowSceneActivation = true; } }
public void Goto_WhenIsNotRunning_ThrowsInvalidOperationException() { var rte = MakeRunTimeEnvironment(); var @goto = new Goto(new Constant("100")); var result = @goto.Execute(rte); }
public void Run(Goto gotoItem) { Browser browser = gotoItem.Browser; IWebDriver iwebDriver = null; // Reading the current config to determing the browser, setting up right driver if (browser.HasFlag(Browser.IEXPLORE)) { iwebDriver = new InternetExplorerDriver(); } else if (browser.HasFlag(Browser.FIREFOX)) { // Calling specific profile allows the extensions to be run // FirefoxProfile firefoxProfile = (new FirefoxProfileManager()).GetProfile("default"); iwebDriver = new FirefoxDriver(); } else if (browser.HasFlag(Browser.CHROME)) { // chrome can't be resized after launching // so we start it maximized here ChromeOptions options = new ChromeOptions(); options.AddArgument("--start-maximized"); options.AddArgument("--disable-popup-blocking"); options.AddArgument("--system-developer-mode"); iwebDriver = new ChromeDriver(options); } Object m_lock = new Object(); this.WebDriver = new WebDriver(iwebDriver, m_lock); gotoItem.Run(this.WebDriver); int xmlActionCount = 0; foreach (WebAction webAction in gotoItem.WebActions) { try { webAction.Run(this.WebDriver); xmlActionCount++; #if !FULL_VERSION if (xmlActionCount >= 2) // 2 actions total: type and click links { break; } #endif } catch (Exception e) { throw new Exception(string.Format("Error when running web action: {0}; Message: {1} {2}", webAction.ToString(), e.Message, e.GetStackFrame())); } } }
public static bool TryReadGoto(this Scanner scanner, out IStatement result) { if (scanner.TryReadToken(Token.Goto)) { IExpression number = scanner.ReadExpression(); result = new Goto(number); return(true); } result = null; return(false); }
protected override BaseStatement Visit(Goto @goto) { var right = Visit(@goto.Destination); if (right is Bracketed brk) { return(base.Visit(new Goto(brk.Parameter))); } else { return(base.Visit(@goto)); } }
protected void Start() { nestManager = GameObject.FindObjectOfType <NestManager>(); if (CurrentOrder == null) { NestInstance potentialNest = nestManager.RandomNest(); if (potentialNest != null) { CurrentInstruction = new Goto(potentialNest.nestPosition + Vector3.forward, 0, this); Instructions.Push(new CreateNest(nestPrefab, potentialNest, protectionTimer, this)); } } }
public static void Run(Module module) { var functions = module.GetFunctionEnumerator(); while (functions.MoveNext()) { if (functions.Current.Code != null) { Block block = functions.Current.Code; var whileLoops = from Statement st in block where st is While select st; var doWhileLoops = from Statement st in block where st is DoWhile select st; foreach (While loop in whileLoops) { Block loopBlock = loop.Block; int nPos = loopBlock.Statements.IndexOf(loop); loopBlock.Statements.Remove(loop); List <Statement> whileReplacement = new List <Statement>(); whileReplacement.Add(new Goto(loop.Label)); Label whileStartLbl = block.CreateTempLabel(); List <Statement> condStatements = new List <Statement>(); whileReplacement.Add(whileStartLbl); whileReplacement.AddRange(loop.Body); whileReplacement.Add(loop.Label); whileReplacement.AddRange(Goto.ParseConditionStatements(loop.Condition.Statements, whileStartLbl)); loopBlock.Statements.InsertRange(nPos, whileReplacement); } foreach (DoWhile loop in doWhileLoops) { Block loopBlock = loop.Block; int nPos = loopBlock.Statements.IndexOf(loop); loopBlock.Statements.Remove(loop); List <Statement> whileReplacement = new List <Statement>(); Label whileStartLbl = block.CreateTempLabel(); whileReplacement.Add(whileStartLbl); whileReplacement.AddRange(loop.Body); whileReplacement.Add(loop.Label); whileReplacement.AddRange(Goto.ParseConditionStatements(loop.Condition.Statements, whileStartLbl)); loopBlock.Statements.InsertRange(nPos, whileReplacement); } } } }
/// <summary> /// Process network input based on state /// </summary> /// <param name="input">The input data</param> /// <param name="entity">The data's corresponding entity</param> /// <returns></returns> public CommandResult ProcessInput(string input, EntityAnimate entity) { if (entity == null) { return(CommandResult.NullEntity()); } switch (State) { case EntityState.NameSelection: CommandResult result = HandleNameSelection(input, entity); if (result.ResultCode == ResultCode.SUCCESS) { var startingRoom = DataAccess.GetAll <World>(CacheType.Instance)[0].StartingLocation; State = EntityState.Active; if (startingRoom != null) { var args = new CommandEventArgs(startingRoom.ToString(), entity, null); entity.IOHandler?.QueueRawOutput(result.ResultMessage); result = new Goto().Execute(args); } } return(result); case EntityState.Active: return(CommandService.ProcessCommand(input, entity, new List <EntityState> { EntityState.Active })); case EntityState.Combat: var processCommands = CommandService.ProcessCommand(input, entity, new List <EntityState> { EntityState.Combat }); if (processCommands.ResultCode == ResultCode.FAIL) { return(HandleCombatInput(input, entity)); } else { return(processCommands); } default: return(CommandResult.Failure("Invalid entity state.")); } }
public override void TakeDamage(int damage, Vector3 origin = default(Vector3)) { base.TakeDamage(damage); if (!IsDead() && origin != default && (CurrentInstruction.GetType() != typeof(Attack) && CurrentInstruction.GetType() != typeof(Chase))) { Instructions.Push(CurrentInstruction); if (origin != default) { CurrentInstruction = new Goto(origin, 2, this); } } }
protected override BaseStatement Visit(If @if) { // Check that each branch contains just one statement... if (@if.FalseBranch.Statements.Count != 1) { return(@if); } if (@if.TrueBranch.Statements.Count != 1) { return(@if); } // ...and that those statements are goto statements if (!(@if.TrueBranch.Statements.Single() is Goto gotoTrue)) { return(@if); } if (!(@if.FalseBranch.Statements.Single() is Goto gotoFalse)) { return(@if); } // if A then goto B else goto C end var a = new Bracketed(new Or(@if.Condition, new ConstantNumber(0))); var b = new Bracketed(gotoTrue.Destination); var c = new Bracketed(gotoFalse.Destination); // goto A*(B-C)+C var g1 = new Goto(new Add(c, new Multiply(a, new Bracketed(new Subtract(b, c))))); // x=C goto A*(B-x)+x var x = new VariableName(_names.Name()); var g2 = new StatementList( new Assignment(x, c), new Goto(new Add(new Multiply(a, new Bracketed(new Subtract(b, new Variable(x)))), new Variable(x))) ); // Return the shortest one (ignoring the length of the temporary variable name, assume that's optimised to 1 char) var xl = x.Name.Length * 2; if (g1.ToString().Length <= g2.ToString().Length - xl + 2) { return(g1); } else { return(g2); } }
public TResult Visit(BaseStatement statement) { return(statement switch { Conditional a => Visit(a), TypedAssignment a => Visit(a), ErrorStatement a => Visit(a), CompoundAssignment a => Visit(a), Assignment a => Visit(a), ExpressionWrapper a => Visit(a), Goto a => Visit(a), If a => Visit(a), StatementList a => Visit(a), EmptyStatement a => Visit(a), _ => VisitUnknown(statement) });
protected override void RanOutOfInstructions() { NestInstance potentialNest = nestManager.RandomNest(); if (potentialNest != null) { Instructions.Push(new CreateNest(nestPrefab, potentialNest, protectionTimer, this)); CurrentInstruction = new Goto(potentialNest.nestPosition + Vector3.forward, 0, this); } else { CurrentInstruction = new Goto(homeNest.transform.position + Vector3.forward, 0, this); Instructions.Push(new Goto(nestManager.OccupiedNests().nestPosition, protectionTimer, this)); } }
private JToken SerializeStatement(BaseStatement stmt) { return(stmt switch { Goto g => new JObject { ["type"] = "statement::goto", ["expression"] = SerializeExpression(g.Destination) }, If i => new JObject { ["type"] = "statement::if", ["condition"] = SerializeExpression(i.Condition), ["body"] = SerializeStatementList(i.TrueBranch), ["else_body"] = SerializeStatementList(i.FalseBranch) }, Assignment a => SerializeAssignment(a), ExpressionWrapper e => new JObject { ["type"] = "statement::expression", ["expression"] = SerializeExpression(e.Expression) }, StatementList _ => throw new NotSupportedException(), _ => throw new NotSupportedException($"Cannot serialize statement type `{stmt.GetType().Name}`") });
protected override void RanOutOfInstructions() { if (CurrentOrder is Patrol) { CurrentOrder = CurrentOrder; } else if (Deployed) { Instructions.Push(new Interact(barracks, this)); CurrentInstruction = new Goto(barracks.transform.position, 0, this); Debug.Log("The soldier should return to the barracks"); } else { base.RanOutOfInstructions(); } }
private void SetupSut() { _mockExpressionEvaluator = new Mock <IExpressionEvaluator>(); _mockProgramRepository = new Mock <IProgramRepository>(); _runEnvironment = new RunEnvironment(); _gotoProgramLine = new ProgramLine(10, new List <IToken> { }); _targetProgramLine = new ProgramLine(100, new List <IToken> { }); _sut = new Goto(_runEnvironment, _mockExpressionEvaluator.Object, _mockProgramRepository.Object); _mockProgramRepository.Setup(mpr => mpr.GetLine(100)).Returns(_targetProgramLine); _mockProgramRepository.Setup(mpr => mpr.GetLine(110)) .Throws(new ClassicBasic.Interpreter.Exceptions.UndefinedStatementException()); _runEnvironment.CurrentLine = _gotoProgramLine; _gotoProgramLine.CurrentToken = 2; }
protected override IEnumerable <BaseStatement> Visit(Goto @goto) { if (@goto.Destination.IsConstant) { var v = @goto.Destination.StaticEvaluate(); if (v.Type == Execution.Type.Number) { return new[] { @goto } } ; } var a = new ExpressionDecomposition(_names).Visit(@goto.Destination); var b = new Goto(new Variable(((Assignment)a.Last()).Left)); return(a.Append(b)); }
protected override void DetectionReaction(GameObject[] target) { GameObject threat = Array.Find(target, potentialTarget => potentialTarget.GetComponent <Destructible>().CurrentGrowth == (int)Destructible.Sizes.Large); if (threat != null && this.SpookLevel != ReportState.Attacking) { canAttack = false; NumberOfSoldiersToSend = largeResponse; Instructions.Clear(); Instructions.Push(new Interact(barracks, this)); CurrentInstruction = new Goto(barracks.transform.position, 0, this); reportPosition = threat.transform.position; return; } foreach (GameObject potentialEnemy in target) { Destructible enemy = potentialEnemy.GetComponent <Destructible>(); if (enemy != null) { if (!enemy.IsDead()) { if (CurrentInstruction == null) { // Debug.Log(enemy + " has a tag " + target[0].gameObject.layer); //Instructions.Push(new Goto(this.transform.position, 0, this)); TargetAcquired(target[0].gameObject.GetComponent <Destructible>()); break; } else if (CurrentInstruction.GetType() == typeof(Chase)) { Instructions.Pop(); // Debug.Log(enemy + " has a tag " + target[0].gameObject.layer); TargetAcquired(target[0].gameObject.GetComponent <Destructible>()); break; } else if (CurrentInstruction.GetType() != typeof(Attack)) { //Debug.Log(enemy + " has a tag " + target[0].gameObject.layer); TargetAcquired(target[0].gameObject.GetComponent <Destructible>()); break; } } } } }
/// <summary> /// Создать узлы графа потока управления программы /// </summary> private void CreateCFGNodes() { var labelDict = _code.LabeledCode; foreach (var block in _blockList) { var last = block.CodeList.Last(); var cfgNode = new CFGNode(block); CFGNodes.Add(cfgNode); // блок содержит GoTo в последней строке if (last is Goto) { Goto gt = (Goto)last; // ищем на какую строку идет переход var targetFirst = labelDict[gt.TargetLabel]; // забираем информацию о том, какому блоку принадлежит эта строка var targetNode = new CFGNode(targetFirst.Block); // устанавливаем связи cfgNode <-> targetNode cfgNode.AddChild(targetNode); // добавляем его в набор узлов CFG CFGNodes.Add(targetNode); } // случай, когда есть переход на первую строку блока: // var first = block.CodeList.First(); // if (first.IsLabeled) // рассматривать не нужно, в силу того, что мы пробежимся по всем базовым блокам // и тем самым в любом случае рано или поздно найдем нужную связь } // каждый блок является родителем последующего var nodeList = CFGNodes.ToList(); for (int i = 0; i < nodeList.Count - 1; ++i) { var cur = nodeList[i]; var next = nodeList[i + 1]; cur.Children.Add(next); next.Parents.Add(cur); } }
public static void Run(Module module) { var functions = module.GetFunctionEnumerator(); while (functions.MoveNext()) { if (functions.Current.Code != null) { var ifs = from Statement st in functions.Current.Code where st is If select st; foreach (If ifStatement in ifs) { Block block = ifStatement.Block; int nPos = block.Statements.IndexOf(ifStatement); block.Statements.Remove(ifStatement); var ifReplacement = new List <Statement>(); var condStatements = new List <Statement>(); Label trueSkipLabel = block.CreateTempLabel(); Declaration notDecl = functions.Current.Code.CreateTempDeclaration(new BuiltInType("int")); condStatements.AddRange(ifStatement.ConditionBlock); condStatements.Add(new Move(notDecl, ifStatement.Condition)); condStatements.Add(new WabbitC.Model.Statements.Math.Not(notDecl)); ifReplacement.AddRange(Goto.ParseConditionStatements(condStatements, trueSkipLabel)); ifReplacement.AddRange(ifStatement.TrueCase.Statements); if (ifStatement.FalseCase == null) { ifReplacement.Add(trueSkipLabel); } else { Label falseSkipLabel = block.CreateTempLabel(); ifReplacement.Add(new Goto(falseSkipLabel)); ifReplacement.Add(trueSkipLabel); ifReplacement.AddRange(ifStatement.FalseCase.Statements); ifReplacement.Add(falseSkipLabel); } block.Statements.InsertRange(nPos, ifReplacement); } } } }
public async System.Threading.Tasks.Task <CMGotoResult> CMGotoListener(JToken arg) { CMGotoParams request = arg.ToObject <CMGotoParams>(); Document document = CheckDoc(request.TextDocument); int pos = request.Pos; if (trace) { System.Console.Error.WriteLine("<-- CMGotoListener"); System.Console.Error.WriteLine(arg.ToString()); (int, int)bs = LanguageServer.Module.GetLineColumn(pos, document); System.Console.Error.WriteLine(""); } var is_enter = request.IsEnter; CMGotoResult s = Goto.main(false, is_enter, document, pos); return(s); }
private ICollection <Statement> GetNextStatement(Statement statement) { var result = new List <Statement>(); int index = Block.Statements.IndexOf(statement); if (index != -1 && index != Block.Statements.Count - 1) { result.Add(Block.Statements[index + 1]); } Goto go = statement as Goto; if (go != null && go.CondDecl != null) { result.Add(go.TargetLabel); } return(result); }
public async void LoadMainMenu() { if (MusicGameEngine.loadedFromAVG) { // 中途退出算失败 var naniCamera = Engine.GetService <ICameraManager>().Camera; naniCamera.enabled = true; var inputManager = Engine.GetService <IInputManager>(); inputManager.ProcessInput = true; if (MusicGameEngine.scriptName_FailLevel != null && MusicGameEngine.label_FailLevel != null) { Goto gtcmd = new Goto(); gtcmd.Path = new NamedString(MusicGameEngine.scriptName_FailLevel, MusicGameEngine.label_FailLevel); await gtcmd.ExecuteAsync(); } SceneManager.UnloadSceneAsync(1); return; } StartCoroutine(WaitForLoadMainMenuFinished()); }
// Update is called once per frame void Update() { if (sliderPower.value == 5) { GoNext = Goto.Down; } if (sliderPower.value == 0) { GoNext = Goto.Up; } if (GoNext == Goto.Up) { sliderPower.value += 0.1F; } if (GoNext == Goto.Down) { sliderPower.value -= 0.1F; } }
public override void TakeDamage(int damage, Vector3 origin = default(Vector3)) { base.TakeDamage(damage); if (!IsDead() && origin != default && (CurrentInstruction.GetType() != typeof(Attack) && CurrentInstruction.GetType() != typeof(Chase))) { Instructions.Push(CurrentInstruction); if (origin != default) { CurrentInstruction = new Goto(origin, 2, this); } } if (CurrentHealth < 10) { canAttack = false; Instructions.Clear(); Instructions.Push(new Interact(barracks, this)); CurrentInstruction = new Goto(barracks.transform.position, 0, this); reportPosition = origin; } }
void OnTriggerEnter(Collider other) { if (other.tag == "enemy") { Goto cs = other.gameObject.GetComponent <Goto>(); //Vector3.Distance(cs.startpos, Vector3(0, 0, 0)); float survivetime = Time.time - cs.startTime; float distance = Vector3.Distance(cs.startpos, gameObject.transform.position); float avgspeed = distance / survivetime; Debug.Log("Survive time: " + survivetime.ToString() + " Distance: " + distance.ToString() + " avg speed: " + avgspeed.ToString() + " name: " + cs.name); Debug.Log(Time.time - cs.startTime); damage += damagepoints; //print(damage); //other.gameObject.SetActive(false); Destroy(other.gameObject); SetCountText(); EndGame(); animator.SetBool("reachTower", true); } }
protected internal override Node TransformGoto(Goto @goto) { return Dispatch(@goto); }
public virtual Statement VisitGoto(Goto Goto, Goto changes, Goto deletions, Goto insertions){ this.UpdateSourceContext(Goto, changes); if (Goto == null) return changes; if (changes != null){ if (deletions == null || insertions == null) Debug.Assert(false); else{ } }else if (deletions != null) return null; return Goto; }
void case_973() #line 6481 "cs-parser.jay" { var lt = (LocatedToken) yyVals[-1+yyTop]; yyVal = new Goto (lt.Value, GetLocation (yyVals[-2+yyTop])); lbag.AddStatement (yyVal, GetLocation (yyVals[-1+yyTop]), GetLocation (yyVals[0+yyTop])); }
public override Statement VisitGoto(Goto Goto) { if (Goto == null) return null; if (Goto.TargetLabel == null) return Goto; //could happen if parser recovered from error. this.HandleError(Goto.TargetLabel, Error.NoSuchLabel, Goto.TargetLabel.ToString()); return null; }
public override bool AddGotoOrigin (UsageVector vector, Goto goto_stmt) { Parent.AddGotoOrigin (vector, goto_stmt); return true; }
protected internal override void TraverseGoto(Goto @goto) { Dispatch(@goto); }
public virtual void VisitGoto(Goto Goto) { }
public override Statement VisitGoto(Goto Goto) { throw new ApplicationException("unimplemented"); }
/// <summary> /// Parses the gotos from the parse table. /// </summary> /// <param name="listTerm">A list of goto terms.</param> /// <returns>The parsed gotos.</returns> /// <example> /// A goto term might look like this: /// <code> /// goto([range(9,10),13,32],21) /// </code> /// </example> private IReadOnlyList<Goto> ParseGotos(IListTerm listTerm) { #region Contract Contract.Requires<ArgumentNullException>(listTerm != null); Contract.Ensures(Contract.Result<IReadOnlyList<Goto>>() != null); #endregion var result = new Goto[listTerm.Count]; int index = 0; foreach (var term in from t in listTerm.SubTerms select t.ToCons("goto", 2)) { var characters = ParseCharacterRanges((IListTerm)term[0]); var labels = ParseLabelRanges((IListTerm)term[0]); var nextState = new StateRef(term[1].ToInt32()); result[index++] = new Goto(nextState, characters, labels); } return result; }
public virtual object Visit (Goto gotoStatement) { return null; }
public override Statement VisitGoto(Goto Goto) { if (Goto == null) return null; return base.VisitGoto((Goto)Goto.Clone()); }
public override bool AddGotoOrigin (UsageVector vector, Goto goto_stmt) { if (goto_stmt.Target != stmt.Name) return Parent.AddGotoOrigin (vector, goto_stmt); // backward jump goto_stmt.SetResolvedTarget (stmt); actual.MergeOrigins (vector.Clone ()); return false; }
public override bool AddGotoOrigin (UsageVector vector, Goto goto_stmt) { string name = goto_stmt.Target; LabeledStatement s = Block.LookupLabel (name); if (s != null) throw new InternalErrorException ("Shouldn't get here"); if (Parent == null) { Error_UnknownLabel (goto_stmt.loc, name, Report); return false; } int errors = Report.Errors; Parent.AddGotoOrigin (vector, goto_stmt); if (errors == Report.Errors) Report.Error (1632, goto_stmt.loc, "Control cannot leave the body of an anonymous method"); return false; }
public override Statement VisitGoto(Goto Goto){ if (Goto == null) return null; if (Goto.TargetLabel == null) return Goto; //could happen if parser recovered from error. Block target = this.targetFor[Goto.TargetLabel.UniqueIdKey] as Block; if (target == null){ if (this.outerTargetFor != null){ target = this.outerTargetFor[Goto.TargetLabel.UniqueIdKey] as Block; if (target != null){ this.HandleError(Goto, Error.GotoLeavesNestedMethod); if (this.referencedLabels != null) this.referencedLabels[target.UniqueKey] = Goto.TargetLabel; return null; } } return Goto; } if (this.referencedLabels != null) this.referencedLabels[target.UniqueKey] = Goto.TargetLabel; Branch br = new Branch(null, target); br.SourceContext = Goto.SourceContext; return br; }
public GotoOrigin (SavedOrigin next, UsageVector vector, Goto stmt) : base (next, vector) { Stmt = stmt; }
protected override void TraverseGoto(Goto @goto) { _ptx.bra(labels.GetOrCreate(@goto.LabelId, () => _ptx.def_label(@goto.ResolveLabel().Name))); }
void case_896() #line 5969 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new Goto (lt.Value, GetLocation (yyVals[-2+yyTop])); lbag.AddStatement (yyVal, GetLocation (yyVals[-1+yyTop]), GetLocation (yyVals[0+yyTop])); }
protected internal virtual void TraverseGoto(Goto @goto) { @goto.Unsupported(); }
protected internal virtual Node TransformGoto(Goto @goto) { return @goto.AcceptTransformer(this, true); }
protected internal override void TraverseGoto(Goto @goto) { Types.Add(@goto, null); }
public virtual Statement VisitGoto(Goto Goto){ return Goto; }
protected internal override void TraverseGoto(Goto @goto) { var label = @goto.ResolveLabel(); _writer.Write("goto " + label.Name); }
public virtual Differences VisitGoto(Goto goto1, Goto goto2){ Differences differences = new Differences(goto1, goto2); if (goto1 == null || goto2 == null){ if (goto1 != goto2) differences.NumberOfDifferences++; else differences.NumberOfSimilarities++; return differences; } Goto changes = (Goto)goto2.Clone(); Goto deletions = (Goto)goto2.Clone(); Goto insertions = (Goto)goto2.Clone(); Differences diff = this.VisitIdentifier(goto1.TargetLabel, goto2.TargetLabel); if (diff == null){Debug.Assert(false); return differences;} changes.TargetLabel = diff.Changes as Identifier; deletions.TargetLabel = diff.Deletions as Identifier; insertions.TargetLabel = diff.Insertions as Identifier; Debug.Assert(diff.Changes == changes.TargetLabel && diff.Deletions == deletions.TargetLabel && diff.Insertions == insertions.TargetLabel); differences.NumberOfDifferences += diff.NumberOfDifferences; differences.NumberOfSimilarities += diff.NumberOfSimilarities; if (differences.NumberOfDifferences == 0){ differences.Changes = null; differences.Deletions = null; differences.Insertions = null; }else{ differences.Changes = changes; differences.Deletions = deletions; differences.Insertions = insertions; } return differences; }
public override bool AddGotoOrigin (UsageVector vector, Goto goto_stmt) { LabeledStatement s = current_vector.Block == null ? null : current_vector.Block.LookupLabel (goto_stmt.Target); if (s != null) throw new InternalErrorException ("Shouldn't get here"); if (finally_vector != null) { int errors = Report.Errors; Parent.AddGotoOrigin (vector, goto_stmt); if (errors == Report.Errors) Report.Error (157, goto_stmt.loc, "Control cannot leave the body of a finally clause"); } else { saved_origins = new GotoOrigin (saved_origins, vector, goto_stmt); } return true; }
public override object Visit (Goto gotoStatement) { var result = new GotoStatement (); var location = LocationsBag.GetLocations (gotoStatement); result.AddChild (new CSharpTokenNode (Convert (gotoStatement.loc), GotoStatement.GotoKeywordRole), GotoStatement.GotoKeywordRole); var loc = location != null ? Convert (location [0]) : TextLocation.Empty; result.AddChild (Identifier.Create (gotoStatement.Target, loc), Roles.Identifier); if (location != null && location.Count > 1) result.AddChild (new CSharpTokenNode (Convert (location [1]), Roles.Semicolon), Roles.Semicolon); return result; }
// returns true if we crossed an unwind-protected region (try/catch/finally, lock, using, ...) public virtual bool AddGotoOrigin (UsageVector vector, Goto goto_stmt) { return Parent.AddGotoOrigin (vector, goto_stmt); }
public virtual Statement VisitGoto(Goto Goto1, Goto Goto2) { return Goto1; }
public override bool AddGotoOrigin (UsageVector vector, Goto goto_stmt) { LabeledStatement stmt = Block == null ? null : Block.LookupLabel (goto_stmt.Target); if (stmt == null) return Parent.AddGotoOrigin (vector, goto_stmt); // forward jump goto_stmt.SetResolvedTarget (stmt); stmt.AddUsageVector (vector); return false; }