Beispiel #1
0
        public TypeCompiler(Configuration configuration, AssemblyCompiler assembly, TypeDefinition type)
        {
            Assembly = assembly;

            foreach (var method in type.Methods)
            {
                MyMethods.Add(method, new MethodCompiler(configuration, this, method));
            }
        }
Beispiel #2
0
        public void AddBlock(AssemblyCompiler assembly)
        {
            foreach (var type in assembly.Types)
            {
                foreach (var method in type.Methods)
                {
                    foreach (var label in method.Labels)
                    {
                        //Labels.Add(label.Key, label.Value + Instructions.Count);
                    }

                    foreach (var comments in method.Comments)
                    {
                        Comments.Add(comments.Key + Instructions.Count, comments.Value.ToArray());
                    }

                    Instructions.AddRange(method.Body);
                }
            }

            foreach (var op in Instructions)
            {
                if (op.AType == OperandType.Label)
                {
                    op.A     = Resolve(op.ALabel);
                    op.AType = OperandType.Immediate;
                }

                if (op.BType == OperandType.Label)
                {
                    op.B     = Resolve(op.BLabel);
                    op.BType = OperandType.Immediate;
                }

                if (op.CType == OperandType.Label)
                {
                    op.C     = Resolve(op.CLabel);
                    op.CType = OperandType.Immediate;
                }

                if (op.MaxRegister > MinRegisters)
                {
                    MinRegisters = op.MaxRegister;
                }
            }
        }