Beispiel #1
0
        public LabelReference CreateLabel()
        {
            LabelReference reference = new LabelReference();

            this._ilmarkers.Add(reference);
            return(reference);
        }
Beispiel #2
0
        private LoopInterrupt(LabelReference label, bool isBreak) : base()
        {
            this.IsBreak = isBreak;
            this.Label   = label;

            this.attachPostConstructor();
        }
Beispiel #3
0
        public LabelReference CreateLabel()
        {
            LabelReference label = new LabelReference();

            _ilmarkers.Add(label);
            return(label);
        }
Beispiel #4
0
        public void AddReferenceWord()
        {
            Word word1 = new Word(0x1234);
            Word word2 = new Word(0x5678);

            m_relModule.AddWord(word1);
            m_relModule.AddWord(word2);
            MemoryOffset wordOffset = new MemoryOffset(2);

            m_relModule.AddReferenceWord(m_label);

            IEnumerable <Word> actualWords = m_relModule.Words;

            Word[] expectedWords = TestUtils.MakeArray(word1, word2, Word.Zero);
            TestUtils.CheckEnumerable(
                expectedWords, actualWords,
                "語のコレクションに、リンク時にラベルのアドレスと置き換わる値が 0 の語が追加される");

            Int32 labelRefsCount = m_relModule.LabelRefs.Count();

            Assert.AreEqual(1, labelRefsCount, "ラベル参照のコレクションに、ラベルへの参照が 1 つ追加される");

            LabelReference expectedLabelRef = LabelReference.MakeForUnitTest(m_label, wordOffset);
            LabelReference actualLabelRef   = m_relModule.LabelRefs.First();

            LabelReferenceTest.Check(
                expectedLabelRef, actualLabelRef,
                "ラベルへの参照には、参照するラベルとそのラベルのアドレスが入る語のオフセットが記録される");
        }
Beispiel #5
0
        public VariableBuilder GrantAccess(params string[] friends)
        {
            if (this.friends != null || this.build != null)
            {
                throw new InvalidOperationException();
            }

            this.friends = friends.Select(it => LabelReference.CreateGlobal(it));
            return(this);
        }
Beispiel #6
0
        public void ResolveReferringAddress()
        {
            LabelAddressResolver labelAddrResolver = LabelAddressResolverTest.Make();
            const UInt16         LabelAddress      = 0x2468;
            LabelDefinition      labelDef          = LabelDefinitionTest.Make("LBL001", 0, LabelAddress);

            labelAddrResolver.LabelTable.RegisterForUnitTest(labelDef);

            const Int32    WordCount   = 4;
            WordCollection actualWords = WordCollectionTest.MakeWords(WordCount);
            MemoryOffset   wordOffset  = new MemoryOffset(1);
            LabelReference labelRef    = LabelReference.MakeForUnitTest(labelDef.Label, wordOffset);

            labelRef.ResolveReferringAddress(labelAddrResolver, actualWords);

            WordCollection expectedWords = WordCollectionTest.MakeWords(WordCount);

            expectedWords[wordOffset] = new Word(LabelAddress);
            TestUtils.CheckEnumerable(
                expectedWords, actualWords,
                "ラベルを参照する語の値がそのラベルのアドレスに置き換えられる");
        }
Beispiel #7
0
        public void Make()
        {
            Label          referringLabel = new Label("LBL001");
            WordCollection actualWords    = new WordCollection();

            // actualWords に 1 語追加して、語のオフセットを初期値の 0 以外の値にする。
            MemoryOffset wordOffset = new MemoryOffset(1);
            Word         addedWord  = new Word(0x55AA);

            actualWords.Add(addedWord);

            LabelReference actualLabelRef = LabelReference.Make(referringLabel, actualWords);

            Word[] expectedWords = TestUtils.MakeArray(addedWord, Word.Zero);
            TestUtils.CheckEnumerable(
                expectedWords, actualWords,
                "オブジェクトコードに、参照するラベルのアドレスを入れる場所として、値が 0 の語が追加される");

            LabelReference expectedLabelRef = LabelReference.MakeForUnitTest(referringLabel, wordOffset);

            Check(
                expectedLabelRef, actualLabelRef,
                "作成された labelRef には、参照するラベルとそのアドレスを入れるオフセットが入る");
        }
Beispiel #8
0
 public static LoopInterrupt CreateContinue(string label = null)
 {
     return(new LoopInterrupt(label == null ? (LabelReference)null : LabelReference.CreateLocal(label), isBreak: false));
 }
Beispiel #9
0
 public void Deconstruct(out ScriptArgument arg, out LabelReference offset)
 {
     arg    = Arg;
     offset = Offset;
 }
Beispiel #10
0
 public Branch(ScriptArgument arg, LabelReference offset)
 {
     Arg    = arg;
     Offset = offset;
 }
Beispiel #11
0
 internal static void Check(LabelReference expected, LabelReference actual, String message)
 {
     LabelTest.Check(expected.ReferringLabel, actual.ReferringLabel, "ReferringLabel: " + message);
     MemoryOffsetTest.Check(expected.WordOffset, actual.WordOffset, "ObjectOffset: " + message);
 }