public void Visit(EquExpr equExpr, object[] args) { equExpr.FirstOp.Accept(this); equExpr.SecondOp.Accept(this); RightValue v1 = readRightValue(equExpr.FirstOp); RightValue v2 = readRightValue(equExpr.SecondOp); DataType resultType = readAlgoOperand(v1, v2, equExpr.Location); BoolConst result = new BoolConst(); if (resultType == DataType.Int) { result.Value = Convert.ToInt32(v1.GetValueObject()) == Convert.ToInt32(v2.GetValueObject()); } else if (resultType == DataType.Float) { kernel.IssueWarning(new Error(ErrorType.EqualOnFloat, equExpr.Location)); result.Value = Convert.ToDouble(v1.GetValueObject()) == Convert.ToDouble(v2.GetValueObject()); } else { throw new Exception(); } equExpr.RightValue = result; }
public void Visit(SwitchStmt switchStmt, object[] args) { RightValue value = exprProcessor.Eval(switchStmt.Expression); if (value is FloatConst) { kernel.IssueWarning(new Error(ErrorType.EqualOnFloat, switchStmt.Location)); } foreach (SwitchCase switchCase in switchStmt.SwitchCaseList) { if (!(value is FloatConst) && switchCase.Value is FloatConst) { kernel.IssueWarning(new Error(ErrorType.EqualOnFloat, switchCase.Location)); } if (switchCase.Value == null || switchCase.Value.IsEqualValueTo(value)) { kernel.RuntimeData.ScopeStack.Open(new LocalScope()); kernel.RuntimeData.InstructionStack.Push(InstructionStack.CLOSE_LOCAL_SCOPE_FLAG); kernel.RuntimeData.InstructionStack.Push(switchCase.CaseContent); break; } } kernel.Next(); }