public QuotedFunction(CatExpr children, CatFxnType pFxnType) { mSubFxns = new CatExpr(children.ToArray()); msDesc = "anonymous function"; msName = "_anonymous_"; mpFxnType = new CatQuotedType(pFxnType); }
public QuotedFunction(QuotedFunction first, QuotedFunction second) { mSubFxns = new CatExpr(first.GetSubFxns().ToArray()); mSubFxns.AddRange(second.GetSubFxns().ToArray()); msDesc = "anonymous composed function"; msName = ""; for (int i = 0; i < mSubFxns.Count; ++i) { if (i > 0) { msName += " "; } msName += mSubFxns[i].GetName(); } try { mpFxnType = new CatQuotedType(CatTypeReconstructor.ComposeTypes(first.GetFxnType(), second.GetFxnType())); // TODO: remove once everythign tests okay. //mpFxnType = new CatQuotedType(CatTypeReconstructor.ComposeTypes(first.GetUnquotedFxnType(), second.GetUnquotedFxnType())); } catch (Exception e) { Output.WriteLine("unable to type quotation: " + ToString()); Output.WriteLine("type error: " + e.Message); mpFxnType = null; } }
public PushFunction(CatExpr children) { mSubFxns = children.GetRange(0, children.Count); msDesc = "pushes an anonymous function onto the stack"; msName = "_function_"; if (Config.gbTypeChecking) { if (Config.gbVerboseInference) { Output.WriteLine("inferring type of quoted function " + msName); } try { // Quotations can be unclear? CatFxnType childType = CatTypeReconstructor.Infer(mSubFxns); // Honestly this should never be true. if (childType == null) { throw new Exception("unknown type error"); } mpFxnType = new CatQuotedType(childType); mpFxnType = CatVarRenamer.RenameVars(mpFxnType); } catch (Exception e) { Output.WriteLine("Could not type quotation: " + msName); Output.WriteLine("Type error: " + e.Message); mpFxnType = null; } } else { mpFxnType = null; } }