Example #1
0
        internal LispObject clojEval(LateSymbolPrimitive lsp, String s, LispObject[] args)
        {
            Object target  = null;
            int    indexOf = s.IndexOf(".");

            if (indexOf > 0)
            {
                String s1 = s.Substring(0, indexOf);
                target = findSymbol(target, s1);
                if (target != null)
                {
                    ((ScriptInterpreter)this).Intern(s1, target);
                }
                Package    pkg = CurrentPackage();
                Symbol     sym = pkg.findAccessibleSymbol(s);
                LispObject sf  = sym.getSymbolFunction();
                if (sf != null)
                {
                    if (sf != lsp)
                    {
                        return(sf.execute(args));
                    }
                }

                s = s.Substring(indexOf + 1);
                Object o = clojExecute(target, s, args);
                return(JavaObject.getInstance(o));
            }
            else
            {
                String s1 = s;
                target = findSymbol(target, s1);
                Object o = clojExecute(target, "", args);
                return(JavaObject.getInstance(o));
            }
        }
Example #2
0
        public Symbol Intern(string p, object globalcogbotTextForm, List <object> exceptFor, java.lang.Class ic, int depth)
        {
            Package pkg = CurrentPackage();

            if (p == null)
            {
                p = ic.getName();
                p = p.ToString();
            }
            p = p.ToUpper();
            Symbol     s  = Lisp.intern(p, pkg);
            LispObject sv = s.getSymbolValue();

            if (sv is JavaObject)
            {
                if (sv.javaInstance() == globalcogbotTextForm)
                {
                    return(s);
                }
            }
            Symbol fun  = pkg.findAccessibleSymbol("SYMBOL-JOBJECT");
            String mask = String.Format("{0} {1}", p, ic.getName());

            if (fun != null && !allExceptFor.Contains(mask))
            {
                allExceptFor.Add(mask);
                LispObject vtemp = s.getSymbolValue();
                s.setSymbolValue(s);
                var jclass = JavaObject.getInstance(ic);
                Lisp.eval(Lisp.list4(fun, new SimpleString(p), s, jclass));
                s.setSymbolValue(vtemp);
                depth++;
            }
            if (globalcogbotTextForm != null)
            {
                LispObject jo = JavaObject.getInstance(globalcogbotTextForm);
                s.setSymbolValue(jo);

                if (exceptFor.Contains(globalcogbotTextForm))
                {
                    return(s);
                }
                exceptFor.Add(globalcogbotTextForm);
            }

            if (true)
            {
                return(s);
            }

            String ns = ic.getName();

            if (!useClassname(ns))
            {
                return(s);
            }
            if (depth > 0)
            {
                AddMembers(p, s, ic, exceptFor, depth - 1);
            }
            return(s);
        }