public PushValue(T x) { mValue = new CatMetaValue <T>(x); msName = mValue.GetData().ToString(); msValueType = CatKind.TypeNameFromObject(x); mpFxnType = CatFxnType.Create("( -> " + msValueType + ")"); }
public AstMacroStackVar(PegAstNode node) : base(node) { if (node.GetNumChildren() < 1) { throw new Exception("invalid macro stack variable"); } if (node.GetNumChildren() > 2) { throw new Exception("invalid macro stack variable"); } msName = node.GetChild(0).ToString(); if (node.GetNumChildren() == 2) { AstFxnType typeNode = new AstFxnType(node.GetChild(1)); mType = CatFxnType.Create(typeNode) as CatFxnType; if (mType == null) { throw new Exception("expected function type " + typeNode.ToString()); } } CheckLabel(AstLabel.MacroStackVar); }
public Method(Object o, MethodInfo mi) : base(mi.Name, "undocumented method from CLR") { mMethod = mi; mObject = o; string sType = MethodToTypeString(mi); mpFxnType = CatFxnType.Create(sType); mpFxnType = CatVarRenamer.RenameVars(mpFxnType); }
public SelfFunction(string name) : base(name) { mpFxnType = CatFxnType.Create("('A -> 'B)"); }
public PrimitiveFunction(string sName, string sType, string sDesc, string sTags) : base(sName, sDesc, sTags) { mpFxnType = CatFxnType.Create(sType); mpFxnType = CatVarRenamer.RenameVars(mpFxnType); }
public static CatFxnType Infer(CatExpr f) { if (!Config.gbTypeChecking) { return(null); } if (f.Count == 0) { if (Config.gbVerboseInference) { Log("type is ( -> )"); } return(CatFxnType.Create("( -> )")); } else if (f.Count == 1) { Function x = f[0]; if (Config.gbVerboseInference) { OutputInferredType(x.GetFxnType()); } return(x.GetFxnType()); } else { Function x = f[0]; CatFxnType ft = x.GetFxnType(); if (Config.gbVerboseInference) { Log("initial term = " + x.GetName() + " : " + x.GetFxnTypeString()); } for (int i = 1; i < f.Count; ++i) { if (ft == null) { return(ft); } Function y = f[i]; if (Config.gbVerboseInference) { Log("Composing accumulated terms with next term"); string s = "previous terms = { "; for (int j = 0; j < i; ++j) { s += f[j].GetName() + " "; } Log(s + "} : " + ft.ToString()); Log("next term = " + y.GetName() + " : " + y.GetFxnTypeString()); } ft = ComposeTypes(ft, y.GetFxnType()); if (ft == null) { return(null); } } return(ft); } }