public override void VisitCase(CaseStatement caseStmt) { LocalVariable test = localVariableStack.GetLocal(caseStmt.TestName); test.Declare(ilGenerator); test.EmitStorePrefix(ilGenerator); caseStmt.Test.Accept(this); BoxIfNecessary(caseStmt.Test.RawType, test.RawType); test.EmitStore(ilGenerator); Label endLabel = ilGenerator.DefineLabel(); foreach (CaseWhen when in caseStmt.WhenPartList) { Label thenLabel = ilGenerator.DefineLabel(); Label nextLabel = ilGenerator.DefineLabel(); foreach (CallExpression call in when.TestCallList) { call.Accept(this); ilGenerator.Emit(OpCodes.Brtrue, thenLabel); } ilGenerator.Emit(OpCodes.Br, nextLabel); ilGenerator.MarkLabel(thenLabel); when.ThenPart.Accept(this); ilGenerator.Emit(OpCodes.Br, endLabel); ilGenerator.MarkLabel(nextLabel); } if (caseStmt.ElsePart != null) caseStmt.ElsePart.Accept(this); ilGenerator.MarkLabel(endLabel); }
public override void VisitCase(CaseStatement caseStmt) { caseStmt.Test.Accept(this); caseStmt.TestName = getTemporallyName(); localVariableStack.AddLocal(caseStmt.TestName, caseStmt.Test.NodeType); foreach (CaseWhen when in caseStmt.WhenPartList) { foreach (Expression value in when.ValueList) { LocalExpression test = new LocalExpression(caseStmt.TestName, value.Location); ModalExpression arg = new ModalExpression(ArgumentMode.In, value, value.Location); TypedNodeList args = new TypedNodeList(arg); CallExpression call = new CallExpression(test, "is_eq", args, value.Location); call.Accept(this); if (call.NodeType == typeManager.BoolType) { when.TestCallList.Append(call); } else { if (call.NodeType != null) { report.Error(value.Location, "no match for {0}::is_eq({1}):BOOL", caseStmt.Test.NodeType.FullName, value.NodeType.FullName); } } } when.ThenPart.Accept(this); } if (caseStmt.ElsePart != null) caseStmt.ElsePart.Accept(this); }
public virtual void VisitCase(CaseStatement caseStmt) { }