Beispiel #1
0
		public CGExtern(CGExpr[] es)
			: base(es, null) {
			if (es.Length < 1) {
				errorValue = ErrorValue.argCountError;
			}
			else {
				CGTextConst nameAndSignatureConst = es[0] as CGTextConst;
				if (nameAndSignatureConst == null) {
					errorValue = ErrorValue.argTypeError;
				}
				else {
					try {
						// This retrieves the method from cache, or creates it:
						ef = ExternalFunction.Make(nameAndSignatureConst.value.value);
						if (ef.arity != es.Length - 1) {
							ef = null;
							errorValue = ErrorValue.argCountError;
						}
						else {
							resType = FromType(ef.ResType);
							argTypes = new Typ[ef.arity];
							for (int i = 0; i < argTypes.Length; i++) {
								argTypes[i] = FromType(ef.ArgType(i));
							}
						}
					}
					catch (Exception exn) // Covers a multitude of sins
					{
						errorValue = ErrorValue.Make(exn.Message);
					}
				}
			}
		}
Beispiel #2
0
		// This is used to implement the ERR function
		public CGError(CGExpr[] es) {
			if (es.Length != 1) {
				errorValue = ErrorValue.argCountError;
			}
			else {
				CGTextConst messageConst = es[0] as CGTextConst;
				if (messageConst == null) {
					errorValue = ErrorValue.argTypeError;
				}
				else {
					errorValue = ErrorValue.Make("#ERR: " + messageConst.value.value);
				}
			}
		}
Beispiel #3
0
 public static Value Make(double d)
 {
     if (double.IsInfinity(d))
     {
         return(ErrorValue.numError);
     }
     else if (double.IsNaN(d))
     {
         return(ErrorValue.FromNan(d));
     }
     else if (d == 0)
     {
         return(ZERO);
     }
     else if (d == 1)
     {
         return(ONE);
     }
     else
     {
         return(new NumberValue(d));
     }
 }
Beispiel #4
0
		public Error(ErrorValue value) {
			this.value = value;
			this.error = this.value.ToString();
		}
Beispiel #5
0
		protected static Gen GenLoadErrorNan(ErrorValue error) { return new Gen(delegate { LoadErrorNan(error); }); }
Beispiel #6
0
		protected static void LoadErrorNan(ErrorValue error) { ilg.Emit(OpCodes.Ldc_R8, error.ErrorNan); }
Beispiel #7
0
		protected static void LoadErrorValue(ErrorValue error) {
			ilg.Emit(OpCodes.Ldc_I4, error.index);
			ilg.Emit(OpCodes.Call, ErrorValue.fromIndexMethod);
		}
Beispiel #8
0
		public CGError(ErrorValue errorValue) { this.errorValue = errorValue; }