コード例 #1
0
        public override void VisitNewArrayInstruction(NewArrayInstruction instruction)
        {
            ControlState.EvaluationStack.PopValue(out CilValueInt32 numElems);

            var newArr = new CilArray(instruction.TypeSpec.GetCilType(_program), numElems.Value, _program);
            var arrRef = ManagedMemory.Store(newArr);

            ControlState.EvaluationStack.PushValue(arrRef);

            ControlState.MoveToNextInstruction();
        }
コード例 #2
0
        public override CILInstructionType BuildNode(ParseTreeNode node)
        {
            var instrTypeParseTreeNode = node.GetFirstChildWithGrammarName(GrammarNames.INSTR_TYPE);

            CILInstructionType result = null;

            var boxParseTreeNode = instrTypeParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_box);

            if (boxParseTreeNode != null)
            {
                result = new BoxInstruction();
            }

            var newarrParseTreeNode = instrTypeParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_newarr);

            if (newarrParseTreeNode != null)
            {
                result = new NewArrayInstruction();
            }

            var unboxanyParseTreeNode = instrTypeParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_unboxany);

            if (unboxanyParseTreeNode != null)
            {
                result = new UnboxAnyInstruction();
            }

            if (result != null)
            {
                var typeSpecParseTreeNode = node.GetFirstChildWithGrammarName(GrammarNames.typeSpec);
                result.TypeSpecification = TypeSpecParseTreeNodeHelper.GetValue(typeSpecParseTreeNode);

                return(result);
            }

            throw new ArgumentException("Cannot recognize CIL instruction type.");
        }
コード例 #3
0
 public abstract void VisitNewArrayInstruction(NewArrayInstruction instruction);