コード例 #1
0
        public void GetBytes_LoadStringInstruction()
        {
            var instruction   = new LoadStringInstruction("helloWorld");
            var expectedBytes = InstructionByteBuilder.Create()
                                .Opcode(Opcode.Load, LoadKind.String, "helloWorld")
                                .AsSpan();

            Assert.True(expectedBytes.SequenceEqual(instruction.GetBytes()));
        }
コード例 #2
0
        protected override void VisitLoadStringInstruction(LoadStringInstruction instruction)
        {
            var cilString = new CilString(instruction.StringValue);

            var reference = ManagedMemory.Store(cilString);

            ControlState.EvaluationStack.PushValue(reference);

            ControlState.MoveToNextInstruction();
        }
コード例 #3
0
        public override CILInstructionString BuildNode(ParseTreeNode node)
        {
            CILInstructionString result = null;

            var instrStringParseTreeNode = node.GetFirstChildWithGrammarName(GrammarNames.INSTR_STRING);

            var ldstrParseTreeNode = instrStringParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_ldstr);

            if (ldstrParseTreeNode != null)
            {
                result = new LoadStringInstruction();
            }

            if (result != null)
            {
                var compQstringParseTreeNode = node.GetFirstChildWithGrammarName(GrammarNames.compQstring);
                result.StringValue = CompQstringParseTreeNodeHelper.GetValue(compQstringParseTreeNode);

                return(result);
            }

            throw new ArgumentException("Cannot recognize CIL instruction string.");
        }
コード例 #4
0
        public void ToString_LoadStringInstruction()
        {
            var loadInstruction = new LoadStringInstruction("helloWorld");

            Assert.Equal("ldstr helloWorld", loadInstruction.ToString());
        }
コード例 #5
0
 public void VisitLoadString(LoadStringInstruction instruction) => IncrementCallCount(nameof(VisitLoadString));
コード例 #6
0
 protected abstract void VisitLoadStringInstruction(LoadStringInstruction instruction);