예제 #1
0
        private static void CgNameExp(FuncInfo fi, NameExp node, int a)
        {
            var r = fi.SlotOfLocVar(node.Name);

            if (r >= 0)
            {
                fi.EmitMove(a, r);
            }
            else
            {
                var idx = fi.IndexOfUpval(node.Name);
                if (idx >= 0)
                {
                    fi.EmitGetUpval(a, idx);
                }
                else
                {
                    var taExp = new TableAccessExp
                    {
                        PrefixExp = new NameExp
                        {
                            Line = 0,
                            Name = "_ENV"
                        },
                        KeyExp = new StringExp
                        {
                            Line = 0,
                            Str  = node.Name
                        }
                    };
                    CgTableAccessExp(fi, taExp, a);
                }
            }
        }