Example #1
0
 public void SetJumpReplacing(int Label, InstructionContainer InsContainer)
 {
     if (ReplaceJumps == null)
     {
         ReplaceJumps = new Dictionary <int, InstructionContainer>();
     }
     ReplaceJumps.Add(Label, InsContainer);
 }
Example #2
0
        public InstructionContainer ExecuteOnTempInsContainer(Action Action)
        {
            var InsContainer    = new InstructionContainer();
            var OldInsContainer = this.InsContainer;

            this.InsContainer = InsContainer;

            Action();
            this.InsContainer = OldInsContainer;
            return(InsContainer);
        }
Example #3
0
        public void Add(InstructionContainer InsContainer)
        {
            var Count = Instructions.Count;

            Instructions.AddRange(InsContainer.Instructions);

            if (InsContainer.LabelPositions != null)
            {
                foreach (var e in InsContainer.LabelPositions)
                {
                    LabelPositions.Add(e.Key, e.Value + Count);
                }
            }
        }
Example #4
0
        public void Insert(int Index, InstructionContainer InsContainer)
        {
            var P = InsContainer.Instructions.Count - 1;

            if (LabelPositions != null)
            {
                foreach (var e in LabelPositions.Keys.ToArray())
                {
                    if (LabelPositions[e] >= Index)
                    {
                        LabelPositions[e] += P;
                    }
                }
            }

            Instructions.InsertRange(Index, InsContainer.Instructions);
            if (InsContainer.LabelPositions != null)
            {
                foreach (var e in InsContainer.LabelPositions)
                {
                    LabelPositions.Add(e.Key, e.Value + Index);
                }
            }
        }
Example #5
0
 public CodeGenerator(CompilerState State)
 {
     this.State        = State;
     this.InsContainer = new InstructionContainer();
 }