예제 #1
0
        public object Apply(Machine machine, ValueEnvironment environment, object[] arguments)
        {
            Symbol symbol = (Symbol)arguments[0];

            string ns = symbol.Namespace;

            if (string.IsNullOrEmpty(ns))
                ns = (string)environment.GetValue(Machine.CurrentNamespaceKey);

            Variable variable = machine.GetVariable(ns, symbol.Name);

            if (variable == null)
                throw new InvalidOperationException(string.Format("Unable to resolve Variable from Symbol {0}", symbol.FullName));

            return variable;
        }
예제 #2
0
        public static Variable Intern(Machine machine, string ns, string name)
        {
            if (string.IsNullOrEmpty(ns))
                throw new InvalidOperationException("Variable has no namespace");

            Variable variable = machine.GetVariable(ns, name);

            if (variable != null)
                return variable;

            variable = new Variable(ns, name);

            machine.SetVariable(variable);

            return variable;
        }