示例#1
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);
         }
     }
 }
示例#2
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);
             }
         }
     }
 }