Example #1
0
        CallStackItem GetTopNonClrFunction()
        {
            CallStackItem stackframe = null;

            for (int i = 0; i < m_ExecutionStack.Count; i++)
            {
                stackframe = m_ExecutionStack.Peek(i);

                if (stackframe.ClrFunction == null)
                {
                    break;
                }
            }

            return(stackframe);
        }
Example #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);
            }
        }