示例#1
0
            public bool Abolish(string functor, int arity)
            {
                string key = BaseTerm.MakeKey(functor, arity);

                if (predefineds.Contains(key))
                {
                    IO.Error("abolish of predefined predicate '{0}/{1}' not allowed", functor, arity);
                }

                PredicateDescr pd = this[key];

                if (pd == null)
                {
                    return(false);
                }

                predTable.Remove(key);

#if arg1index
                pd.DestroyFirstArgIndex(); // rebuilt by ResolveIndices()
#endif
                ResolveIndices();

                return(true);
            }
示例#2
0
            public UndefAction ActionWhenUndefined(string f, int a)
            {
                UndefAction u;

                actionWhenUndefined.TryGetValue(BaseTerm.MakeKey(f, a), out u);

                return(u);
            }
示例#3
0
            public void SetDiscontiguous(BaseTerm t)
            {
                if (t == null || t.FunctorToString != SLASH || !t.Arg(0).IsAtom || !t.Arg(1).IsInteger)
                {
                    IO.Error("Illegal or missing argument '{0}' for discontiguous/1", t);
                }

                // The predicate descriptor does not yet exist (and may even not come at all!)
                string key = BaseTerm.MakeKey(t.Arg(0).FunctorToString, t.Arg(1).To <short>());

                //IO.WriteLine ("--- Setting discontiguous for {0} in definitionFile {1}", key, Globals.ConsultFileName);
                isDiscontiguous[key] = "true";
            }
示例#4
0
            PredicateDescr SetClauseList(string f, int a, ClauseNode c)
            {
                string         key = BaseTerm.MakeKey(f, a);
                PredicateDescr pd  = this[key];

                if (pd == null)
                {
                    this[key] = pd =
                        new PredicateDescr(null, ConsultFileName, f, a, c);
                }
                else
                {
                    pd.SetClauseListHead(c);
                }

                pd.AdjustClauseListEnd();

                return(pd);
            }
示例#5
0
            public bool SetSpy(bool enabled, string functor, int arity, BaseTerm list)
            {
                SpyPort ports;

                if (list == null)
                {
                    ports = SpyPort.Full;
                }
                else
                {
                    ports = SpyPort.None;
                    string s;

                    while (list.Arity == 2)
                    {
                        s = list.Arg(0).FunctorToString;

                        try
                        {
                            ports |= (SpyPort)Enum.Parse(typeof(SpyPort), s);
                        }
                        catch
                        {
                            IO.Error("Illegal value '{0}'", s);
                        }
                        list = list.Arg(1);
                    }
                }

                PredicateDescr pd;

                if (arity == -1)
                {
                    bool found = false;

                    foreach (KeyValuePair <string, PredicateDescr> kv in predTable)
                    {
                        if ((pd = kv.Value).Functor == functor)
                        {
                            found = true;
                            pd.SetSpy(enabled, pd.Functor, pd.Arity, ports, !enabled);
                        }
                    }

                    if (!found)
                    {
                        IO.Error("Predicate does not exist: {0}", functor);
                    }

                    return(found);
                }
                else
                {
                    predTable.TryGetValue(BaseTerm.MakeKey(functor, arity), out pd);

                    if (pd == null)
                    {
                        IO.Error("Predicate does not exist: {0}/{1}", functor, arity);

                        return(false);
                    }

                    pd.SetSpy(enabled, functor, arity, ports, !enabled);
                }

                return(true);
            }
示例#6
0
 public bool IsPredicate(string functor, int arity)
 {
     return(this.Contains(BaseTerm.MakeKey(functor, arity)));
 }
示例#7
0
 public void SetActionWhenUndefined(string f, int a, UndefAction u)
 {
     actionWhenUndefined[BaseTerm.MakeKey(f, a)] = u;
 }