コード例 #1
0
        public SymbolRef CreateGlobalReference(string name)
        {
            if (name == WellKnownSymbols.ENV)
            {
                throw new InternalErrorException("_ENV passed in CreateGlobalReference");
            }

            SymbolRef env = Find(WellKnownSymbols.ENV);

            return(SymbolRef.Global(name, env));
        }
コード例 #2
0
        public SymbolRef FindSymbolByName(string name)
        {
            if (m_ExecutionStack.Count > 0)
            {
                CallStackItem stackframe = GetTopNonClrFunction();

                if (stackframe != null)
                {
                    if (stackframe.Debug_Symbols != null)
                    {
                        for (int i = stackframe.Debug_Symbols.Length - 1; i >= 0; i--)
                        {
                            var l = stackframe.Debug_Symbols[i];

                            if (l.i_Name == name && stackframe.LocalScope[i] != null)
                            {
                                return(l);
                            }
                        }
                    }


                    var closure = stackframe.ClosureScope;

                    if (closure != null)
                    {
                        for (int i = 0; i < closure.Symbols.Length; i++)
                        {
                            if (closure.Symbols[i] == name)
                            {
                                return(SymbolRef.Upvalue(name, i));
                            }
                        }
                    }
                }
            }

            if (name != WellKnownSymbols.ENV)
            {
                SymbolRef env = FindSymbolByName(WellKnownSymbols.ENV);
                return(SymbolRef.Global(name, env));
            }
            else
            {
                return(SymbolRef.DefaultEnv);
            }
        }