Today I found a “final bug” in my LSL ByteCode parser, and was able to get read seemingly clean ByteCode. I also made a quick hack of merging the CLR RunTime code generator with the LSL ByteCode parser, and compiled my first small function.
It works! 🙂
Also writing the compiled script to a .dll-file. Necessary as the only way I know of to debug CLR is through the loveable PEVerifier.EXE.
Of course most work remains. States are not supported, dynamic function names not supported, only one OPCODE (PUSHS – push string to stack) and only one BUILTIN command (llSay mapped to Debug.WriteLine) is supported.
Not to mention user space multitasking and moving a running script between regions.
Notice the last two lines of this log…
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
Debug: Opening filename: LSO\CloseToDefault.lso Debug: Reading HEADER BLOCK at: 0 Debug: TM - Top of memory (size): 16384 Debug: IP - Instruction Pointer (0=not running): 0 Debug: VN - Version number: 512 Debug: BP - Local Frame Pointer: 16383 Debug: SP - Stack Pointer: 16383 Debug: HR - Heap Register: 233 Debug: HP - Heap Pointer: 240 Debug: CS - Current State: 0 Debug: NS - Next State: 0 Debug: CE - Current Events: 0 Debug: IE - In Event: 0 Debug: ER - Event Register: 0 Debug: FR - Fault Register: 0 Debug: SLR - Sleep Register: 0 Debug: GVR - Global Variable Register: 100 Debug: GFR - Global Function Register: 100 Debug: PR - Parameter Register: 0 Debug: ESR - Energy Supply Register: 0 Debug: SR - State Register: 100 Debug: NCE - 64-bit Current Events: 1 Debug: NIE - 64-bit In Events: 0 Debug: NER - 64-bit Event Register: 5 Debug: Read position when exiting HEADER BLOCK: 100 Debug: Reading STATIC BLOCK at: 100 Debug: Number of Static Blocks read: 0 Debug: No FUNCTION BLOCK found Debug: Reading STATE BLOCK at: 100 Debug: Reading STATE POINTER BLOCK 1 at: 104 Debug: Pointer: 116 Debug: Total potential EventMask bits: 64 Debug: Reading STATE BLOCK 1 at: 116 Debug: State block Start Pos: 116 Debug: State block Header Size: 5 Debug: State block Header End Pos: 121 Debug: Reading STATE BLOCK 1 HANDLER matching EVENT MASK 0 (state_entry) at: 121 Debug: Reading STATE BLOCK 1 HANDLER EVENT MASK 0 (state_entry) Code Chunk Pointer: 137 Debug: Reading STATE BLOCK 1 HANDLER EVENT MASK 0 (state_entry) Call Frame Size: 0 Debug: Reading STATE BLOCK 1 HANDLER matching EVENT MASK 2 (touch_start) at: 129 Debug: Reading STATE BLOCK 1 HANDLER EVENT MASK 2 (touch_start) Code Chunk Pointer: 181 Debug: Reading STATE BLOCK 1 HANDLER EVENT MASK 2 (touch_start) Call Frame Size: 4 Debug: Reading Event Code Chunk state 0, event state_entry Debug: CLR:event_state_entry:MethodBuilder methodBuilder = typeBuilder.DefineMethod... Debug: CLR:event_state_entry:typeBuilder.DefineMethodOverride(methodBuilder... Debug: CLR:event_state_entry:ILGenerator il = methodBuilder.GetILGenerator(); Debug: Reading Function Code Chunk at: 137 Debug: CodeChunk Header Size: 5 Debug: Function comment: Debug: Return type: 99 Debug: Reading Code Chunk Argument 1 Debug: Code Chunk Argument 1 return type: 94 Debug: OPCODE: NOOP Debug: OPCODE: NOOP Debug: OPCODE: NOOP Debug: OPCODE: PUSHARGS Debug: Param1: Hello, Tedd! Debug: OPCODE: PUSHARGE Debug: Param1: 0 Debug: OPCODE: PUSHSP Debug: OPCODE: PUSHARGI Debug: Param1: 8 Debug: OPCODE: ADD Debug: Param1: 17 Debug: OPCODE: POPBP Debug: OPCODE: CALLLIB_TWO_BYTE Debug: Param1: 23 Debug: OPCODE: RETURN Debug: Last OPCODE was return command. Code chunk execution complete. Debug: CLR:event_state_entry:il.BeginCatchBlock(typeof(Exception)); Debug: CLR:event_state_entry:il.Emit(OpCodes.Ldstr... Debug: CLR:event_state_entry:il.Emit(OpCodes.Call... Debug: CLR:event_state_entry:il.Emit(OpCodes.Callvirt... Debug: CLR:event_state_entry:il.Emit(OpCodes.Call... Debug: Reading Event Code Chunk state 0, event touch_start Debug: CLR:event_touch_start:MethodBuilder methodBuilder = typeBuilder.DefineMethod... Debug: CLR:event_touch_start:typeBuilder.DefineMethodOverride(methodBuilder... Debug: CLR:event_touch_start:ILGenerator il = methodBuilder.GetILGenerator(); Debug: Reading Function Code Chunk at: 181 Debug: CodeChunk Header Size: 5 Debug: Function comment: Debug: Return type: 99 Debug: Reading Code Chunk Argument 1 Debug: Code Chunk Argument 1 return type: 94 Debug: OPCODE: NOOP Debug: OPCODE: NOOP Debug: OPCODE: NOOP Debug: OPCODE: PUSHARGS Debug: Param1: Object was touched. Debug: OPCODE: PUSHARGE Debug: Param1: 0 Debug: OPCODE: PUSHSP Debug: OPCODE: PUSHARGI Debug: Param1: 8 Debug: OPCODE: ADD Debug: Param1: 17 Debug: OPCODE: POPBP Debug: OPCODE: CALLLIB_TWO_BYTE Debug: Param1: 23 Debug: OPCODE: POP Debug: OPCODE: RETURN Debug: Last OPCODE was return command. Code chunk execution complete. Debug: CLR:event_touch_start:il.BeginCatchBlock(typeof(Exception)); Debug: CLR:event_touch_start:il.Emit(OpCodes.Ldstr... Debug: CLR:event_touch_start:il.Emit(OpCodes.Call... Debug: CLR:event_touch_start:il.Emit(OpCodes.Callvirt... Debug: CLR:event_touch_start:il.Emit(OpCodes.Call... Starting CLR dynamic execution of: event_state_entry Hello, Tedd! |