예제 #1
0
        public override AstNode Visit(SetAccessorDefinition node)
        {
            // Begin the node.
            builder.BeginNode(node);

            // Get the function.
            Function function = node.GetFunction();

            // Ignore declarations.
            if(node.GetChildren() == null)
                return builder.EndNode();

            // Store the old function.
            Function oldFunction = currentFunction;
            currentFunction = function;

            // Get and update lexical scope.
            LexicalScope topScope = (LexicalScope)node.GetScope();
            PushScope(topScope);

            // Create the top basic block.
            BasicBlock topBlock = CreateBasicBlock();
            topBlock.SetName("top");
            builder.SetBlock(topBlock);

            // Prepare returning, required by exception handling.
            PrepareReturning(node, function, topScope);

            // Store the indices in local variables.
            int index = function.IsStatic() ? 0 : 1;
            foreach(LocalVariable indexLocal in node.GetIndexerVariables())
            {
                builder.CreateLoadArg((byte)index++);
                builder.CreateStoreLocal(indexLocal);
            }

            // Store the "value" argument in a local variable.
            LocalVariable valueLocal = node.GetValueLocal();
            builder.CreateLoadArg((byte)index++);
            builder.CreateStoreLocal(valueLocal);

            // Visit his children.
            VisitList(node.GetChildren());

            // Finish return.
            FinishReturn(node, function);

            // Restore the scope.
            PopScope();

            // Restore the current function.
            currentFunction = oldFunction;

            return builder.EndNode();
        }
예제 #2
0
        public override AstNode Visit(SetAccessorDefinition node)
        {
            // Get the function.
            Function function = node.GetFunction();
            if(node.GetChildren() == null)
                return node;

            // Store the old function.
            Function oldFunction = currentFunction;
            currentFunction = function;

            // Update the scope.
            PushScope(node.GetScope());

            // Visit his children.
            VisitList(node.GetChildren());

            // Restore the scope.
            PopScope();

            // Restore the current function.
            currentFunction = oldFunction;

            return node;
        }