private BytecodeToken ReadNativeCall(byte b) { int pos = (int)_reader.BaseStream.Position - 1; int nativeIndex; if ((b & 0xF0) == 0x60) { byte b2 = _reader.ReadByte(); nativeIndex = ((b - 0x60) << 8) + b2; } else { nativeIndex = b; } var function = CachedNativeFunctionInfo.GetNativeFunction(nativeIndex); //have to figure out how to do this, it's looking up name of native function if (function == null) { return(ErrToken("// invalid native function " + nativeIndex)); } if (function.PreOperator || function.PostOperator) { var p = ReadNext(); if (IsInvalid(p)) { return(p); } ReadNext(); // end of parms if (function.PreOperator) { return(Token((function.HumanReadableControlToken ?? function.Name) + p, pos, nativeIndex)); } return(Token(p + (function.HumanReadableControlToken ?? function.Name), pos, nativeIndex)); } if (function.Operator) { var p1 = ReadNext(); if (IsInvalid(p1)) { return(WrapErrToken(function.Name + "(" + p1, p1)); } var p2 = ReadNext(); if (IsInvalid(p2)) { return(WrapErrToken(p1 + " " + function.Name + " " + p2, p2)); } ReadNext(); // end of parms return(Token(p1 + " " + (function.HumanReadableControlToken ?? function.Name) + " " + p2, pos, nativeIndex)); } return(ReadCall(function.Name)); }
public BytecodeSingularToken ToBytecodeSingularToken(int scriptStartOffset) { BytecodeSingularToken bcst = new BytecodeSingularToken(); string opcodetext = OpCode.ToString(); if (NativeIndex > 0) { var function = CachedNativeFunctionInfo.GetNativeFunction(NativeIndex); //this could be done dynamically. But if you're able to add native functions to the exe you probably know more about the engine than me if (function != null) { opcodetext = function.Name; } } opcodetext = $"[{((byte)OpCode):X2}] {opcodetext}"; bcst.CurrentStack = _text; bcst.OpCode = opcodetext; bcst.StartPos = _offset + scriptStartOffset; return(bcst); }