public void TryCatchNodesHaveAMonotonicallyIncrementingID() { var first = new TryCatchNode(SourcePosition.NIL, new BlockNode(SourcePosition.NIL), new BlockNode(SourcePosition.NIL), new IdentNode(SourcePosition.NIL, "foo")); var second = new TryCatchNode(SourcePosition.NIL, new BlockNode(SourcePosition.NIL), new BlockNode(SourcePosition.NIL), new IdentNode(SourcePosition.NIL, "foo")); var third = new TryCatchNode(SourcePosition.NIL, new BlockNode(SourcePosition.NIL), new BlockNode(SourcePosition.NIL), new IdentNode(SourcePosition.NIL, "foo")); Assert.AreEqual(second.ID, first.ID + 1); Assert.AreEqual(third.ID, second.ID + 1); }
public void Accept(TryCatchNode node) { var endLabel = nextLabel(); var temp = methodStack.Peek(); methodStack.Push(new HassiumMethod(module, "catch")); methodStack.Peek().Parent = classStack.Peek(); table.EnterScope(); methodStack.Peek().Parameters.Add(new FunctionParameter(FunctionParameterType.Normal, node.ExceptionName), table.HandleSymbol(node.ExceptionName)); node.CatchBody.VisitChildren(this); var handler = new HassiumExceptionHandler(temp, methodStack.Peek(), endLabel); methodStack.Pop(); emit(node.SourceLocation, InstructionType.PushHandler, handler); node.TryBody.Visit(this); emit(node.SourceLocation, InstructionType.PopHandler); emitLabel(node.SourceLocation, endLabel); }
public void VisitTryCatch(TryCatchNode node) { UpdateLine(node); NewProcedure($"try{node.ID}", false, false, -1, false); UpdateLine(node); node.Try.Accept(this); asm.Return(); var tryProc = FinishProcedure(); NewProcedure($"catch{node.ID}", false, false, -1, false); UpdateLine(node); asm.AddParameter(node.Error.Value, false); asm.MarkLocal(node.Error.Value); node.Catch.Accept(this); asm.Return(); var catchProc = FinishProcedure(); Closure(tryProc); Closure(catchProc); asm.Try(); }
public void VisitTryCatch(TryCatchNode node) { VisitTryCatchHandler(node); }
public TryCatchNodeTests() { @try = new BlockNode(SourcePosition.NIL); @catch = new BlockNode(SourcePosition.NIL); subject = new TryCatchNode(SourcePosition.NIL, @try, @catch, new IdentNode(SourcePosition.NIL, "foo")); }