Exemplo n.º 1
0
        public virtual IdentifierOperand Get(string name, bool inherit = true)
        {
            IdentifierOperand identifier;

            if (_identifiers.TryGetValue(name, out identifier))
            {
                return(identifier);
            }

            if (inherit && Previous != null)
            {
                return(Previous.Get(name));
            }

            return(null);
        }
Exemplo n.º 2
0
        public FunctionContext(ExpressionCompiler compiler, int frameIndex, Scope prevScope, string parentName, string name)
        {
            _instructions = new List <Instruction>();
            _loopLabels   = new IndexedStack <Tuple <LabelOperand, LabelOperand> >();

            Compiler   = compiler;
            FrameIndex = frameIndex;

            Scope = new Scope(frameIndex, prevScope);

            ParentName = parentName;
            Name       = name;
            FullName   = string.Format("{0}{1}{2}", parentName, string.IsNullOrEmpty(parentName) ? "" : ".", Name ?? "");

            AssignedName = name != null?prevScope.Get(name) : null;

            Label = Compiler.MakeLabel("function");

            IdentifierCount = 0;
        }
Exemplo n.º 3
0
        public FunctionContext(ExpressionCompiler compiler, int argIndex, int localIndex, Scope prevScope, string parentName, string name)
        {
            _instructions = new List<Instruction>();
            _loopLabels = new IndexedStack<Tuple<LabelOperand, LabelOperand>>();

            Compiler = compiler;
            ArgIndex = argIndex;
            LocalIndex = localIndex;

            Scope = prevScope;

            ParentName = parentName;
            Name = name;
            FullName = string.Format("{0}{1}{2}", parentName, string.IsNullOrEmpty(parentName) ? "" : ".", Name ?? "");

            AssignedName = name != null ? prevScope.Get(name) : null;
            Label = Compiler.MakeLabel("function");

            IdentifierCount = 0;
        }
Exemplo n.º 4
0
 public virtual IdentifierOperand Identifier(string name)
 {
     return(Scope.Get(name));
 }
Exemplo n.º 5
0
 public IdentifierOperand Identifier(string name)
 {
     return(_scope.Get(name));
 }