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); } } } }
// 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); } } }
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)); } }
public Error(ErrorValue value) { this.value = value; this.error = this.value.ToString(); }
protected static Gen GenLoadErrorNan(ErrorValue error) { return new Gen(delegate { LoadErrorNan(error); }); }
protected static void LoadErrorNan(ErrorValue error) { ilg.Emit(OpCodes.Ldc_R8, error.ErrorNan); }
protected static void LoadErrorValue(ErrorValue error) { ilg.Emit(OpCodes.Ldc_I4, error.index); ilg.Emit(OpCodes.Call, ErrorValue.fromIndexMethod); }
public CGError(ErrorValue errorValue) { this.errorValue = errorValue; }