public void IfExp(IfExp e) { Label FalseLabel, EndLabel; FalseLabel = il.DefineLabel(); EndLabel = il.DefineLabel(); e.EvalExp.Visit(this); il.Emit(OpCodes.Brfalse, FalseLabel); e.ThenExp.Visit(this); il.Emit(OpCodes.Br, EndLabel); il.MarkLabel(FalseLabel); e.ElseExp.Visit(this); il.MarkLabel(EndLabel); }
public void IfExp(IfExp e) { e.EvalExp.Visit(this); CheckBool(e.EvalExp); e.ThenExp.Visit(this); e.ElseExp.Visit(this); if (e.ThenExp.ExpType != e.ElseExp.ExpType){ Console.WriteLine("Error 103: Then expression and Else Expression do not evaluate to same type"); success = false; } else { e.ExpType = e.ThenExp.ExpType; } }