Ejemplo n.º 1
0
 public Opcode(ZMachine zm, OpcodeCompiler compiler, OpcodeAttribute attribute,
     int pc, int zCodeLength,
     int argc, OperandType[] operandTypes, short[] operandValues,
     string operandText, int resultStorage, bool branchIfTrue, int branchOffset)
 {
     this.zm = zm;
     this.compiler = compiler;
     this.attribute = attribute;
     this.PC = pc;
     this.ZCodeLength = zCodeLength;
     this.argc = argc;
     this.operandTypes = new OperandType[argc];
     Array.Copy(operandTypes, this.operandTypes, argc);
     this.operandValues = new short[argc];
     Array.Copy(operandValues, this.operandValues, argc);
     this.operandText = operandText;
     this.resultStorage = resultStorage;
     this.branchIfTrue = branchIfTrue;
     this.branchOffset = branchOffset;
 }
Ejemplo n.º 2
0
 public Opcode(ZMachine zm, OpcodeCompiler compiler, OpcodeAttribute attribute,
               int pc, int zCodeLength,
               int argc, OperandType[] operandTypes, short[] operandValues,
               string operandText, int resultStorage, bool branchIfTrue, int branchOffset)
 {
     this.zm           = zm;
     this.compiler     = compiler;
     this.attribute    = attribute;
     this.PC           = pc;
     this.ZCodeLength  = zCodeLength;
     this.argc         = argc;
     this.operandTypes = new OperandType[argc];
     Array.Copy(operandTypes, this.operandTypes, argc);
     this.operandValues = new short[argc];
     Array.Copy(operandValues, this.operandValues, argc);
     this.operandText   = operandText;
     this.resultStorage = resultStorage;
     this.branchIfTrue  = branchIfTrue;
     this.branchOffset  = branchOffset;
 }
Ejemplo n.º 3
0
        private static void InitOpcodeTable()
        {
            MethodInfo[] mis = typeof(Opcode).GetMethods(
                BindingFlags.NonPublic | BindingFlags.Instance);

            foreach (MethodInfo mi in mis)
            {
                OpcodeAttribute[] attrs = (OpcodeAttribute[])mi.GetCustomAttributes(typeof(OpcodeAttribute), false);
                if (attrs.Length > 0)
                {
                    OpcodeCompiler del = (OpcodeCompiler)Delegate.CreateDelegate(
                        typeof(OpcodeCompiler), null, mi);
                    OpcodeAttribute a    = attrs[0];
                    OpcodeInfo      info = new OpcodeInfo(a, del);
                    switch (a.OpCount)
                    {
                    case OpCount.Zero:
                        zeroOpInfos.Add((byte)(a.Number - 176), info);
                        break;

                    case OpCount.One:
                        oneOpInfos.Add((byte)(a.Number - 128), info);
                        break;

                    case OpCount.Two:
                        twoOpInfos.Add(a.Number, info);
                        break;

                    case OpCount.Var:
                        varOpInfos.Add((byte)(a.Number - 224), info);
                        break;

                    case OpCount.Ext:
                        extOpInfos.Add(a.Number, info);
                        break;
                    }
                }
            }
        }
Ejemplo n.º 4
0
        internal static string GetOpcodeName(OpcodeAttribute attribute, OpcodeCompiler handler)
        {
            if (attribute != null && attribute.Alias != null)
            {
                return(attribute.Alias);
            }

            if (handler == null)
            {
                return("<unknown>");
            }

            MethodInfo mi   = handler.Method;
            string     name = mi.Name;

            if (name.StartsWith("op_"))
            {
                return(name.Remove(0, 3));
            }
            else
            {
                return(name);
            }
        }
Ejemplo n.º 5
0
 public OpcodeInfo(OpcodeAttribute attr, OpcodeCompiler compiler)
 {
     this.Attr = attr;
     this.Compiler = compiler;
 }
Ejemplo n.º 6
0
 public OpcodeInfo(OpcodeAttribute attr, OpcodeCompiler compiler)
 {
     this.Attr     = attr;
     this.Compiler = compiler;
 }