public Opcode(Command command, int value, int mask, OpcodeType[] applicableTypes, bool pseudo) { Command = command; Value = value; Mask = mask; ApplicableTypes = applicableTypes; Pseudo = pseudo; }
public Operand(OpcodeType parentType) { _parentType = parentType; Swizzles = new[] { Operand4ComponentName.X, Operand4ComponentName.Y, Operand4ComponentName.Z, Operand4ComponentName.W }; Indices = new OperandIndex[3]; }
public static bool IsNestedSectionEnd(this OpcodeType type) { switch (type) { case OpcodeType.EndLoop: case OpcodeType.EndIf: case OpcodeType.Else: case OpcodeType.EndSwitch: return(true); default: return(false); } }
public static bool IsConditionalInstruction(this OpcodeType type) { switch (type) { case OpcodeType.BreakC: case OpcodeType.CallC: case OpcodeType.Discard: case OpcodeType.If: return(true); default: return(false); } }
private static void OptionSubParse(List <DialogueParser> Args, string incode) { int m, n = 0; do { OpcodeType opcode = OpcodeType.Option; m = n; n = incode.IndexOf(opcode.ToString(), m, StringComparison.OrdinalIgnoreCase); if (n == -1) { foreach (var op in DialogFunctionsRules.opcodeTemplates) { if (op.Value.isDefault || op.Value.opcode != OpcodeType.Option) { continue; } n = incode.IndexOf(op.Value.opcodeName, m, StringComparison.Ordinal); if (n != -1) { break; } } } if (n > -1) { string name = GetOpcodeName(incode, ref n); if (name == null) { break; // bad code } string nameLower = name.ToLowerInvariant(); if (nameLower == "gsay_option") { opcode = OpcodeType.gsay_option; //name = nameLower; } else if (nameLower == "giq_option") { opcode = OpcodeType.giq_option; //name = nameLower; } Args.Add(new DialogueParser(opcode, name, incode, n)); // n+6 n = nextPosition; } } while (n > -1 && n < incode.Length); }
public static bool OpcodeHasSwizzle(this OpcodeType type) { switch (type) { case OpcodeType.DclConstantBuffer: case OpcodeType.DclUnorderedAccessViewRaw: case OpcodeType.DclUnorderedAccessViewStructured: case OpcodeType.DclUnorderedAccessViewTyped: case OpcodeType.DclResourceRaw: case OpcodeType.DclResourceStructured: case OpcodeType.DclResource: case OpcodeType.DclSampler: return(false); default: return(true); } }
private void HandleMaps(string[] maps, SortedDictionary <int, string> dict, OpcodeType type) { foreach (string map in maps) { Console.WriteLine($"Processing {Path.GetFileName(map)}."); var scriptTables = MapLoader.LoadAllScriptFiles(map, _db, out _); foreach (ScriptTable table in scriptTables.Values) { if (type == OpcodeType.Functions) { FunctionOpcodesFromExpressions(table.Expressions, dict); } else if (type == OpcodeType.EngineGlobals) { EngineGlobalsFromExpressions(table.Expressions, dict); } } } }
public static void BuildOpcodesDictionary() { if (opcodeTemplates.Count > 0) { return; } // загружаем шаблоны из файла if (File.Exists(RulesFile)) { string[] fileBuf = File.ReadAllLines(RulesFile); foreach (string item in fileBuf) { string line = item.TrimStart(); if (line.Length == 0 || line[0] == ';') { continue; } string[] args = line.Split(','); OpcodeType type = DialogueParser.GetOpcodeType(args[0]); if (type == OpcodeType.None) { continue; } var template = new OpcodeTemplate(type, args[1].Trim(), int.Parse(args[3]), // message int.Parse(args[4]), // file int.Parse(args[5]), // node int.Parse(args[6]), // iq int.Parse(args[2]) // total func args ); template.isDefault = false; opcodeTemplates.Add(template.opcodeName, template); } } foreach (var item in templates) { opcodeTemplates.Add(item.opcodeName, item); } }
private string ReplyParseCode(int offset, int x, string name, ref string code) { // пробуем парсить код if (x < 0) { this.opcode = OpcodeType.None; return(string.Empty); } int sOffset = offset - name.Length; this.shortcode = code.Substring(sOffset, x + 1 - sOffset); if (code[x] == ')') { x--; } try { code = code.Substring(offset + 1, x - offset); } catch { return(string.Empty); } int z; if (this.opcode == OpcodeType.gsay_message) { z = code.LastIndexOf(','); code = code.Remove(z); } if (this.opcode == OpcodeType.gsay_reply || this.opcode == OpcodeType.gsay_message) { z = code.IndexOf(','); string fileNum = code.Remove(z++); if (!int.TryParse(fileNum.Trim(trimming), out this.numberMsgFile)) // тут номер файла msg { this.numberMsgFile = messageSubCode(fileNum); } code = code.Substring(z, code.Length - z); // тут номер строки } return(code); }
private void SetType() { switch (this.Instr.OpCode) { case LuaOpcode.LOADK: case LuaOpcode.GETGLOBAL: case LuaOpcode.SETGLOBAL: case LuaOpcode.CLOSURE: this.OpType = OpcodeType.ABx; break; case LuaOpcode.FORLOOP: case LuaOpcode.FORPREP: case LuaOpcode.JMP: this.OpType = OpcodeType.AsBx; break; default: this.OpType = OpcodeType.ABC; break; } }
private static int GetLength(OpcodeType type) { switch (type) { case OpcodeType.Add: case OpcodeType.Multiply: case OpcodeType.LessThan: case OpcodeType.Equals: return(4); case OpcodeType.JumpIfTrue: case OpcodeType.JumpIfFalse: return(3); case OpcodeType.Input: case OpcodeType.Output: case OpcodeType.AdjustBase: return(2); default: return(1); } }
private static ExecutableOpcodeType MapOpcodeType(OpcodeType opcodeType) { return (ExecutableOpcodeType) Enum.Parse(typeof (ExecutableOpcodeType), opcodeType.ToString()); }
public int index; // номер ? public ContentBody(string scrText, string msgText, OpcodeType type) : this(scrText, msgText, type, -1, -1, -1) { }
public static bool IsSwapHash(OpcodeType opcodeType) => opcodeType == OpcodeType.OP_HASH160 || opcodeType == OpcodeType.OP_HASH256 || opcodeType == OpcodeType.OP_SHA256;
//Copied from satoshi's code public static string GetOpName(OpcodeType opcode) { switch(opcode) { // push value case OpcodeType.OP_0: return "0"; case OpcodeType.OP_PUSHDATA1: return "OP_PUSHDATA1"; case OpcodeType.OP_PUSHDATA2: return "OP_PUSHDATA2"; case OpcodeType.OP_PUSHDATA4: return "OP_PUSHDATA4"; case OpcodeType.OP_1NEGATE: return "-1"; case OpcodeType.OP_RESERVED: return "OP_RESERVED"; case OpcodeType.OP_1: return "1"; case OpcodeType.OP_2: return "2"; case OpcodeType.OP_3: return "3"; case OpcodeType.OP_4: return "4"; case OpcodeType.OP_5: return "5"; case OpcodeType.OP_6: return "6"; case OpcodeType.OP_7: return "7"; case OpcodeType.OP_8: return "8"; case OpcodeType.OP_9: return "9"; case OpcodeType.OP_10: return "10"; case OpcodeType.OP_11: return "11"; case OpcodeType.OP_12: return "12"; case OpcodeType.OP_13: return "13"; case OpcodeType.OP_14: return "14"; case OpcodeType.OP_15: return "15"; case OpcodeType.OP_16: return "16"; // control case OpcodeType.OP_NOP: return "OP_NOP"; case OpcodeType.OP_VER: return "OP_VER"; case OpcodeType.OP_IF: return "OP_IF"; case OpcodeType.OP_NOTIF: return "OP_NOTIF"; case OpcodeType.OP_VERIF: return "OP_VERIF"; case OpcodeType.OP_VERNOTIF: return "OP_VERNOTIF"; case OpcodeType.OP_ELSE: return "OP_ELSE"; case OpcodeType.OP_ENDIF: return "OP_ENDIF"; case OpcodeType.OP_VERIFY: return "OP_VERIFY"; case OpcodeType.OP_RETURN: return "OP_RETURN"; // stack ops case OpcodeType.OP_TOALTSTACK: return "OP_TOALTSTACK"; case OpcodeType.OP_FROMALTSTACK: return "OP_FROMALTSTACK"; case OpcodeType.OP_2DROP: return "OP_2DROP"; case OpcodeType.OP_2DUP: return "OP_2DUP"; case OpcodeType.OP_3DUP: return "OP_3DUP"; case OpcodeType.OP_2OVER: return "OP_2OVER"; case OpcodeType.OP_2ROT: return "OP_2ROT"; case OpcodeType.OP_2SWAP: return "OP_2SWAP"; case OpcodeType.OP_IFDUP: return "OP_IFDUP"; case OpcodeType.OP_DEPTH: return "OP_DEPTH"; case OpcodeType.OP_DROP: return "OP_DROP"; case OpcodeType.OP_DUP: return "OP_DUP"; case OpcodeType.OP_NIP: return "OP_NIP"; case OpcodeType.OP_OVER: return "OP_OVER"; case OpcodeType.OP_PICK: return "OP_PICK"; case OpcodeType.OP_ROLL: return "OP_ROLL"; case OpcodeType.OP_ROT: return "OP_ROT"; case OpcodeType.OP_SWAP: return "OP_SWAP"; case OpcodeType.OP_TUCK: return "OP_TUCK"; // splice ops case OpcodeType.OP_CAT: return "OP_CAT"; case OpcodeType.OP_SUBSTR: return "OP_SUBSTR"; case OpcodeType.OP_LEFT: return "OP_LEFT"; case OpcodeType.OP_RIGHT: return "OP_RIGHT"; case OpcodeType.OP_SIZE: return "OP_SIZE"; // bit logic case OpcodeType.OP_INVERT: return "OP_INVERT"; case OpcodeType.OP_AND: return "OP_AND"; case OpcodeType.OP_OR: return "OP_OR"; case OpcodeType.OP_XOR: return "OP_XOR"; case OpcodeType.OP_EQUAL: return "OP_EQUAL"; case OpcodeType.OP_EQUALVERIFY: return "OP_EQUALVERIFY"; case OpcodeType.OP_RESERVED1: return "OP_RESERVED1"; case OpcodeType.OP_RESERVED2: return "OP_RESERVED2"; // numeric case OpcodeType.OP_1ADD: return "OP_1ADD"; case OpcodeType.OP_1SUB: return "OP_1SUB"; case OpcodeType.OP_2MUL: return "OP_2MUL"; case OpcodeType.OP_2DIV: return "OP_2DIV"; case OpcodeType.OP_NEGATE: return "OP_NEGATE"; case OpcodeType.OP_ABS: return "OP_ABS"; case OpcodeType.OP_NOT: return "OP_NOT"; case OpcodeType.OP_0NOTEQUAL: return "OP_0NOTEQUAL"; case OpcodeType.OP_ADD: return "OP_ADD"; case OpcodeType.OP_SUB: return "OP_SUB"; case OpcodeType.OP_MUL: return "OP_MUL"; case OpcodeType.OP_DIV: return "OP_DIV"; case OpcodeType.OP_MOD: return "OP_MOD"; case OpcodeType.OP_LSHIFT: return "OP_LSHIFT"; case OpcodeType.OP_RSHIFT: return "OP_RSHIFT"; case OpcodeType.OP_BOOLAND: return "OP_BOOLAND"; case OpcodeType.OP_BOOLOR: return "OP_BOOLOR"; case OpcodeType.OP_NUMEQUAL: return "OP_NUMEQUAL"; case OpcodeType.OP_NUMEQUALVERIFY: return "OP_NUMEQUALVERIFY"; case OpcodeType.OP_NUMNOTEQUAL: return "OP_NUMNOTEQUAL"; case OpcodeType.OP_LESSTHAN: return "OP_LESSTHAN"; case OpcodeType.OP_GREATERTHAN: return "OP_GREATERTHAN"; case OpcodeType.OP_LESSTHANOREQUAL: return "OP_LESSTHANOREQUAL"; case OpcodeType.OP_GREATERTHANOREQUAL: return "OP_GREATERTHANOREQUAL"; case OpcodeType.OP_MIN: return "OP_MIN"; case OpcodeType.OP_MAX: return "OP_MAX"; case OpcodeType.OP_WITHIN: return "OP_WITHIN"; // crypto case OpcodeType.OP_RIPEMD160: return "OP_RIPEMD160"; case OpcodeType.OP_SHA1: return "OP_SHA1"; case OpcodeType.OP_SHA256: return "OP_SHA256"; case OpcodeType.OP_HASH160: return "OP_HASH160"; case OpcodeType.OP_HASH256: return "OP_HASH256"; case OpcodeType.OP_CODESEPARATOR: return "OP_CODESEPARATOR"; case OpcodeType.OP_CHECKSIG: return "OP_CHECKSIG"; case OpcodeType.OP_CHECKSIGVERIFY: return "OP_CHECKSIGVERIFY"; case OpcodeType.OP_CHECKMULTISIG: return "OP_CHECKMULTISIG"; case OpcodeType.OP_CHECKMULTISIGVERIFY: return "OP_CHECKMULTISIGVERIFY"; // expanson case OpcodeType.OP_NOP1: return "OP_NOP1"; case OpcodeType.OP_NOP2: return "OP_NOP2"; case OpcodeType.OP_NOP3: return "OP_NOP3"; case OpcodeType.OP_NOP4: return "OP_NOP4"; case OpcodeType.OP_NOP5: return "OP_NOP5"; case OpcodeType.OP_NOP6: return "OP_NOP6"; case OpcodeType.OP_NOP7: return "OP_NOP7"; case OpcodeType.OP_NOP8: return "OP_NOP8"; case OpcodeType.OP_NOP9: return "OP_NOP9"; case OpcodeType.OP_NOP10: return "OP_NOP10"; // template matching params case OpcodeType.OP_PUBKEYHASH: return "OP_PUBKEYHASH"; case OpcodeType.OP_PUBKEY: return "OP_PUBKEY"; case OpcodeType.OP_SMALLDATA: return "OP_SMALLDATA"; case OpcodeType.OP_INVALIDOPCODE: return "OP_INVALIDOPCODE"; default: return "OP_UNKNOWN"; } }
public static bool IsDeclaration(this OpcodeType type) { return((type >= OpcodeType.DclResource && type <= OpcodeType.DclGlobalFlags) || (type >= OpcodeType.DclStream && type <= OpcodeType.DclResourceStructured) || type == OpcodeType.DclGsInstanceCount); }
public static Operand Parse(BytecodeReader reader, OpcodeType parentType) { uint token0 = reader.ReadUInt32(); if (token0 == 0) return null; var operand = new Operand(parentType); var numComponents = token0.DecodeValue<OperandNumComponents>(0, 1); switch (numComponents) { case OperandNumComponents.Zero: { operand.NumComponents = 0; break; } case OperandNumComponents.One: { operand.NumComponents = 1; break; } case OperandNumComponents.Four: { operand.NumComponents = 4; operand.SelectionMode = token0.DecodeValue<Operand4ComponentSelectionMode>(2, 3); switch (operand.SelectionMode) { case Operand4ComponentSelectionMode.Mask: { operand.ComponentMask = token0.DecodeValue<ComponentMask>(4, 7); break; } case Operand4ComponentSelectionMode.Swizzle: { var swizzle = token0.DecodeValue(4, 11); Func<uint, byte, Operand4ComponentName> swizzleDecoder = (s, i) => (Operand4ComponentName) ((s >> (i * 2)) & 3); operand.Swizzles[0] = swizzleDecoder(swizzle, 0); operand.Swizzles[1] = swizzleDecoder(swizzle, 1); operand.Swizzles[2] = swizzleDecoder(swizzle, 2); operand.Swizzles[3] = swizzleDecoder(swizzle, 3); break; } case Operand4ComponentSelectionMode.Select1: { var swizzle = token0.DecodeValue<Operand4ComponentName>(4, 5); operand.Swizzles[0] = operand.Swizzles[1] = operand.Swizzles[2] = operand.Swizzles[3] = swizzle; break; } default: { throw new ParseException("Unrecognized selection method: " + operand.SelectionMode); } } break; } case OperandNumComponents.N: { throw new ParseException("OperandNumComponents.N is not currently supported."); } } operand.OperandType = token0.DecodeValue<OperandType>(12, 19); operand.IndexDimension = token0.DecodeValue<OperandIndexDimension>(20, 21); operand.IsExtended = token0.DecodeValue(31, 31) == 1; if (operand.IsExtended) ReadExtendedOperand(operand, reader); Func<uint, byte, OperandIndexRepresentation> indexRepresentationDecoder = (t, i) => (OperandIndexRepresentation) t.DecodeValue((byte) (22 + (i * 3)), (byte) (22 + (i * 3) + 2)); for (byte i = 0; i < (byte) operand.IndexDimension; i++) { operand.Indices[i] = new OperandIndex(); var indexRepresentation = indexRepresentationDecoder(token0, i); operand.Indices[i].Representation = indexRepresentation; switch (indexRepresentation) { case OperandIndexRepresentation.Immediate32: operand.Indices[i].Value = reader.ReadUInt32(); break; case OperandIndexRepresentation.Immediate64: operand.Indices[i].Value = reader.ReadUInt64(); goto default; case OperandIndexRepresentation.Relative: operand.Indices[i].Register = Parse(reader, parentType); break; case OperandIndexRepresentation.Immediate32PlusRelative: operand.Indices[i].Value = reader.ReadUInt32(); goto case OperandIndexRepresentation.Relative; case OperandIndexRepresentation.Immediate64PlusRelative: operand.Indices[i].Value = reader.ReadUInt64(); goto case OperandIndexRepresentation.Relative; default: throw new ParseException("Unrecognised index representation: " + indexRepresentation); } } var numberType = parentType.GetNumberType(); switch (operand.OperandType) { case OperandType.Immediate32: { var immediateValues = new Number4(); for (var i = 0; i < operand.NumComponents; i++) immediateValues.SetNumber(i, Number.Parse(reader)); operand.ImmediateValues = immediateValues; break; } case OperandType.Immediate64: { var immediateValues = new Number4(); for (var i = 0; i < operand.NumComponents; i++) immediateValues.SetDouble(i, reader.ReadDouble()); operand.ImmediateValues = immediateValues; break; } } return operand; }
public static bool GetOpCode(string name, out OpcodeType result) { return(_OpcodeByName.TryGetValue(name, out result)); }
//Copied from satoshi's code public static string GetOpName(OpcodeType opcode) { if (!_ValidOpCode[(byte)opcode]) { return("OP_UNKNOWN"); } switch (opcode) { // push value case OpcodeType.OP_0: return("0"); case OpcodeType.OP_PUSHDATA1: return("OP_PUSHDATA1"); case OpcodeType.OP_PUSHDATA2: return("OP_PUSHDATA2"); case OpcodeType.OP_PUSHDATA4: return("OP_PUSHDATA4"); case OpcodeType.OP_1NEGATE: return("-1"); case OpcodeType.OP_RESERVED: return("OP_RESERVED"); case OpcodeType.OP_1: return("1"); case OpcodeType.OP_2: return("2"); case OpcodeType.OP_3: return("3"); case OpcodeType.OP_4: return("4"); case OpcodeType.OP_5: return("5"); case OpcodeType.OP_6: return("6"); case OpcodeType.OP_7: return("7"); case OpcodeType.OP_8: return("8"); case OpcodeType.OP_9: return("9"); case OpcodeType.OP_10: return("OP_10"); case OpcodeType.OP_11: return("OP_11"); case OpcodeType.OP_12: return("OP_12"); case OpcodeType.OP_13: return("OP_13"); case OpcodeType.OP_14: return("OP_14"); case OpcodeType.OP_15: return("OP_15"); case OpcodeType.OP_16: return("OP_16"); // control case OpcodeType.OP_NOP: return("OP_NOP"); case OpcodeType.OP_VER: return("OP_VER"); case OpcodeType.OP_IF: return("OP_IF"); case OpcodeType.OP_NOTIF: return("OP_NOTIF"); case OpcodeType.OP_VERIF: return("OP_VERIF"); case OpcodeType.OP_VERNOTIF: return("OP_VERNOTIF"); case OpcodeType.OP_ELSE: return("OP_ELSE"); case OpcodeType.OP_ENDIF: return("OP_ENDIF"); case OpcodeType.OP_VERIFY: return("OP_VERIFY"); case OpcodeType.OP_RETURN: return("OP_RETURN"); // stack ops case OpcodeType.OP_TOALTSTACK: return("OP_TOALTSTACK"); case OpcodeType.OP_FROMALTSTACK: return("OP_FROMALTSTACK"); case OpcodeType.OP_2DROP: return("OP_2DROP"); case OpcodeType.OP_2DUP: return("OP_2DUP"); case OpcodeType.OP_3DUP: return("OP_3DUP"); case OpcodeType.OP_2OVER: return("OP_2OVER"); case OpcodeType.OP_2ROT: return("OP_2ROT"); case OpcodeType.OP_2SWAP: return("OP_2SWAP"); case OpcodeType.OP_IFDUP: return("OP_IFDUP"); case OpcodeType.OP_DEPTH: return("OP_DEPTH"); case OpcodeType.OP_DROP: return("OP_DROP"); case OpcodeType.OP_DUP: return("OP_DUP"); case OpcodeType.OP_NIP: return("OP_NIP"); case OpcodeType.OP_OVER: return("OP_OVER"); case OpcodeType.OP_PICK: return("OP_PICK"); case OpcodeType.OP_ROLL: return("OP_ROLL"); case OpcodeType.OP_ROT: return("OP_ROT"); case OpcodeType.OP_SWAP: return("OP_SWAP"); case OpcodeType.OP_TUCK: return("OP_TUCK"); // splice ops case OpcodeType.OP_CAT: return("OP_CAT"); case OpcodeType.OP_SUBSTR: return("OP_SUBSTR"); case OpcodeType.OP_LEFT: return("OP_LEFT"); case OpcodeType.OP_RIGHT: return("OP_RIGHT"); case OpcodeType.OP_SIZE: return("OP_SIZE"); // bit logic case OpcodeType.OP_INVERT: return("OP_INVERT"); case OpcodeType.OP_AND: return("OP_AND"); case OpcodeType.OP_OR: return("OP_OR"); case OpcodeType.OP_XOR: return("OP_XOR"); case OpcodeType.OP_EQUAL: return("OP_EQUAL"); case OpcodeType.OP_EQUALVERIFY: return("OP_EQUALVERIFY"); case OpcodeType.OP_RESERVED1: return("OP_RESERVED1"); case OpcodeType.OP_RESERVED2: return("OP_RESERVED2"); // numeric case OpcodeType.OP_1ADD: return("OP_1ADD"); case OpcodeType.OP_1SUB: return("OP_1SUB"); case OpcodeType.OP_2MUL: return("OP_2MUL"); case OpcodeType.OP_2DIV: return("OP_2DIV"); case OpcodeType.OP_NEGATE: return("OP_NEGATE"); case OpcodeType.OP_ABS: return("OP_ABS"); case OpcodeType.OP_NOT: return("OP_NOT"); case OpcodeType.OP_0NOTEQUAL: return("OP_0NOTEQUAL"); case OpcodeType.OP_ADD: return("OP_ADD"); case OpcodeType.OP_SUB: return("OP_SUB"); case OpcodeType.OP_MUL: return("OP_MUL"); case OpcodeType.OP_DIV: return("OP_DIV"); case OpcodeType.OP_MOD: return("OP_MOD"); case OpcodeType.OP_LSHIFT: return("OP_LSHIFT"); case OpcodeType.OP_RSHIFT: return("OP_RSHIFT"); case OpcodeType.OP_BOOLAND: return("OP_BOOLAND"); case OpcodeType.OP_BOOLOR: return("OP_BOOLOR"); case OpcodeType.OP_NUMEQUAL: return("OP_NUMEQUAL"); case OpcodeType.OP_NUMEQUALVERIFY: return("OP_NUMEQUALVERIFY"); case OpcodeType.OP_NUMNOTEQUAL: return("OP_NUMNOTEQUAL"); case OpcodeType.OP_LESSTHAN: return("OP_LESSTHAN"); case OpcodeType.OP_GREATERTHAN: return("OP_GREATERTHAN"); case OpcodeType.OP_LESSTHANOREQUAL: return("OP_LESSTHANOREQUAL"); case OpcodeType.OP_GREATERTHANOREQUAL: return("OP_GREATERTHANOREQUAL"); case OpcodeType.OP_MIN: return("OP_MIN"); case OpcodeType.OP_MAX: return("OP_MAX"); case OpcodeType.OP_WITHIN: return("OP_WITHIN"); // crypto case OpcodeType.OP_RIPEMD160: return("OP_RIPEMD160"); case OpcodeType.OP_SHA1: return("OP_SHA1"); case OpcodeType.OP_SHA256: return("OP_SHA256"); case OpcodeType.OP_HASH160: return("OP_HASH160"); case OpcodeType.OP_HASH256: return("OP_HASH256"); case OpcodeType.OP_CODESEPARATOR: return("OP_CODESEPARATOR"); case OpcodeType.OP_CHECKSIG: return("OP_CHECKSIG"); case OpcodeType.OP_CHECKSIGVERIFY: return("OP_CHECKSIGVERIFY"); case OpcodeType.OP_CHECKMULTISIG: return("OP_CHECKMULTISIG"); case OpcodeType.OP_CHECKMULTISIGVERIFY: return("OP_CHECKMULTISIGVERIFY"); case OpcodeType.OP_CHECKLOCKTIMEVERIFY: return("OP_CLTV"); case OpcodeType.OP_CHECKSEQUENCEVERIFY: return("OP_CSV"); // expanson case OpcodeType.OP_NOP1: return("OP_NOP1"); case OpcodeType.OP_NOP4: return("OP_NOP4"); case OpcodeType.OP_NOP5: return("OP_NOP5"); case OpcodeType.OP_NOP6: return("OP_NOP6"); case OpcodeType.OP_NOP7: return("OP_NOP7"); case OpcodeType.OP_NOP8: return("OP_NOP8"); case OpcodeType.OP_NOP9: return("OP_NOP9"); case OpcodeType.OP_NOP10: return("OP_NOP10"); default: return(Enum.GetName(typeof(OpcodeType), opcode)); } }
private string ParseOptionCode(int offset, int x, string name, ref string code) { // prepare code //int z = code.IndexOf("(", offset) + 1; if (x < offset) { this.opcode = OpcodeType.None; return(string.Empty); } int sOffset = offset - name.Length; this.shortcode = code.Substring(sOffset, x + 1 - sOffset); try { code = code.Substring(++offset, x - offset); } catch { return(string.Empty); } int z = code.LastIndexOf(',') + 1; string msgNum = string.Empty; switch (this.opcode) { case OpcodeType.gsay_option: case OpcodeType.giq_option: // iq param parse if (this.opcode == OpcodeType.giq_option) { x = code.IndexOf(','); this.iq = code.Remove(x).Trim(trimming); code = code.Substring(++x); // удаляем IQ параметр z -= x; } else { this.iq = "-"; } // node param parse code = code.Remove(z - 1); // удаляем Reaction параметр z = code.LastIndexOf(',') + 1; this.toNode = code.Substring(z, code.Length - z).Trim(trimming).TrimStart('@'); code = code.Remove(z - 1); // удаляем Node параметр // msg file number parse z = code.IndexOf(','); string fileNum = code.Remove(z); x = fileNum.IndexOf(',') + 1; if (!int.TryParse(fileNum.Substring(x).Trim(trimming), out this.numberMsgFile)) { this.numberMsgFile = messageSubCode(fileNum); } code = code.Substring(z + 1); // удаляем // msg line number parse msgNum = code; z = msgNum.IndexOf(','); if (z > 0) { msgNum = msgNum.Remove(z); //.Trim(trimming); } break; // for all macros case OpcodeType.Option: // iq/node param parse int result; string str = code.Substring(z).Trim(trimming); if (int.TryParse(str, out result)) { this.iq = result.ToString(); code = code.Remove(z - 1); } else { this.toNode = str.TrimStart('@'); } // node param parse if (this.toNode == null) { int y = code.LastIndexOf(',') + 1; this.toNode = code.Substring(y, --z - y).Trim(trimming).TrimStart('@'); z = y; } msgNum = code = code.Remove(z - 1); // удаляем Node параметр break; } return(msgNum); }
public Script GenerateScriptPubKey(OpcodeType segWitVersion, byte[] data) { if(data == null) throw new ArgumentNullException("data"); if(!ValidSegwitVersion((byte)segWitVersion)) throw new ArgumentException("Segwit version must be from OP_0 to OP_16", "segWitVersion"); return new Script(segWitVersion, Op.GetPushOp(data)); }
public static DeclarationToken Parse(BytecodeReader reader, OpcodeType opcodeType) { switch (opcodeType) { case OpcodeType.DclGlobalFlags: return GlobalFlagsDeclarationToken.Parse(reader); case OpcodeType.DclResource: return ResourceDeclarationToken.Parse(reader); case OpcodeType.DclSampler: return SamplerDeclarationToken.Parse(reader); case OpcodeType.DclInput: case OpcodeType.DclInputSgv: case OpcodeType.DclInputSiv: case OpcodeType.DclInputPs: case OpcodeType.DclInputPsSgv: case OpcodeType.DclInputPsSiv: return InputRegisterDeclarationToken.Parse(reader); case OpcodeType.DclOutput: case OpcodeType.DclOutputSgv: case OpcodeType.DclOutputSiv: return OutputRegisterDeclarationToken.Parse(reader); case OpcodeType.DclIndexRange: return IndexingRangeDeclarationToken.Parse(reader); case OpcodeType.DclTemps: return TempRegisterDeclarationToken.Parse(reader); case OpcodeType.DclIndexableTemp: return IndexableTempRegisterDeclarationToken.Parse(reader); case OpcodeType.DclConstantBuffer: return ConstantBufferDeclarationToken.Parse(reader); case OpcodeType.DclGsInputPrimitive: return GeometryShaderInputPrimitiveDeclarationToken.Parse(reader); case OpcodeType.DclGsOutputPrimitiveTopology: return GeometryShaderOutputPrimitiveTopologyDeclarationToken.Parse(reader); case OpcodeType.DclMaxOutputVertexCount: return GeometryShaderMaxOutputVertexCountDeclarationToken.Parse(reader); case OpcodeType.DclGsInstanceCount: return GeometryShaderInstanceCountDeclarationToken.Parse(reader); case OpcodeType.DclInputControlPointCount: case OpcodeType.DclOutputControlPointCount: return ControlPointCountDeclarationToken.Parse(reader); case OpcodeType.DclTessDomain: return TessellatorDomainDeclarationToken.Parse(reader); case OpcodeType.DclTessPartitioning: return TessellatorPartitioningDeclarationToken.Parse(reader); case OpcodeType.DclTessOutputPrimitive: return TessellatorOutputPrimitiveDeclarationToken.Parse(reader); case OpcodeType.DclHsMaxTessFactor: return HullShaderMaxTessFactorDeclarationToken.Parse(reader); case OpcodeType.DclHsForkPhaseInstanceCount: return HullShaderForkPhaseInstanceCountDeclarationToken.Parse(reader); case OpcodeType.DclFunctionBody : return FunctionBodyDeclarationToken.Parse(reader); case OpcodeType.DclFunctionTable : return FunctionTableDeclarationToken.Parse(reader); case OpcodeType.DclInterface : return InterfaceDeclarationToken.Parse(reader); case OpcodeType.DclThreadGroup: return ThreadGroupDeclarationToken.Parse(reader); case OpcodeType.DclUnorderedAccessViewTyped : return TypedUnorderedAccessViewDeclarationToken.Parse(reader); case OpcodeType.DclUnorderedAccessViewRaw : return RawUnorderedAccessViewDeclarationToken.Parse(reader); case OpcodeType.DclUnorderedAccessViewStructured : return StructuredUnorderedAccessViewDeclarationToken.Parse(reader); case OpcodeType.DclThreadGroupSharedMemoryRaw : return RawThreadGroupSharedMemoryDeclarationToken.Parse(reader); case OpcodeType.DclThreadGroupSharedMemoryStructured : return StructuredThreadGroupSharedMemoryDeclarationToken.Parse(reader); case OpcodeType.DclResourceRaw : return RawShaderResourceViewDeclarationToken.Parse(reader); case OpcodeType.DclResourceStructured: return StructuredShaderResourceViewDeclarationToken.Parse(reader); case OpcodeType.DclStream : return StreamDeclarationToken.Parse(reader); default: throw new ParseException("OpcodeType '" + opcodeType + "' is not supported."); } }
/// <summary> /// /// </summary> /// <param name="fin"></param> /// <param name="opcode"></param> /// <param name="maskingKey">either null which will set MASK bit to 0, or byte array of 4 items which will set MASK to 1</param> /// <param name="payload">unmasked data</param> /// <param name="rsv1"></param> /// <param name="rsv2"></param> /// <param name="rsv3"></param> public WebSocketMessage(bool fin, OpcodeType opcode, byte[] maskingKey, IDataStream payload, bool rsv1 = false, bool rsv2 = false, bool rsv3 = false) { if (MaskingKey != null && MaskingKey.Length != 4) { throw new ArgumentException("MaskingKey.Length != 4"); } if (payload == null) { payload = EmptyData.Instance; } MaskingKey = maskingKey; FIN = fin; RSV1 = rsv1; RSV2 = rsv2; RSV3 = rsv3; Opcode = opcode; MASK = MaskingKey != null; PayloadLength = payload.Length; InnerData = payload; var buffer = new byte[calculateHeaderLength()]; buffer[0] = (byte)((FIN ? 128 : 0) + (RSV1 ? 64 : 0) + (RSV2 ? 32 : 0) + (RSV3 ? 16 : 0) + ((byte)Opcode)); int i = 2; if (PayloadLength > 125) { if (PayloadLength <= UInt16.MaxValue) { buffer[1] = 126; var bytes = BitConverter.GetBytes((UInt16)PayloadLength); if (BitConverter.IsLittleEndian) { byte b0 = bytes[0]; bytes[0] = bytes[1]; bytes[1] = b0; } buffer[2] = bytes[0]; buffer[3] = bytes[1]; i = 4; } else { buffer[1] = 127; var bytes = BitConverter.GetBytes((UInt64)PayloadLength); if (BitConverter.IsLittleEndian) { Array.Reverse(bytes); } Array.Copy(bytes, 0, buffer, 2, 8); i = 10; } } else { buffer[1] = (byte)PayloadLength; } buffer[1] += (byte)(MASK ? 128 : 0); if (MASK) { Array.Copy(MaskingKey, 0, buffer, i, 4); } var header = new ByteArray(buffer); if (MASK) { payload = new MaskedStream(maskingKey, payload); } var res = new StreamList(); res.Add(header); res.Add(payload); if (PayloadLength < 4096) { binaryStream = new ByteArray(res); } else { binaryStream = res; } }
internal static bool IsPushCode(OpcodeType opcode) { return 0 <= opcode && opcode <= OpcodeType.OP_16 && opcode != OpcodeType.OP_RESERVED; }
internal int FindAndDelete(OpcodeType op) { return FindAndDelete(new Op() { Code = op }); }
public static Operand Parse(BytecodeReader reader, OpcodeType parentType) { uint token0 = reader.ReadUInt32(); if (token0 == 0) { return(null); } var operand = new Operand(parentType); var numComponents = token0.DecodeValue <OperandNumComponents>(0, 1); switch (numComponents) { case OperandNumComponents.Zero: { operand.NumComponents = 0; break; } case OperandNumComponents.One: { operand.NumComponents = 1; break; } case OperandNumComponents.Four: { operand.NumComponents = 4; operand.SelectionMode = token0.DecodeValue <Operand4ComponentSelectionMode>(2, 3); switch (operand.SelectionMode) { case Operand4ComponentSelectionMode.Mask: { operand.ComponentMask = token0.DecodeValue <ComponentMask>(4, 7); break; } case Operand4ComponentSelectionMode.Swizzle: { var swizzle = token0.DecodeValue(4, 11); Func <uint, byte, Operand4ComponentName> swizzleDecoder = (s, i) => (Operand4ComponentName)((s >> (i * 2)) & 3); operand.Swizzles[0] = swizzleDecoder(swizzle, 0); operand.Swizzles[1] = swizzleDecoder(swizzle, 1); operand.Swizzles[2] = swizzleDecoder(swizzle, 2); operand.Swizzles[3] = swizzleDecoder(swizzle, 3); break; } case Operand4ComponentSelectionMode.Select1: { var swizzle = token0.DecodeValue <Operand4ComponentName>(4, 5); operand.Swizzles[0] = operand.Swizzles[1] = operand.Swizzles[2] = operand.Swizzles[3] = swizzle; break; } default: { throw new ParseException("Unrecognized selection method: " + operand.SelectionMode); } } break; } case OperandNumComponents.N: { throw new ParseException("OperandNumComponents.N is not currently supported."); } } operand.OperandType = token0.DecodeValue <OperandType>(12, 19); operand.IndexDimension = token0.DecodeValue <OperandIndexDimension>(20, 21); operand.IsExtended = token0.DecodeValue(31, 31) == 1; if (operand.IsExtended) { ReadExtendedOperand(operand, reader); } Func <uint, byte, OperandIndexRepresentation> indexRepresentationDecoder = (t, i) => (OperandIndexRepresentation)t.DecodeValue((byte)(22 + (i * 3)), (byte)(22 + (i * 3) + 2)); for (byte i = 0; i < (byte)operand.IndexDimension; i++) { operand.Indices[i] = new OperandIndex(); var indexRepresentation = indexRepresentationDecoder(token0, i); operand.Indices[i].Representation = indexRepresentation; switch (indexRepresentation) { case OperandIndexRepresentation.Immediate32: operand.Indices[i].Value = reader.ReadUInt32(); break; case OperandIndexRepresentation.Immediate64: operand.Indices[i].Value = reader.ReadUInt64(); goto default; case OperandIndexRepresentation.Relative: operand.Indices[i].Register = Parse(reader, parentType); break; case OperandIndexRepresentation.Immediate32PlusRelative: operand.Indices[i].Value = reader.ReadUInt32(); goto case OperandIndexRepresentation.Relative; case OperandIndexRepresentation.Immediate64PlusRelative: operand.Indices[i].Value = reader.ReadUInt64(); goto case OperandIndexRepresentation.Relative; default: throw new ParseException("Unrecognised index representation: " + indexRepresentation); } } var numberType = parentType.GetNumberType(); switch (operand.OperandType) { case OperandType.Immediate32: { var immediateValues = new Number4(); for (var i = 0; i < operand.NumComponents; i++) { immediateValues.SetNumber(i, Number.Parse(reader)); } operand.ImmediateValues = immediateValues; break; } case OperandType.Immediate64: { var immediateValues = new Number4(); for (var i = 0; i < operand.NumComponents; i++) { immediateValues.SetDouble(i, reader.ReadDouble()); } operand.ImmediateValues = immediateValues; break; } } return(operand); }
// Suggested opcode: OpcodeType.Text public static void Send(FinType fin, OpcodeType opcode, string message) { SendInternal(fin, opcode, Encoding.UTF8.GetBytes(message)); }
//Copied from satoshi's code public static string GetOpName(OpcodeType opcode) { if(!_ValidOpCode[(byte)opcode]) return "OP_UNKNOWN"; switch(opcode) { // push value case OpcodeType.OP_0: return "0"; case OpcodeType.OP_PUSHDATA1: return "OP_PUSHDATA1"; case OpcodeType.OP_PUSHDATA2: return "OP_PUSHDATA2"; case OpcodeType.OP_PUSHDATA4: return "OP_PUSHDATA4"; case OpcodeType.OP_1NEGATE: return "-1"; case OpcodeType.OP_RESERVED: return "OP_RESERVED"; case OpcodeType.OP_1: return "1"; case OpcodeType.OP_2: return "2"; case OpcodeType.OP_3: return "3"; case OpcodeType.OP_4: return "4"; case OpcodeType.OP_5: return "5"; case OpcodeType.OP_6: return "6"; case OpcodeType.OP_7: return "7"; case OpcodeType.OP_8: return "8"; case OpcodeType.OP_9: return "9"; case OpcodeType.OP_10: return "10"; case OpcodeType.OP_11: return "11"; case OpcodeType.OP_12: return "12"; case OpcodeType.OP_13: return "13"; case OpcodeType.OP_14: return "14"; case OpcodeType.OP_15: return "15"; case OpcodeType.OP_16: return "16"; // control case OpcodeType.OP_NOP: return "OP_NOP"; case OpcodeType.OP_VER: return "OP_VER"; case OpcodeType.OP_IF: return "OP_IF"; case OpcodeType.OP_NOTIF: return "OP_NOTIF"; case OpcodeType.OP_VERIF: return "OP_VERIF"; case OpcodeType.OP_VERNOTIF: return "OP_VERNOTIF"; case OpcodeType.OP_ELSE: return "OP_ELSE"; case OpcodeType.OP_ENDIF: return "OP_ENDIF"; case OpcodeType.OP_VERIFY: return "OP_VERIFY"; case OpcodeType.OP_RETURN: return "OP_RETURN"; // stack ops case OpcodeType.OP_TOALTSTACK: return "OP_TOALTSTACK"; case OpcodeType.OP_FROMALTSTACK: return "OP_FROMALTSTACK"; case OpcodeType.OP_2DROP: return "OP_2DROP"; case OpcodeType.OP_2DUP: return "OP_2DUP"; case OpcodeType.OP_3DUP: return "OP_3DUP"; case OpcodeType.OP_2OVER: return "OP_2OVER"; case OpcodeType.OP_2ROT: return "OP_2ROT"; case OpcodeType.OP_2SWAP: return "OP_2SWAP"; case OpcodeType.OP_IFDUP: return "OP_IFDUP"; case OpcodeType.OP_DEPTH: return "OP_DEPTH"; case OpcodeType.OP_DROP: return "OP_DROP"; case OpcodeType.OP_DUP: return "OP_DUP"; case OpcodeType.OP_NIP: return "OP_NIP"; case OpcodeType.OP_OVER: return "OP_OVER"; case OpcodeType.OP_PICK: return "OP_PICK"; case OpcodeType.OP_ROLL: return "OP_ROLL"; case OpcodeType.OP_ROT: return "OP_ROT"; case OpcodeType.OP_SWAP: return "OP_SWAP"; case OpcodeType.OP_TUCK: return "OP_TUCK"; // splice ops case OpcodeType.OP_CAT: return "OP_CAT"; case OpcodeType.OP_SUBSTR: return "OP_SUBSTR"; case OpcodeType.OP_LEFT: return "OP_LEFT"; case OpcodeType.OP_RIGHT: return "OP_RIGHT"; case OpcodeType.OP_SIZE: return "OP_SIZE"; // bit logic case OpcodeType.OP_INVERT: return "OP_INVERT"; case OpcodeType.OP_AND: return "OP_AND"; case OpcodeType.OP_OR: return "OP_OR"; case OpcodeType.OP_XOR: return "OP_XOR"; case OpcodeType.OP_EQUAL: return "OP_EQUAL"; case OpcodeType.OP_EQUALVERIFY: return "OP_EQUALVERIFY"; case OpcodeType.OP_RESERVED1: return "OP_RESERVED1"; case OpcodeType.OP_RESERVED2: return "OP_RESERVED2"; // numeric case OpcodeType.OP_1ADD: return "OP_1ADD"; case OpcodeType.OP_1SUB: return "OP_1SUB"; case OpcodeType.OP_2MUL: return "OP_2MUL"; case OpcodeType.OP_2DIV: return "OP_2DIV"; case OpcodeType.OP_NEGATE: return "OP_NEGATE"; case OpcodeType.OP_ABS: return "OP_ABS"; case OpcodeType.OP_NOT: return "OP_NOT"; case OpcodeType.OP_0NOTEQUAL: return "OP_0NOTEQUAL"; case OpcodeType.OP_ADD: return "OP_ADD"; case OpcodeType.OP_SUB: return "OP_SUB"; case OpcodeType.OP_MUL: return "OP_MUL"; case OpcodeType.OP_DIV: return "OP_DIV"; case OpcodeType.OP_MOD: return "OP_MOD"; case OpcodeType.OP_LSHIFT: return "OP_LSHIFT"; case OpcodeType.OP_RSHIFT: return "OP_RSHIFT"; case OpcodeType.OP_BOOLAND: return "OP_BOOLAND"; case OpcodeType.OP_BOOLOR: return "OP_BOOLOR"; case OpcodeType.OP_NUMEQUAL: return "OP_NUMEQUAL"; case OpcodeType.OP_NUMEQUALVERIFY: return "OP_NUMEQUALVERIFY"; case OpcodeType.OP_NUMNOTEQUAL: return "OP_NUMNOTEQUAL"; case OpcodeType.OP_LESSTHAN: return "OP_LESSTHAN"; case OpcodeType.OP_GREATERTHAN: return "OP_GREATERTHAN"; case OpcodeType.OP_LESSTHANOREQUAL: return "OP_LESSTHANOREQUAL"; case OpcodeType.OP_GREATERTHANOREQUAL: return "OP_GREATERTHANOREQUAL"; case OpcodeType.OP_MIN: return "OP_MIN"; case OpcodeType.OP_MAX: return "OP_MAX"; case OpcodeType.OP_WITHIN: return "OP_WITHIN"; // crypto case OpcodeType.OP_RIPEMD160: return "OP_RIPEMD160"; case OpcodeType.OP_SHA1: return "OP_SHA1"; case OpcodeType.OP_SHA256: return "OP_SHA256"; case OpcodeType.OP_HASH160: return "OP_HASH160"; case OpcodeType.OP_HASH256: return "OP_HASH256"; case OpcodeType.OP_CODESEPARATOR: return "OP_CODESEPARATOR"; case OpcodeType.OP_CHECKSIG: return "OP_CHECKSIG"; case OpcodeType.OP_CHECKSIGVERIFY: return "OP_CHECKSIGVERIFY"; case OpcodeType.OP_CHECKMULTISIG: return "OP_CHECKMULTISIG"; case OpcodeType.OP_CHECKMULTISIGVERIFY: return "OP_CHECKMULTISIGVERIFY"; case OpcodeType.OP_CHECKLOCKTIMEVERIFY: return "OP_CHECKLOCKTIMEVERIFY"; // expanson case OpcodeType.OP_NOP1: return "OP_NOP1"; case OpcodeType.OP_NOP3: return "OP_NOP3"; case OpcodeType.OP_NOP4: return "OP_NOP4"; case OpcodeType.OP_NOP5: return "OP_NOP5"; case OpcodeType.OP_NOP6: return "OP_NOP6"; case OpcodeType.OP_NOP7: return "OP_NOP7"; case OpcodeType.OP_NOP8: return "OP_NOP8"; case OpcodeType.OP_NOP9: return "OP_NOP9"; case OpcodeType.OP_NOP10: return "OP_NOP10"; default: return Enum.GetName(typeof(OpcodeType), opcode); } }
public static DeclarationToken Parse(BytecodeReader reader, OpcodeType opcodeType) { switch (opcodeType) { case OpcodeType.DclGlobalFlags: return(GlobalFlagsDeclarationToken.Parse(reader)); case OpcodeType.DclResource: return(ResourceDeclarationToken.Parse(reader)); case OpcodeType.DclSampler: return(SamplerDeclarationToken.Parse(reader)); case OpcodeType.DclInput: case OpcodeType.DclInputSgv: case OpcodeType.DclInputSiv: case OpcodeType.DclInputPs: case OpcodeType.DclInputPsSgv: case OpcodeType.DclInputPsSiv: return(InputRegisterDeclarationToken.Parse(reader)); case OpcodeType.DclOutput: case OpcodeType.DclOutputSgv: case OpcodeType.DclOutputSiv: return(OutputRegisterDeclarationToken.Parse(reader)); case OpcodeType.DclIndexRange: return(IndexingRangeDeclarationToken.Parse(reader)); case OpcodeType.DclTemps: return(TempRegisterDeclarationToken.Parse(reader)); case OpcodeType.DclIndexableTemp: return(IndexableTempRegisterDeclarationToken.Parse(reader)); case OpcodeType.DclConstantBuffer: return(ConstantBufferDeclarationToken.Parse(reader)); case OpcodeType.DclGsInputPrimitive: return(GeometryShaderInputPrimitiveDeclarationToken.Parse(reader)); case OpcodeType.DclGsOutputPrimitiveTopology: return(GeometryShaderOutputPrimitiveTopologyDeclarationToken.Parse(reader)); case OpcodeType.DclMaxOutputVertexCount: return(GeometryShaderMaxOutputVertexCountDeclarationToken.Parse(reader)); case OpcodeType.DclGsInstanceCount: return(GeometryShaderInstanceCountDeclarationToken.Parse(reader)); case OpcodeType.DclInputControlPointCount: case OpcodeType.DclOutputControlPointCount: return(ControlPointCountDeclarationToken.Parse(reader)); case OpcodeType.DclTessDomain: return(TessellatorDomainDeclarationToken.Parse(reader)); case OpcodeType.DclTessPartitioning: return(TessellatorPartitioningDeclarationToken.Parse(reader)); case OpcodeType.DclTessOutputPrimitive: return(TessellatorOutputPrimitiveDeclarationToken.Parse(reader)); case OpcodeType.DclHsMaxTessFactor: return(HullShaderMaxTessFactorDeclarationToken.Parse(reader)); case OpcodeType.DclHsForkPhaseInstanceCount: return(HullShaderForkPhaseInstanceCountDeclarationToken.Parse(reader)); case OpcodeType.DclFunctionBody: return(FunctionBodyDeclarationToken.Parse(reader)); case OpcodeType.DclFunctionTable: return(FunctionTableDeclarationToken.Parse(reader)); case OpcodeType.DclInterface: return(InterfaceDeclarationToken.Parse(reader)); case OpcodeType.DclThreadGroup: return(ThreadGroupDeclarationToken.Parse(reader)); case OpcodeType.DclUnorderedAccessViewTyped: return(TypedUnorderedAccessViewDeclarationToken.Parse(reader)); case OpcodeType.DclUnorderedAccessViewRaw: return(RawUnorderedAccessViewDeclarationToken.Parse(reader)); case OpcodeType.DclUnorderedAccessViewStructured: return(StructuredUnorderedAccessViewDeclarationToken.Parse(reader)); case OpcodeType.DclThreadGroupSharedMemoryRaw: return(RawThreadGroupSharedMemoryDeclarationToken.Parse(reader)); case OpcodeType.DclThreadGroupSharedMemoryStructured: return(StructuredThreadGroupSharedMemoryDeclarationToken.Parse(reader)); case OpcodeType.DclResourceRaw: return(RawShaderResourceViewDeclarationToken.Parse(reader)); case OpcodeType.DclResourceStructured: return(StructuredShaderResourceViewDeclarationToken.Parse(reader)); case OpcodeType.DclStream: return(StreamDeclarationToken.Parse(reader)); default: throw new ParseException("OpcodeType '" + opcodeType + "' is not supported."); } }
public static bool GetOpCode(string name, out OpcodeType result) { return _OpcodeByName.TryGetValue(name, out result); }
private static InstructionToken CreateInstruction(OpcodeType opcodeType) { return new InstructionToken { Header = { OpcodeType = opcodeType } }; }
public static bool IsPushCode(OpcodeType opcode) { return(0 <= opcode && opcode <= OpcodeType.OP_16 && opcode != OpcodeType.OP_RESERVED); }
private static InstructionToken CreateInstruction(OpcodeType opcodeType) { return(new InstructionToken { Header = { OpcodeType = opcodeType } }); }
private static ExecutableOpcodeType MapOpcodeType(OpcodeType opcodeType) { return((ExecutableOpcodeType)Enum.Parse(typeof(ExecutableOpcodeType), opcodeType.ToString())); }
public static bool IsSwapHash(OpcodeType opcodeType) { return(opcodeType == OpcodeType.OP_HASH160 || opcodeType == OpcodeType.OP_HASH256 || opcodeType == OpcodeType.OP_SHA256); }