Exemple #1
0
        public AssemblerInstruction(string name, InstructionAction <T1> action, bool convertLabelsToOffset = false)
            : base(name, null, convertLabelsToOffset)
        {
            this.action = action;

            SetParameters(GetParametersFromTypes(typeof(T1)));
        }
Exemple #2
0
 public AssemblerInstruction(string name, InstructionAction action, bool convertLabelsToOffset = false)
 {
     this.Name              = name;
     this.action            = action;
     ConvertLabelsToOffsets = convertLabelsToOffset;
     parameters             = null;
 }
Exemple #3
0
        private void InitInstructionMap(IInstructionImplementation[] instructionImplementations)
        {
            InstructionMap         = new Dictionary <int, InstructionAction>();
            InstructionMetaDataMap = new Dictionary <int, InstructionAttribute>();
            LoadedLibrary          = new List <string>();
            foreach (IInstructionImplementation instrImplm in instructionImplementations)
            {
                LoadedLibrary.Add(instrImplm.GetType().Name);

                IEnumerable <MethodInfo> methods = instrImplm.GetType().GetTypeInfo().GetMethods()
                                                   .Where(m => m.GetCustomAttributes(typeof(InstructionAttribute), false).Count() > 0);

                foreach (MethodInfo method in methods)
                {
                    //get instruction info
                    InstructionAttribute attr = method.GetCustomAttribute <InstructionAttribute>();
                    //get delegate from method
                    InstructionAction action = (InstructionAction)method.CreateDelegate(typeof(InstructionAction), instrImplm);
                    //map said delegate to instruction
                    InstructionMap.Add(attr.OpCode, action);
                    InstructionMetaDataMap.Add(attr.OpCode, attr);
                }
            }

            if (this.VerboseLevel.HasFlag(VirtualMachineVerboseLevel.LoadtimeInfo))
            {
                foreach (KeyValuePair <int, InstructionAction> mappedInstruction in InstructionMap.ToList().OrderBy(kvp => kvp.Key))
                {
                    InstructionAttribute instrMetaData = InstructionMetaDataMap[mappedInstruction.Key];
                    Console.WriteLine("loaded \"{0}\" from {1} lib", instrMetaData, instrMetaData.Library);
                }
            }
        }
Exemple #4
0
 private static void Register( String mnemonic, byte argCount,
     InstructionAction action )
 {
     Instruction inst = new Instruction( mnemonic, argCount, action );
     stToAdd.Add( inst );
     stMnemonics.Add( mnemonic, inst );
 }
Exemple #5
0
        private Instruction( String mnemonic, byte argCount, InstructionAction action )
        {
            Mnemonic = mnemonic;
            ArgCount = argCount;
            Action = action;

            InstructionID = 0x00;
        }
Exemple #6
0
 public MethodChange(InstructionAction action, Instruction instruction, int index)
 {
     Action      = action;
     Instruction = instruction;
     Index       = index;
 }