public void CheckBitArithmetical(ExpState state) { if (state.ResultType.IsEnum) { return; } CheckArithmetical(state); }
public void CheckArithmetical(ExpState state) { if (state == null) { if ((List.Str == "-" || List.Str == "+") && List.Prev().Str == List.Str) { List.ThrowException("Sorry, " + List.Str + List.Str + " is not implemented."); } List.ThrowException("Missing operand here."); } if (state.ResultType == typeof(char) && (StartType == typeof(int) || StartType == typeof(long))) { return; } if (state.ResultType == typeof(bool) && ((Sizes & OperandSizes.Bool) == OperandSizes.Bool)) { return; } if ((state.ResultType == typeof(int) || state.ResultType == typeof(long)) && ((Sizes & OperandSizes.Integer) == OperandSizes.Integer)) { return; } if ((state.ResultType == typeof(float) || state.ResultType == typeof(double)) && ((Sizes & OperandSizes.Real) == OperandSizes.Real)) { return; } string s = ""; if (((Sizes & OperandSizes.Bool) == OperandSizes.Bool)) { s += "bool "; } if (((Sizes & OperandSizes.Integer) == OperandSizes.Integer)) { if (s != "") { s += "or "; } s += "integer "; } if (((Sizes & OperandSizes.Real) == OperandSizes.Real)) { if (s != "") { s += "or "; } s += "real "; } List.ThrowException("Expected an operand of type '" + s + "'."); }
public ExpState NextBitArithmetical(ExpState state) { if (state.ResultType.IsEnum) { if (state.ResultType == StartType) { return(state); } List.ThrowException("Enum types not the same"); return(null); } else { return(Next(state)); } }
public ExpState NextComparison(ExpState state) { if (state.IsNull && StartType == null) { return(state); } if (state.IsNull && !StartType.IsValueType) { return(new ExpState(StartType)); } if (state.ResultType == StartType) { return(state); } if (StartType == null && !state.ResultType.IsValueType) { return(state); } return(Next(state)); }
public OperandSize(LexList list, ExpState state, OperandSizes sizes, Emit e) { StartType = state.ResultType; Sizes = sizes; List = list; E = e; }
public ExpState Next(ExpState state) { CheckArithmetical(state); Type firstType = StartType; Type secondType = state.ResultType; if (firstType == secondType) { return(state); } if (firstType == typeof(bool) || secondType == typeof(bool)) { List.ThrowException("Mixture of bool and non bool operands."); } switch (GetTypePair(firstType, secondType)) { case Char_Char: case Char_Int: case Int_Char: case Int_Int: case Long_Long: case Float_Float: case Double_Double: break; case Char_Long: case Int_Long: ConvertNonTopToLong(); break; case Long_Int: case Long_Char: ConvertTopToLong(); state = new ExpState(typeof(long)); break; case Char_Double: case Int_Double: case Long_Double: case Float_Double: ConvertNonTopToDouble(); break; case Double_Int: case Double_Char: case Double_Long: case Double_Float: ConvertTopToDouble(); state = new ExpState(typeof(double)); break; case Char_Float: case Int_Float: case Long_Float: case Float_Int: case Float_Char: case Float_Long: ConvertTopToDouble(); ConvertNonTopToDouble(); state = new ExpState(typeof(double)); break; } return(state); }