00001
00032 #include "linden_common.h"
00033
00034 #include "lscript_readlso.h"
00035 #include "lscript_library.h"
00036 #include "lscript_alloc.h"
00037
00038 LLScriptLSOParse::LLScriptLSOParse(FILE *fp)
00039 {
00040 U8 sizearray[4];
00041 S32 filesize;
00042 S32 pos = 0;
00043 if (fread(&sizearray, 1, 4, fp) != 4)
00044 {
00045 llwarns << "Short read" << llendl;
00046 filesize = 0;
00047 } else {
00048 filesize = bytestream2integer(sizearray, pos);
00049 }
00050 mRawData = new U8[filesize];
00051 fseek(fp, 0, SEEK_SET);
00052 if (fread(mRawData, 1, filesize, fp) != filesize)
00053 {
00054 llwarns << "Short read" << llendl;
00055 }
00056
00057 initOpCodePrinting();
00058 }
00059
00060 LLScriptLSOParse::LLScriptLSOParse(U8 *buffer)
00061 {
00062 mRawData = buffer;
00063 initOpCodePrinting();
00064 }
00065
00066 LLScriptLSOParse::~LLScriptLSOParse()
00067 {
00068 delete [] mRawData;
00069 }
00070
00071 void LLScriptLSOParse::printData(FILE *fp)
00072 {
00073
00074
00075
00076 printNameDesc(fp);
00077
00078 printRegisters(fp);
00079
00080 printGlobals(fp);
00081
00082 printGlobalFunctions(fp);
00083
00084 printStates(fp);
00085
00086 printHeap(fp);
00087 }
00088
00089 void LLScriptLSOParse::printNameDesc(FILE *fp)
00090 {
00091 fprintf(fp, "=============================\n\n");
00092 }
00093
00094 S32 gMajorVersion = 0;
00095
00096 void LLScriptLSOParse::printRegisters(FILE *fp)
00097 {
00098
00099 S32 i;
00100
00101 fprintf(fp, "=============================\n");
00102 fprintf(fp, "Registers\n");
00103 fprintf(fp, "=============================\n");
00104 S32 version = get_register(mRawData, LREG_VN);
00105 if (version == LSL2_VERSION1_END_NUMBER)
00106 {
00107 gMajorVersion = LSL2_MAJOR_VERSION_ONE;
00108 }
00109 else if (version == LSL2_VERSION_NUMBER)
00110 {
00111 gMajorVersion = LSL2_MAJOR_VERSION_TWO;
00112 }
00113 for (i = LREG_IP; i < LREG_EOF; i++)
00114 {
00115 if (i < LREG_NCE)
00116 {
00117 fprintf(fp, "%s: 0x%X\n", gLSCRIPTRegisterNames[i], get_register(mRawData, (LSCRIPTRegisters)i));
00118 }
00119 else if (gMajorVersion == LSL2_MAJOR_VERSION_TWO)
00120 {
00121 U64 data = get_register_u64(mRawData, (LSCRIPTRegisters)i);
00122 fprintf(fp, "%s: 0x%X%X\n", gLSCRIPTRegisterNames[i], (U32)(data>>32), (U32)(data && 0xFFFFFFFF));
00123 }
00124 }
00125 fprintf(fp, "=============================\n\n");
00126 }
00127
00128 void LLScriptLSOParse::printGlobals(FILE *fp)
00129 {
00130
00131 S32 offset, varoffset;
00132 S32 ivalue;
00133 F32 fpvalue;
00134 LLVector3 vvalue;
00135 LLQuaternion qvalue;
00136 char name[256];
00137 U8 type;
00138
00139 S32 global_v_offset = get_register(mRawData, LREG_GVR);
00140 S32 global_f_offset = get_register(mRawData, LREG_GFR);
00141
00142 fprintf(fp, "=============================\n");
00143 fprintf(fp, "[0x%X] Global Variables\n", global_v_offset);
00144 fprintf(fp, "=============================\n");
00145
00146
00147 while (global_v_offset < global_f_offset)
00148 {
00149
00150
00151 varoffset = global_v_offset;
00152 offset = bytestream2integer(mRawData, global_v_offset);
00153
00154
00155 type = *(mRawData + global_v_offset++);
00156
00157
00158 bytestream2char(name, mRawData, global_v_offset);
00159
00160 switch(type)
00161 {
00162 case LST_INTEGER:
00163 ivalue = bytestream2integer(mRawData, global_v_offset);
00164 fprintf(fp, "[0x%X] integer %s = %d\n", varoffset, name, ivalue);
00165 break;
00166 case LST_FLOATINGPOINT:
00167 fpvalue = bytestream2float(mRawData, global_v_offset);
00168 fprintf(fp, "[0x%X] integer %s = %f\n", varoffset, name, fpvalue);
00169 break;
00170 case LST_STRING:
00171 ivalue = bytestream2integer(mRawData, global_v_offset);
00172 fprintf(fp, "[0x%X] string %s = 0x%X\n", varoffset, name, ivalue + get_register(mRawData, LREG_HR) - 1);
00173 break;
00174 case LST_KEY:
00175 ivalue = bytestream2integer(mRawData, global_v_offset);
00176 fprintf(fp, "[0x%X] key %s = 0x%X\n", varoffset, name, ivalue + get_register(mRawData, LREG_HR) - 1);
00177 break;
00178 case LST_VECTOR:
00179 bytestream2vector(vvalue, mRawData, global_v_offset);
00180 fprintf(fp, "[0x%X] vector %s = < %f, %f, %f >\n", varoffset, name, vvalue.mV[VX], vvalue.mV[VY], vvalue.mV[VZ]);
00181 break;
00182 case LST_QUATERNION:
00183 bytestream2quaternion(qvalue, mRawData, global_v_offset);
00184 fprintf(fp, "[0x%X] quaternion %s = < %f, %f, %f, %f >\n", varoffset, name, qvalue.mQ[VX], qvalue.mQ[VY], qvalue.mQ[VZ], qvalue.mQ[VS]);
00185 break;
00186 case LST_LIST:
00187 ivalue = bytestream2integer(mRawData, global_v_offset);
00188 fprintf(fp, "[0x%X] list %s = 0x%X\n", varoffset, name, ivalue + get_register(mRawData, LREG_HR) - 1);
00189 break;
00190 default:
00191 break;
00192 }
00193 }
00194
00195 fprintf(fp, "=============================\n\n");
00196 }
00197
00198 void LLScriptLSOParse::printGlobalFunctions(FILE *fp)
00199 {
00200
00201 S32 i, offset;
00202
00203
00204 char name[256];
00205 U8 type;
00206
00207 offset = get_register(mRawData, LREG_GFR);
00208 S32 start_of_state = get_register(mRawData, LREG_SR);
00209 if (start_of_state == offset)
00210 return;
00211
00212 S32 global_f_offset = get_register(mRawData, LREG_GFR);
00213
00214 fprintf(fp, "=============================\n");
00215 fprintf(fp, "[0x%X] Global Functions\n", global_f_offset);
00216 fprintf(fp, "=============================\n");
00217
00218
00219 S32 num_functions = bytestream2integer(mRawData, offset);
00220 S32 orig_function_offset;
00221 S32 function_offset;
00222 S32 next_function_offset = 0;
00223 S32 function_number = 0;
00224 S32 opcode_start;
00225 S32 opcode_end;
00226
00227 for (i = 0; i < num_functions; i++)
00228 {
00229
00230
00231 if (i == 0)
00232 {
00233 if (i < num_functions - 1)
00234 {
00235 function_offset = bytestream2integer(mRawData, offset);
00236 next_function_offset = bytestream2integer(mRawData, offset);
00237 function_offset += global_f_offset;
00238 opcode_end = next_function_offset + global_f_offset;
00239 }
00240 else
00241 {
00242 function_offset = bytestream2integer(mRawData, offset);
00243 function_offset += global_f_offset;
00244 opcode_end = get_register(mRawData, LREG_SR);
00245 }
00246 }
00247 else if (i < num_functions - 1)
00248 {
00249 function_offset = next_function_offset;
00250 next_function_offset = bytestream2integer(mRawData, offset);
00251 function_offset += global_f_offset;
00252 opcode_end = next_function_offset + global_f_offset;
00253 }
00254 else
00255 {
00256 function_offset = next_function_offset;
00257 function_offset += global_f_offset;
00258 opcode_end = get_register(mRawData, LREG_SR);
00259 }
00260 orig_function_offset = function_offset;
00261
00262 opcode_start = bytestream2integer(mRawData, function_offset);
00263 opcode_start += orig_function_offset;
00264 bytestream2char(name, mRawData, function_offset);
00265
00266 type = *(mRawData + function_offset++);
00267 fprintf(fp, "[Function #%d] [0x%X] %s\n", function_number, orig_function_offset, name);
00268 fprintf(fp, "\tReturn Type: %s\n", LSCRIPTTypeNames[type]);
00269 type = *(mRawData + function_offset++);
00270 S32 params;
00271 params = 0;
00272 S32 pcount = 0;
00273 while (type)
00274 {
00275 bytestream2char(name, mRawData, function_offset);
00276 fprintf(fp, "\tParameter #%d: %s %s\n", pcount++, LSCRIPTTypeNames[type], name);
00277 type = *(mRawData + function_offset++);
00278 }
00279 fprintf(fp, "\t\tOpCodes: 0x%X - 0x%X\n", opcode_start, opcode_end);
00280 printOpCodeRange(fp, opcode_start, opcode_end, 2);
00281 function_number++;
00282 }
00283
00284 fprintf(fp, "=============================\n\n");
00285 }
00286
00287 void LLScriptLSOParse::printStates(FILE *fp)
00288 {
00289
00290 S32 i, offset;
00291 U32 j, k;
00292
00293
00294 char name[256];
00295
00296 S32 state_offset = get_register(mRawData, LREG_SR);
00297
00298 fprintf(fp, "=============================\n");
00299 fprintf(fp, "[0x%X] States\n", state_offset);
00300 fprintf(fp, "=============================\n");
00301
00302 offset = state_offset;
00303 S32 num_states = bytestream2integer(mRawData, offset);
00304 S32 state_info_offset;
00305 S32 event_jump_table;
00306 U64 event_handlers;
00307 S32 event_offset;
00308 S32 original_event_offset;
00309 S32 opcode_start;
00310 S32 worst_case_opcode_end;
00311 S32 opcode_end;
00312 S32 stack_size;
00313 S32 read_ahead;
00314 S32 first_jump = 0;
00315
00316 for (i = 0; i < num_states; i++)
00317 {
00318 state_info_offset = bytestream2integer(mRawData, offset);
00319 if (gMajorVersion == LSL2_MAJOR_VERSION_TWO)
00320 event_handlers = bytestream2u64(mRawData, offset);
00321 else
00322 event_handlers = bytestream2integer(mRawData, offset);
00323 if (!first_jump)
00324 {
00325 first_jump = state_info_offset;
00326 }
00327 read_ahead = offset;
00328 if (offset < first_jump + state_offset)
00329 {
00330 worst_case_opcode_end = bytestream2integer(mRawData, read_ahead) + state_offset;
00331 }
00332 else
00333 {
00334 worst_case_opcode_end = get_register(mRawData, LREG_HR);
00335 }
00336 state_info_offset += state_offset;
00337 fprintf(fp, "[0x%X] ", state_info_offset);
00338 state_info_offset += LSCRIPTDataSize[LST_INTEGER];
00339 bytestream2char(name, mRawData, state_info_offset);
00340 fprintf(fp, "%s\n", name);
00341
00342 event_jump_table = state_info_offset;
00343
00344
00345 for (j = LSTT_STATE_BEGIN; j < LSTT_STATE_END; j++)
00346 {
00347 if (event_handlers & LSCRIPTStateBitField[j])
00348 {
00349 event_offset = bytestream2integer(mRawData, state_info_offset);
00350 stack_size = bytestream2integer(mRawData, state_info_offset);
00351
00352 read_ahead = event_jump_table;
00353
00354 S32 temp_end;
00355 S32 dummy;
00356
00357 opcode_end = worst_case_opcode_end;
00358
00359 for (k = LSTT_STATE_BEGIN; k < LSTT_STATE_END; k++)
00360 {
00361 if (event_handlers & LSCRIPTStateBitField[k])
00362 {
00363 temp_end = bytestream2integer(mRawData, read_ahead);
00364 dummy = bytestream2integer(mRawData, read_ahead);
00365 if ( (temp_end < opcode_end)
00366 &&(temp_end > event_offset))
00367 {
00368 opcode_end = temp_end;
00369 }
00370 }
00371 }
00372
00373 if (event_offset)
00374 {
00375 event_offset += event_jump_table;
00376 if (opcode_end < worst_case_opcode_end)
00377 opcode_end += event_jump_table;
00378 original_event_offset = event_offset;
00379
00380 fprintf(fp, "\t[0x%X] ", event_offset);
00381
00382 opcode_start = bytestream2integer(mRawData, event_offset);
00383 opcode_start += original_event_offset;
00384
00385 switch(j)
00386 {
00387 case LSTT_STATE_ENTRY:
00388 bytestream2char(name, mRawData, event_offset);
00389 fprintf(fp, "%s\n", name);
00390 break;
00391 case LSTT_STATE_EXIT:
00392 bytestream2char(name, mRawData, event_offset);
00393 fprintf(fp, "%s\n", name);
00394 break;
00395 case LSTT_TOUCH_START:
00396 bytestream2char(name, mRawData, event_offset);
00397 fprintf(fp, "%s\n", name);
00398 bytestream2char(name, mRawData, event_offset);
00399 fprintf(fp, "\t\tkey %s\n", name);
00400 bytestream2char(name, mRawData, event_offset);
00401 fprintf(fp, "\t\tvector %s\n", name);
00402 break;
00403 case LSTT_TOUCH:
00404 bytestream2char(name, mRawData, event_offset);
00405 fprintf(fp, "%s\n", name);
00406 bytestream2char(name, mRawData, event_offset);
00407 fprintf(fp, "\t\tkey %s\n", name);
00408 bytestream2char(name, mRawData, event_offset);
00409 fprintf(fp, "\t\tvector %s\n", name);
00410 break;
00411 case LSTT_TOUCH_END:
00412 bytestream2char(name, mRawData, event_offset);
00413 fprintf(fp, "%s\n", name);
00414 bytestream2char(name, mRawData, event_offset);
00415 fprintf(fp, "\t\tkey %s\n", name);
00416 bytestream2char(name, mRawData, event_offset);
00417 fprintf(fp, "\t\tvector %s\n", name);
00418 break;
00419 case LSTT_COLLISION_START:
00420 bytestream2char(name, mRawData, event_offset);
00421 fprintf(fp, "%s\n", name);
00422 bytestream2char(name, mRawData, event_offset);
00423 fprintf(fp, "\t\tkey %s\n", name);
00424 bytestream2char(name, mRawData, event_offset);
00425 fprintf(fp, "\t\tvector %s\n", name);
00426 bytestream2char(name, mRawData, event_offset);
00427 fprintf(fp, "\t\tvector %s\n", name);
00428 break;
00429 case LSTT_COLLISION:
00430 bytestream2char(name, mRawData, event_offset);
00431 fprintf(fp, "%s\n", name);
00432 bytestream2char(name, mRawData, event_offset);
00433 fprintf(fp, "\t\tkey %s\n", name);
00434 bytestream2char(name, mRawData, event_offset);
00435 fprintf(fp, "\t\tvector %s\n", name);
00436 bytestream2char(name, mRawData, event_offset);
00437 fprintf(fp, "\t\tvector %s\n", name);
00438 break;
00439 case LSTT_COLLISION_END:
00440 bytestream2char(name, mRawData, event_offset);
00441 fprintf(fp, "%s\n", name);
00442 bytestream2char(name, mRawData, event_offset);
00443 fprintf(fp, "\t\tkey %s\n", name);
00444 bytestream2char(name, mRawData, event_offset);
00445 fprintf(fp, "\t\tvector %s\n", name);
00446 bytestream2char(name, mRawData, event_offset);
00447 fprintf(fp, "\t\tvector %s\n", name);
00448 break;
00449 case LSTT_LAND_COLLISION_START:
00450 bytestream2char(name, mRawData, event_offset);
00451 fprintf(fp, "%s\n", name);
00452 bytestream2char(name, mRawData, event_offset);
00453 fprintf(fp, "\t\tvector %s\n", name);
00454 break;
00455 case LSTT_LAND_COLLISION:
00456 bytestream2char(name, mRawData, event_offset);
00457 fprintf(fp, "%s\n", name);
00458 bytestream2char(name, mRawData, event_offset);
00459 fprintf(fp, "\t\tvector %s\n", name);
00460 break;
00461 case LSTT_LAND_COLLISION_END:
00462 bytestream2char(name, mRawData, event_offset);
00463 fprintf(fp, "%s\n", name);
00464 bytestream2char(name, mRawData, event_offset);
00465 fprintf(fp, "\t\tvector %s\n", name);
00466 break;
00467 case LSTT_INVENTORY:
00468 bytestream2char(name, mRawData, event_offset);
00469 fprintf(fp, "%s\n", name);
00470 bytestream2char(name, mRawData, event_offset);
00471 fprintf(fp, "\t\tinteger %s\n", name);
00472 break;
00473 case LSTT_ATTACH:
00474 bytestream2char(name, mRawData, event_offset);
00475 fprintf(fp, "%s\n", name);
00476 bytestream2char(name, mRawData, event_offset);
00477 fprintf(fp, "\t\tkey %s\n", name);
00478 break;
00479 case LSTT_DATASERVER:
00480 bytestream2char(name, mRawData, event_offset);
00481 fprintf(fp, "%s\n", name);
00482 bytestream2char(name, mRawData, event_offset);
00483 fprintf(fp, "\t\tkey %s\n", name);
00484 bytestream2char(name, mRawData, event_offset);
00485 fprintf(fp, "\t\tstring %s\n", name);
00486 break;
00487 case LSTT_TIMER:
00488 bytestream2char(name, mRawData, event_offset);
00489 fprintf(fp, "%s\n", name);
00490 break;
00491 case LSTT_MOVING_START:
00492 bytestream2char(name, mRawData, event_offset);
00493 fprintf(fp, "%s\n", name);
00494 break;
00495 case LSTT_MOVING_END:
00496 bytestream2char(name, mRawData, event_offset);
00497 fprintf(fp, "%s\n", name);
00498 break;
00499 case LSTT_CHAT:
00500 bytestream2char(name, mRawData, event_offset);
00501 fprintf(fp, "%s\n", name);
00502 bytestream2char(name, mRawData, event_offset);
00503 fprintf(fp, "\t\tinteger %s\n", name);
00504 bytestream2char(name, mRawData, event_offset);
00505 fprintf(fp, "\t\tkey %s\n", name);
00506 bytestream2char(name, mRawData, event_offset);
00507 fprintf(fp, "\t\tstring %s\n", name);
00508 break;
00509 case LSTT_OBJECT_REZ:
00510 bytestream2char(name, mRawData, event_offset);
00511 fprintf(fp, "%s\n", name);
00512 bytestream2char(name, mRawData, event_offset);
00513 fprintf(fp, "\t\tkey %s\n", name);
00514 break;
00515 case LSTT_REMOTE_DATA:
00516 bytestream2char(name, mRawData, event_offset);
00517 fprintf(fp, "%s\n", name);
00518 bytestream2char(name, mRawData, event_offset);
00519 fprintf(fp, "\t\tinteger %s\n", name);
00520 bytestream2char(name, mRawData, event_offset);
00521 fprintf(fp, "\t\tkey %s\n", name);
00522 bytestream2char(name, mRawData, event_offset);
00523 fprintf(fp, "\t\tinteger %s\n", name);
00524 bytestream2char(name, mRawData, event_offset);
00525 fprintf(fp, "\t\tstring %s\n", name);
00526 break;
00527 case LSTT_REZ:
00528 bytestream2char(name, mRawData, event_offset);
00529 fprintf(fp, "%s\n", name);
00530 break;
00531 case LSTT_SENSOR:
00532 bytestream2char(name, mRawData, event_offset);
00533 fprintf(fp, "%s\n", name);
00534 bytestream2char(name, mRawData, event_offset);
00535 fprintf(fp, "\t\tinteger %s\n", name);
00536 break;
00537 case LSTT_NO_SENSOR:
00538 bytestream2char(name, mRawData, event_offset);
00539 fprintf(fp, "%s\n", name);
00540 break;
00541 case LSTT_CONTROL:
00542 bytestream2char(name, mRawData, event_offset);
00543 fprintf(fp, "%s\n", name);
00544 bytestream2char(name, mRawData, event_offset);
00545 fprintf(fp, "\t\tkey %s\n", name);
00546 bytestream2char(name, mRawData, event_offset);
00547 fprintf(fp, "\t\tinteger %s\n", name);
00548 bytestream2char(name, mRawData, event_offset);
00549 fprintf(fp, "\t\tinteger %s\n", name);
00550 break;
00551 case LSTT_LINK_MESSAGE:
00552 bytestream2char(name, mRawData, event_offset);
00553 fprintf(fp, "%s\n", name);
00554 bytestream2char(name, mRawData, event_offset);
00555 fprintf(fp, "\t\tinteger %s\n", name);
00556 bytestream2char(name, mRawData, event_offset);
00557 fprintf(fp, "\t\tstring %s\n", name);
00558 bytestream2char(name, mRawData, event_offset);
00559 fprintf(fp, "\t\tkey %s\n", name);
00560 break;
00561 case LSTT_MONEY:
00562 bytestream2char(name, mRawData, event_offset);
00563 fprintf(fp, "%s\n", name);
00564 bytestream2char(name, mRawData, event_offset);
00565 fprintf(fp, "\t\tkey %s\n", name);
00566 bytestream2char(name, mRawData, event_offset);
00567 fprintf(fp, "\t\tinteger %s\n", name);
00568 break;
00569 case LSTT_EMAIL:
00570 bytestream2char(name, mRawData, event_offset);
00571 fprintf(fp, "%s\n", name);
00572 bytestream2char(name, mRawData, event_offset);
00573 fprintf(fp, "\t\tstring %s\n", name);
00574 bytestream2char(name, mRawData, event_offset);
00575 fprintf(fp, "\t\tstring %s\n", name);
00576 bytestream2char(name, mRawData, event_offset);
00577 fprintf(fp, "\t\tstring %s\n", name);
00578 bytestream2char(name, mRawData, event_offset);
00579 fprintf(fp, "\t\tinteger %s\n", name);
00580 break;
00581 case LSTT_AT_TARGET:
00582 bytestream2char(name, mRawData, event_offset);
00583 fprintf(fp, "%s\n", name);
00584 bytestream2char(name, mRawData, event_offset);
00585 fprintf(fp, "\t\tinteger %s\n", name);
00586 bytestream2char(name, mRawData, event_offset);
00587 fprintf(fp, "\t\tvector %s\n", name);
00588 bytestream2char(name, mRawData, event_offset);
00589 fprintf(fp, "\t\tvector %s\n", name);
00590 break;
00591 case LSTT_NOT_AT_TARGET:
00592 bytestream2char(name, mRawData, event_offset);
00593 fprintf(fp, "%s\n", name);
00594 break;
00595 case LSTT_AT_ROT_TARGET:
00596 bytestream2char(name, mRawData, event_offset);
00597 fprintf(fp, "%s\n", name);
00598 bytestream2char(name, mRawData, event_offset);
00599 fprintf(fp, "\t\tinteger %s\n", name);
00600 bytestream2char(name, mRawData, event_offset);
00601 fprintf(fp, "\t\tquaternion %s\n", name);
00602 bytestream2char(name, mRawData, event_offset);
00603 fprintf(fp, "\t\tquaternion %s\n", name);
00604 break;
00605 case LSTT_NOT_AT_ROT_TARGET:
00606 bytestream2char(name, mRawData, event_offset);
00607 fprintf(fp, "%s\n", name);
00608 break;
00609 case LSTT_RTPERMISSIONS:
00610 bytestream2char(name, mRawData, event_offset);
00611 fprintf(fp, "%s\n", name);
00612 fprintf(fp, "\t\tinteger %s\n", name);
00613 bytestream2char(name, mRawData, event_offset);
00614 break;
00615 case LSTT_HTTP_RESPONSE:
00616 bytestream2char(name, mRawData, event_offset);
00617 fprintf(fp, "%s\n", name);
00618 bytestream2char(name, mRawData, event_offset);
00619 fprintf(fp, "\t\tkey %s\n", name);
00620 bytestream2char(name, mRawData, event_offset);
00621 fprintf(fp, "\t\tinteger %s\n", name);
00622 bytestream2char(name, mRawData, event_offset);
00623 fprintf(fp, "\t\tlist %s\n", name);
00624 bytestream2char(name, mRawData, event_offset);
00625 fprintf(fp, "\t\tstring %s\n", name);
00626 break;
00627 default:
00628 break;
00629 }
00630 fprintf(fp, "\t\tStack Size: %d\n", stack_size);
00631 fprintf(fp, "\t\t\tOpCodes: 0x%X - 0x%X\n", opcode_start, opcode_end);
00632 printOpCodeRange(fp, opcode_start, opcode_end, 3);
00633 }
00634 }
00635 }
00636 }
00637 fprintf(fp, "=============================\n\n");
00638 }
00639
00640 void LLScriptLSOParse::printHeap(FILE *fp)
00641 {
00642
00643
00644 S32 heap_offset = get_register(mRawData, LREG_HR);
00645 S32 heap_pointer = get_register(mRawData, LREG_HP);
00646 fprintf(fp, "=============================\n");
00647 fprintf(fp, "[0x%X - 0x%X] Heap\n", heap_offset, heap_pointer);
00648 fprintf(fp, "=============================\n");
00649
00650 lsa_fprint_heap(mRawData, fp);
00651
00652 fprintf(fp, "=============================\n\n");
00653 }
00654
00655 void lso_print_tabs(FILE *fp, S32 tabs)
00656 {
00657 S32 i;
00658 for (i = 0; i < tabs; i++)
00659 {
00660 fprintf(fp, "\t");
00661 }
00662 }
00663
00664 void LLScriptLSOParse::printOpCodes(FILE *fp, S32 &offset, S32 tabs)
00665 {
00666 U8 opcode = *(mRawData + offset);
00667 mPrintOpCodes[opcode](fp, mRawData, offset, tabs);
00668 }
00669
00670 void LLScriptLSOParse::printOpCodeRange(FILE *fp, S32 start, S32 end, S32 tabs)
00671 {
00672 while (start < end)
00673 {
00674 printOpCodes(fp, start, tabs);
00675 }
00676 }
00677
00678 void LLScriptLSOParse::initOpCodePrinting()
00679 {
00680 S32 i;
00681 for (i = 0; i < 256; i++)
00682 {
00683 mPrintOpCodes[i] = print_noop;
00684 }
00685 mPrintOpCodes[LSCRIPTOpCodes[LOPC_NOOP]] = print_noop;
00686
00687 mPrintOpCodes[LSCRIPTOpCodes[LOPC_POP]] = print_pop;
00688 mPrintOpCodes[LSCRIPTOpCodes[LOPC_POPS]] = print_pops;
00689 mPrintOpCodes[LSCRIPTOpCodes[LOPC_POPL]] = print_popl;
00690 mPrintOpCodes[LSCRIPTOpCodes[LOPC_POPV]] = print_popv;
00691 mPrintOpCodes[LSCRIPTOpCodes[LOPC_POPQ]] = print_popq;
00692 mPrintOpCodes[LSCRIPTOpCodes[LOPC_POPARG]] = print_poparg;
00693 mPrintOpCodes[LSCRIPTOpCodes[LOPC_POPIP]] = print_popip;
00694 mPrintOpCodes[LSCRIPTOpCodes[LOPC_POPBP]] = print_popbp;
00695 mPrintOpCodes[LSCRIPTOpCodes[LOPC_POPSP]] = print_popsp;
00696 mPrintOpCodes[LSCRIPTOpCodes[LOPC_POPSLR]] = print_popslr;
00697
00698 mPrintOpCodes[LSCRIPTOpCodes[LOPC_DUP]] = print_dup;
00699 mPrintOpCodes[LSCRIPTOpCodes[LOPC_DUPS]] = print_dups;
00700 mPrintOpCodes[LSCRIPTOpCodes[LOPC_DUPL]] = print_dupl;
00701 mPrintOpCodes[LSCRIPTOpCodes[LOPC_DUPV]] = print_dupv;
00702 mPrintOpCodes[LSCRIPTOpCodes[LOPC_DUPQ]] = print_dupq;
00703
00704 mPrintOpCodes[LSCRIPTOpCodes[LOPC_STORE]] = print_store;
00705 mPrintOpCodes[LSCRIPTOpCodes[LOPC_STORES]] = print_stores;
00706 mPrintOpCodes[LSCRIPTOpCodes[LOPC_STOREL]] = print_storel;
00707 mPrintOpCodes[LSCRIPTOpCodes[LOPC_STOREV]] = print_storev;
00708 mPrintOpCodes[LSCRIPTOpCodes[LOPC_STOREQ]] = print_storeq;
00709 mPrintOpCodes[LSCRIPTOpCodes[LOPC_STOREG]] = print_storeg;
00710 mPrintOpCodes[LSCRIPTOpCodes[LOPC_STOREGS]] = print_storegs;
00711 mPrintOpCodes[LSCRIPTOpCodes[LOPC_STOREGL]] = print_storegl;
00712 mPrintOpCodes[LSCRIPTOpCodes[LOPC_STOREGV]] = print_storegv;
00713 mPrintOpCodes[LSCRIPTOpCodes[LOPC_STOREGQ]] = print_storegq;
00714 mPrintOpCodes[LSCRIPTOpCodes[LOPC_LOADP]] = print_loadp;
00715 mPrintOpCodes[LSCRIPTOpCodes[LOPC_LOADSP]] = print_loadsp;
00716 mPrintOpCodes[LSCRIPTOpCodes[LOPC_LOADLP]] = print_loadlp;
00717 mPrintOpCodes[LSCRIPTOpCodes[LOPC_LOADVP]] = print_loadvp;
00718 mPrintOpCodes[LSCRIPTOpCodes[LOPC_LOADQP]] = print_loadqp;
00719 mPrintOpCodes[LSCRIPTOpCodes[LOPC_LOADGP]] = print_loadgp;
00720 mPrintOpCodes[LSCRIPTOpCodes[LOPC_LOADGSP]] = print_loadgsp;
00721 mPrintOpCodes[LSCRIPTOpCodes[LOPC_LOADGLP]] = print_loadglp;
00722 mPrintOpCodes[LSCRIPTOpCodes[LOPC_LOADGVP]] = print_loadgvp;
00723 mPrintOpCodes[LSCRIPTOpCodes[LOPC_LOADGQP]] = print_loadgqp;
00724
00725 mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSH]] = print_push;
00726 mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHS]] = print_pushs;
00727 mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHL]] = print_pushl;
00728 mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHV]] = print_pushv;
00729 mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHQ]] = print_pushq;
00730 mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHG]] = print_pushg;
00731 mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHGS]] = print_pushgs;
00732 mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHGL]] = print_pushgl;
00733 mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHGV]] = print_pushgv;
00734 mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHGQ]] = print_pushgq;
00735 mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHIP]] = print_puship;
00736 mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHSP]] = print_pushsp;
00737 mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHBP]] = print_pushbp;
00738 mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHARGB]] = print_pushargb;
00739 mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHARGI]] = print_pushargi;
00740 mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHARGF]] = print_pushargf;
00741 mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHARGS]] = print_pushargs;
00742 mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHARGV]] = print_pushargv;
00743 mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHARGQ]] = print_pushargq;
00744 mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHE]] = print_pushe;
00745 mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHEV]] = print_pushev;
00746 mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHEQ]] = print_pusheq;
00747 mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHARGE]] = print_pusharge;
00748
00749 mPrintOpCodes[LSCRIPTOpCodes[LOPC_ADD]] = print_add;
00750 mPrintOpCodes[LSCRIPTOpCodes[LOPC_SUB]] = print_sub;
00751 mPrintOpCodes[LSCRIPTOpCodes[LOPC_MUL]] = print_mul;
00752 mPrintOpCodes[LSCRIPTOpCodes[LOPC_DIV]] = print_div;
00753 mPrintOpCodes[LSCRIPTOpCodes[LOPC_MOD]] = print_mod;
00754
00755 mPrintOpCodes[LSCRIPTOpCodes[LOPC_EQ]] = print_eq;
00756 mPrintOpCodes[LSCRIPTOpCodes[LOPC_NEQ]] = print_neq;
00757 mPrintOpCodes[LSCRIPTOpCodes[LOPC_LEQ]] = print_leq;
00758 mPrintOpCodes[LSCRIPTOpCodes[LOPC_GEQ]] = print_geq;
00759 mPrintOpCodes[LSCRIPTOpCodes[LOPC_LESS]] = print_less;
00760 mPrintOpCodes[LSCRIPTOpCodes[LOPC_GREATER]] = print_greater;
00761
00762 mPrintOpCodes[LSCRIPTOpCodes[LOPC_BITAND]] = print_bitand;
00763 mPrintOpCodes[LSCRIPTOpCodes[LOPC_BITOR]] = print_bitor;
00764 mPrintOpCodes[LSCRIPTOpCodes[LOPC_BITXOR]] = print_bitxor;
00765
00766 mPrintOpCodes[LSCRIPTOpCodes[LOPC_BOOLAND]] = print_booland;
00767 mPrintOpCodes[LSCRIPTOpCodes[LOPC_BOOLOR]] = print_boolor;
00768
00769 mPrintOpCodes[LSCRIPTOpCodes[LOPC_SHL]] = print_shl;
00770 mPrintOpCodes[LSCRIPTOpCodes[LOPC_SHR]] = print_shr;
00771
00772 mPrintOpCodes[LSCRIPTOpCodes[LOPC_NEG]] = print_neg;
00773 mPrintOpCodes[LSCRIPTOpCodes[LOPC_BITNOT]] = print_bitnot;
00774 mPrintOpCodes[LSCRIPTOpCodes[LOPC_BOOLNOT]] = print_boolnot;
00775
00776 mPrintOpCodes[LSCRIPTOpCodes[LOPC_JUMP]] = print_jump;
00777 mPrintOpCodes[LSCRIPTOpCodes[LOPC_JUMPIF]] = print_jumpif;
00778 mPrintOpCodes[LSCRIPTOpCodes[LOPC_JUMPNIF]] = print_jumpnif;
00779
00780 mPrintOpCodes[LSCRIPTOpCodes[LOPC_STATE]] = print_state;
00781 mPrintOpCodes[LSCRIPTOpCodes[LOPC_CALL]] = print_call;
00782 mPrintOpCodes[LSCRIPTOpCodes[LOPC_RETURN]] = print_return;
00783 mPrintOpCodes[LSCRIPTOpCodes[LOPC_CAST]] = print_cast;
00784 mPrintOpCodes[LSCRIPTOpCodes[LOPC_STACKTOS]] = print_stacktos;
00785 mPrintOpCodes[LSCRIPTOpCodes[LOPC_STACKTOL]] = print_stacktol;
00786
00787 mPrintOpCodes[LSCRIPTOpCodes[LOPC_PRINT]] = print_print;
00788
00789 mPrintOpCodes[LSCRIPTOpCodes[LOPC_CALLLIB]] = print_calllib;
00790
00791 mPrintOpCodes[LSCRIPTOpCodes[LOPC_CALLLIB_TWO_BYTE]] = print_calllib_two_byte;
00792 }
00793
00794 void print_noop(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
00795 {
00796 lso_print_tabs(fp, tabs);
00797 fprintf(fp, "[0x%X]\tNOOP\n", offset++);
00798 }
00799
00800 void print_pop(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
00801 {
00802 lso_print_tabs(fp, tabs);
00803 fprintf(fp, "[0x%X]\tPOP\n", offset++);
00804 }
00805
00806 void print_pops(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
00807 {
00808 lso_print_tabs(fp, tabs);
00809 fprintf(fp, "[0x%X]\tPOPS\n", offset++);
00810 }
00811
00812 void print_popl(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
00813 {
00814 lso_print_tabs(fp, tabs);
00815 fprintf(fp, "[0x%X]\tPOPL\n", offset++);
00816 }
00817
00818 void print_popv(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
00819 {
00820 lso_print_tabs(fp, tabs);
00821 fprintf(fp, "[0x%X]\tPOPV\n", offset++);
00822 }
00823
00824 void print_popq(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
00825 {
00826 lso_print_tabs(fp, tabs);
00827 fprintf(fp, "[0x%X]\tPOPQ\n", offset++);
00828 }
00829
00830 void print_poparg(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
00831 {
00832 S32 arg;
00833 lso_print_tabs(fp, tabs);
00834 fprintf(fp, "[0x%X]\tPOPARG ", offset++);
00835 arg = bytestream2integer(buffer, offset);
00836 fprintf(fp, "%d\n", arg);
00837 }
00838
00839 void print_popip(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
00840 {
00841 lso_print_tabs(fp, tabs);
00842 fprintf(fp, "[0x%X]\tPOPIP\n", offset++);
00843 }
00844
00845 void print_popbp(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
00846 {
00847 lso_print_tabs(fp, tabs);
00848 fprintf(fp, "[0x%X]\tPOPBP\n", offset++);
00849 }
00850
00851 void print_popsp(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
00852 {
00853 lso_print_tabs(fp, tabs);
00854 fprintf(fp, "[0x%X]\tPOPSP\n", offset++);
00855 }
00856
00857 void print_popslr(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
00858 {
00859 lso_print_tabs(fp, tabs);
00860 fprintf(fp, "[0x%X]\tPOPSLR\n", offset++);
00861 }
00862
00863 void print_dup(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
00864 {
00865 lso_print_tabs(fp, tabs);
00866 fprintf(fp, "[0x%X]\tDUP\n", offset++);
00867 }
00868
00869 void print_dups(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
00870 {
00871 lso_print_tabs(fp, tabs);
00872 fprintf(fp, "[0x%X]\tDUPS\n", offset++);
00873 }
00874
00875 void print_dupl(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
00876 {
00877 lso_print_tabs(fp, tabs);
00878 fprintf(fp, "[0x%X]\tDUPL\n", offset++);
00879 }
00880
00881 void print_dupv(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
00882 {
00883 lso_print_tabs(fp, tabs);
00884 fprintf(fp, "[0x%X]\tDUPV\n", offset++);
00885 }
00886
00887 void print_dupq(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
00888 {
00889 lso_print_tabs(fp, tabs);
00890 fprintf(fp, "[0x%X]\tDUPQ\n", offset++);
00891 }
00892
00893 void print_store(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
00894 {
00895 S32 arg;
00896 lso_print_tabs(fp, tabs);
00897 fprintf(fp, "[0x%X]\tSTORE $BP + ", offset++);
00898 arg = bytestream2integer(buffer, offset);
00899 fprintf(fp, "%d\n", arg);
00900 }
00901
00902 void print_stores(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
00903 {
00904 S32 arg;
00905 lso_print_tabs(fp, tabs);
00906 fprintf(fp, "[0x%X]\tSTORES $BP + ", offset++);
00907 arg = bytestream2integer(buffer, offset);
00908 fprintf(fp, "%d\n", arg);
00909 }
00910
00911 void print_storel(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
00912 {
00913 S32 arg;
00914 lso_print_tabs(fp, tabs);
00915 fprintf(fp, "[0x%X]\tSTOREL $BP + ", offset++);
00916 arg = bytestream2integer(buffer, offset);
00917 fprintf(fp, "%d\n", arg);
00918 }
00919
00920 void print_storev(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
00921 {
00922 S32 arg;
00923 lso_print_tabs(fp, tabs);
00924 fprintf(fp, "[0x%X]\tSTOREV $BP + ", offset++);
00925 arg = bytestream2integer(buffer, offset);
00926 fprintf(fp, "%d\n", arg);
00927 }
00928
00929 void print_storeq(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
00930 {
00931 S32 arg;
00932 lso_print_tabs(fp, tabs);
00933 fprintf(fp, "[0x%X]\tSTOREQ $BP + ", offset++);
00934 arg = bytestream2integer(buffer, offset);
00935 fprintf(fp, "%d\n", arg);
00936 }
00937
00938 void print_storeg(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
00939 {
00940 S32 arg;
00941 lso_print_tabs(fp, tabs);
00942 fprintf(fp, "[0x%X]\tSTOREG ", offset++);
00943 arg = bytestream2integer(buffer, offset);
00944 fprintf(fp, "%d\n", arg + get_register(buffer, LREG_GVR));
00945 }
00946
00947 void print_storegs(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
00948 {
00949 S32 arg;
00950 lso_print_tabs(fp, tabs);
00951 fprintf(fp, "[0x%X]\tSTOREGS ", offset++);
00952 arg = bytestream2integer(buffer, offset);
00953 fprintf(fp, "%d\n", arg + get_register(buffer, LREG_GVR));
00954 }
00955
00956 void print_storegl(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
00957 {
00958 S32 arg;
00959 lso_print_tabs(fp, tabs);
00960 fprintf(fp, "[0x%X]\tSTOREGL ", offset++);
00961 arg = bytestream2integer(buffer, offset);
00962 fprintf(fp, "%d\n", arg + get_register(buffer, LREG_GVR));
00963 }
00964
00965 void print_storegv(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
00966 {
00967 S32 arg;
00968 lso_print_tabs(fp, tabs);
00969 fprintf(fp, "[0x%X]\tSTOREGV ", offset++);
00970 arg = bytestream2integer(buffer, offset);
00971 fprintf(fp, "%d\n", arg + get_register(buffer, LREG_GVR));
00972 }
00973
00974 void print_storegq(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
00975 {
00976 S32 arg;
00977 lso_print_tabs(fp, tabs);
00978 fprintf(fp, "[0x%X]\tSTOREGQ ", offset++);
00979 arg = bytestream2integer(buffer, offset);
00980 fprintf(fp, "%d\n", arg + get_register(buffer, LREG_GVR));
00981 }
00982
00983 void print_loadp(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
00984 {
00985 S32 arg;
00986 lso_print_tabs(fp, tabs);
00987 fprintf(fp, "[0x%X]\tSTOREP $BP + ", offset++);
00988 arg = bytestream2integer(buffer, offset);
00989 fprintf(fp, "%d\n", arg);
00990 }
00991
00992 void print_loadsp(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
00993 {
00994 S32 arg;
00995 lso_print_tabs(fp, tabs);
00996 fprintf(fp, "[0x%X]\tSTOREPS $BP + ", offset++);
00997 arg = bytestream2integer(buffer, offset);
00998 fprintf(fp, "%d\n", arg);
00999 }
01000
01001 void print_loadlp(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01002 {
01003 S32 arg;
01004 lso_print_tabs(fp, tabs);
01005 fprintf(fp, "[0x%X]\tSTOREPL $BP + ", offset++);
01006 arg = bytestream2integer(buffer, offset);
01007 fprintf(fp, "%d\n", arg);
01008 }
01009
01010 void print_loadvp(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01011 {
01012 S32 arg;
01013 lso_print_tabs(fp, tabs);
01014 fprintf(fp, "[0x%X]\tSTOREVP $BP + ", offset++);
01015 arg = bytestream2integer(buffer, offset);
01016 fprintf(fp, "%d\n", arg);
01017 }
01018
01019 void print_loadqp(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01020 {
01021 S32 arg;
01022 lso_print_tabs(fp, tabs);
01023 fprintf(fp, "[0x%X]\tSTOREQP $BP + ", offset++);
01024 arg = bytestream2integer(buffer, offset);
01025 fprintf(fp, "%d\n", arg);
01026 }
01027
01028 void print_loadgp(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01029 {
01030 S32 arg;
01031 lso_print_tabs(fp, tabs);
01032 fprintf(fp, "[0x%X]\tSTOREGP ", offset++);
01033 arg = bytestream2integer(buffer, offset);
01034 fprintf(fp, "%d\n", arg + get_register(buffer, LREG_GVR));
01035 }
01036
01037 void print_loadgsp(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01038 {
01039 S32 arg;
01040 lso_print_tabs(fp, tabs);
01041 fprintf(fp, "[0x%X]\tSTOREGSP ", offset++);
01042 arg = bytestream2integer(buffer, offset);
01043 fprintf(fp, "%d\n", arg + get_register(buffer, LREG_GVR));
01044 }
01045
01046 void print_loadglp(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01047 {
01048 S32 arg;
01049 lso_print_tabs(fp, tabs);
01050 fprintf(fp, "[0x%X]\tSTOREGLP ", offset++);
01051 arg = bytestream2integer(buffer, offset);
01052 fprintf(fp, "%d\n", arg + get_register(buffer, LREG_GVR));
01053 }
01054
01055 void print_loadgvp(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01056 {
01057 S32 arg;
01058 lso_print_tabs(fp, tabs);
01059 fprintf(fp, "[0x%X]\tSTOREGVP ", offset++);
01060 arg = bytestream2integer(buffer, offset);
01061 fprintf(fp, "%d\n", arg + get_register(buffer, LREG_GVR));
01062 }
01063
01064 void print_loadgqp(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01065 {
01066 S32 arg;
01067 lso_print_tabs(fp, tabs);
01068 fprintf(fp, "[0x%X]\tSTOREGQP ", offset++);
01069 arg = bytestream2integer(buffer, offset);
01070 fprintf(fp, "%d\n", arg + get_register(buffer, LREG_GVR));
01071 }
01072
01073 void print_push(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01074 {
01075 S32 arg;
01076 lso_print_tabs(fp, tabs);
01077 fprintf(fp, "[0x%X]\tPUSH $BP + ", offset++);
01078 arg = bytestream2integer(buffer, offset);
01079 fprintf(fp, "%d\n", arg);
01080 }
01081
01082 void print_pushs(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01083 {
01084 S32 arg;
01085 lso_print_tabs(fp, tabs);
01086 fprintf(fp, "[0x%X]\tPUSHS $BP + ", offset++);
01087 arg = bytestream2integer(buffer, offset);
01088 fprintf(fp, "%d\n", arg);
01089 }
01090
01091 void print_pushl(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01092 {
01093 S32 arg;
01094 lso_print_tabs(fp, tabs);
01095 fprintf(fp, "[0x%X]\tPUSHL $BP + ", offset++);
01096 arg = bytestream2integer(buffer, offset);
01097 fprintf(fp, "%d\n", arg);
01098 }
01099
01100 void print_pushv(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01101 {
01102 S32 arg;
01103 lso_print_tabs(fp, tabs);
01104 fprintf(fp, "[0x%X]\tPUSHV $BP + ", offset++);
01105 arg = bytestream2integer(buffer, offset);
01106 fprintf(fp, "%d\n", arg);
01107 }
01108
01109 void print_pushq(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01110 {
01111 S32 arg;
01112 lso_print_tabs(fp, tabs);
01113 fprintf(fp, "[0x%X]\tPUSHQ $BP + ", offset++);
01114 arg = bytestream2integer(buffer, offset);
01115 fprintf(fp, "%d\n", arg);
01116 }
01117
01118 void print_pushg(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01119 {
01120 S32 arg;
01121 lso_print_tabs(fp, tabs);
01122 fprintf(fp, "[0x%X]\tPUSHG ", offset++);
01123 arg = bytestream2integer(buffer, offset);
01124 fprintf(fp, "0x%X\n", arg + get_register(buffer, LREG_GVR));
01125 }
01126
01127 void print_pushgs(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01128 {
01129 S32 arg;
01130 lso_print_tabs(fp, tabs);
01131 fprintf(fp, "[0x%X]\tPUSHGS ", offset++);
01132 arg = bytestream2integer(buffer, offset);
01133 fprintf(fp, "0x%X\n", arg + get_register(buffer, LREG_GVR));
01134 }
01135
01136 void print_pushgl(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01137 {
01138 S32 arg;
01139 lso_print_tabs(fp, tabs);
01140 fprintf(fp, "[0x%X]\tPUSHGL ", offset++);
01141 arg = bytestream2integer(buffer, offset);
01142 fprintf(fp, "0x%X\n", arg + get_register(buffer, LREG_GVR));
01143 }
01144
01145 void print_pushgv(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01146 {
01147 S32 arg;
01148 lso_print_tabs(fp, tabs);
01149 fprintf(fp, "[0x%X]\tPUSHGV ", offset++);
01150 arg = bytestream2integer(buffer, offset);
01151 fprintf(fp, "0x%X\n", arg + get_register(buffer, LREG_GVR));
01152 }
01153
01154 void print_pushgq(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01155 {
01156 S32 arg;
01157 lso_print_tabs(fp, tabs);
01158 fprintf(fp, "[0x%X]\tPUSHGQ ", offset++);
01159 arg = bytestream2integer(buffer, offset);
01160 fprintf(fp, "0x%X\n", arg + get_register(buffer, LREG_GVR));
01161 }
01162
01163 void print_puship(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01164 {
01165 lso_print_tabs(fp, tabs);
01166 fprintf(fp, "[0x%X]\tPUSHIP\n", offset++);
01167 }
01168
01169 void print_pushbp(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01170 {
01171 lso_print_tabs(fp, tabs);
01172 fprintf(fp, "[0x%X]\tPUSHBP\n", offset++);
01173 }
01174
01175 void print_pushsp(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01176 {
01177 lso_print_tabs(fp, tabs);
01178 fprintf(fp, "[0x%X]\tPUSHSP\n", offset++);
01179 }
01180
01181 void print_pushargb(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01182 {
01183 U8 arg;
01184 lso_print_tabs(fp, tabs);
01185 fprintf(fp, "[0x%X]\tPUSHARGB ", offset++);
01186 arg = *(buffer + offset++);
01187 fprintf(fp, "%d\n", (U32)arg);
01188 }
01189
01190 void print_pushargi(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01191 {
01192 S32 arg;
01193 lso_print_tabs(fp, tabs);
01194 fprintf(fp, "[0x%X]\tPUSHARGI ", offset++);
01195 arg = bytestream2integer(buffer, offset);
01196 fprintf(fp, "%d\n", arg);
01197 }
01198
01199 void print_pushargf(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01200 {
01201 F32 arg;
01202 lso_print_tabs(fp, tabs);
01203 fprintf(fp, "[0x%X]\tPUSHARGF ", offset++);
01204 arg = bytestream2float(buffer, offset);
01205 fprintf(fp, "%f\n", arg);
01206 }
01207
01208 void print_pushargs(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01209 {
01210 char arg[1024];
01211 lso_print_tabs(fp, tabs);
01212 fprintf(fp, "[0x%X]\tPUSHARGS ", offset++);
01213 bytestream2char(arg, buffer, offset);
01214 fprintf(fp, "%s\n", arg);
01215 }
01216
01217 void print_pushargv(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01218 {
01219 LLVector3 arg;
01220 lso_print_tabs(fp, tabs);
01221 fprintf(fp, "[0x%X]\tPUSHARGV ", offset++);
01222 bytestream2vector(arg, buffer, offset);
01223 fprintf(fp, "< %f, %f, %f >\n", arg.mV[VX], arg.mV[VY], arg.mV[VZ]);
01224 }
01225
01226 void print_pushargq(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01227 {
01228 LLQuaternion arg;
01229 lso_print_tabs(fp, tabs);
01230 fprintf(fp, "[0x%X]\tPUSHARGV ", offset++);
01231 bytestream2quaternion(arg, buffer, offset);
01232 fprintf(fp, "< %f, %f, %f, %f >\n", arg.mQ[VX], arg.mQ[VY], arg.mQ[VZ], arg.mQ[VS]);
01233 }
01234
01235 void print_pushe(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01236 {
01237 lso_print_tabs(fp, tabs);
01238 fprintf(fp, "[0x%X]\tPUSHE\n", offset++);
01239 }
01240
01241 void print_pushev(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01242 {
01243 lso_print_tabs(fp, tabs);
01244 fprintf(fp, "[0x%X]\tPUSHEV\n", offset++);
01245 }
01246
01247 void print_pusheq(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01248 {
01249 lso_print_tabs(fp, tabs);
01250 fprintf(fp, "[0x%X]\tPUSHEQ\n", offset++);
01251 }
01252
01253 void print_pusharge(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01254 {
01255 S32 arg;
01256 lso_print_tabs(fp, tabs);
01257 fprintf(fp, "[0x%X]\tPUSHARGE ", offset++);
01258 arg = bytestream2integer(buffer, offset);
01259 fprintf(fp, "%d\n", arg);
01260 }
01261
01262
01263 void print_add(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01264 {
01265 U8 types;
01266 U8 type1;
01267 U8 type2;
01268 lso_print_tabs(fp, tabs);
01269 fprintf(fp, "[0x%X]\tADD ", offset++);
01270 types = *(buffer + offset++);
01271 type1 = types >> 4;
01272 type2 = types & 0xf;
01273 fprintf(fp, "%s, %s\n", LSCRIPTTypeNames[type1], LSCRIPTTypeNames[type2]);
01274 }
01275
01276 void print_sub(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01277 {
01278 U8 types;
01279 U8 type1;
01280 U8 type2;
01281 lso_print_tabs(fp, tabs);
01282 fprintf(fp, "[0x%X]\tSUB ", offset++);
01283 types = *(buffer + offset++);
01284 type1 = types >> 4;
01285 type2 = types & 0xf;
01286 fprintf(fp, "%s, %s\n", LSCRIPTTypeNames[type1], LSCRIPTTypeNames[type2]);
01287 }
01288
01289 void print_mul(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01290 {
01291 U8 types;
01292 U8 type1;
01293 U8 type2;
01294 lso_print_tabs(fp, tabs);
01295 fprintf(fp, "[0x%X]\tMUL ", offset++);
01296 types = *(buffer + offset++);
01297 type1 = types >> 4;
01298 type2 = types & 0xf;
01299 fprintf(fp, "%s, %s\n", LSCRIPTTypeNames[type1], LSCRIPTTypeNames[type2]);
01300 }
01301
01302 void print_div(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01303 {
01304 U8 types;
01305 U8 type1;
01306 U8 type2;
01307 lso_print_tabs(fp, tabs);
01308 fprintf(fp, "[0x%X]\tDIV ", offset++);
01309 types = *(buffer + offset++);
01310 type1 = types >> 4;
01311 type2 = types & 0xf;
01312 fprintf(fp, "%s, %s\n", LSCRIPTTypeNames[type1], LSCRIPTTypeNames[type2]);
01313 }
01314
01315 void print_mod(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01316 {
01317 U8 types;
01318 U8 type1;
01319 U8 type2;
01320 lso_print_tabs(fp, tabs);
01321 fprintf(fp, "[0x%X]\tMOD ", offset++);
01322 types = *(buffer + offset++);
01323 type1 = types >> 4;
01324 type2 = types & 0xf;
01325 fprintf(fp, "%s, %s\n", LSCRIPTTypeNames[type1], LSCRIPTTypeNames[type2]);
01326 }
01327
01328 void print_eq(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01329 {
01330 U8 types;
01331 U8 type1;
01332 U8 type2;
01333 lso_print_tabs(fp, tabs);
01334 fprintf(fp, "[0x%X]\tEQ ", offset++);
01335 types = *(buffer + offset++);
01336 type1 = types >> 4;
01337 type2 = types & 0xf;
01338 fprintf(fp, "%s, %s\n", LSCRIPTTypeNames[type1], LSCRIPTTypeNames[type2]);
01339 }
01340
01341 void print_neq(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01342 {
01343 U8 types;
01344 U8 type1;
01345 U8 type2;
01346 lso_print_tabs(fp, tabs);
01347 fprintf(fp, "[0x%X]\tNEQ ", offset++);
01348 types = *(buffer + offset++);
01349 type1 = types >> 4;
01350 type2 = types & 0xf;
01351 fprintf(fp, "%s, %s\n", LSCRIPTTypeNames[type1], LSCRIPTTypeNames[type2]);
01352 }
01353
01354 void print_leq(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01355 {
01356 U8 types;
01357 U8 type1;
01358 U8 type2;
01359 lso_print_tabs(fp, tabs);
01360 fprintf(fp, "[0x%X]\tLEQ ", offset++);
01361 types = *(buffer + offset++);
01362 type1 = types >> 4;
01363 type2 = types & 0xf;
01364 fprintf(fp, "%s, %s\n", LSCRIPTTypeNames[type1], LSCRIPTTypeNames[type2]);
01365 }
01366
01367 void print_geq(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01368 {
01369 U8 types;
01370 U8 type1;
01371 U8 type2;
01372 lso_print_tabs(fp, tabs);
01373 fprintf(fp, "[0x%X]\tGEQ ", offset++);
01374 types = *(buffer + offset++);
01375 type1 = types >> 4;
01376 type2 = types & 0xf;
01377 fprintf(fp, "%s, %s\n", LSCRIPTTypeNames[type1], LSCRIPTTypeNames[type2]);
01378 }
01379
01380 void print_less(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01381 {
01382 U8 types;
01383 U8 type1;
01384 U8 type2;
01385 lso_print_tabs(fp, tabs);
01386 fprintf(fp, "[0x%X]\tLESS ", offset++);
01387 types = *(buffer + offset++);
01388 type1 = types >> 4;
01389 type2 = types & 0xf;
01390 fprintf(fp, "%s, %s\n", LSCRIPTTypeNames[type1], LSCRIPTTypeNames[type2]);
01391 }
01392
01393 void print_greater(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01394 {
01395 U8 types;
01396 U8 type1;
01397 U8 type2;
01398 lso_print_tabs(fp, tabs);
01399 fprintf(fp, "[0x%X]\tGREATER ", offset++);
01400 types = *(buffer + offset++);
01401 type1 = types >> 4;
01402 type2 = types & 0xf;
01403 fprintf(fp, "%s, %s\n", LSCRIPTTypeNames[type1], LSCRIPTTypeNames[type2]);
01404 }
01405
01406
01407 void print_bitand(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01408 {
01409 lso_print_tabs(fp, tabs);
01410 fprintf(fp, "[0x%X]\tBITAND\n", offset++);
01411 }
01412
01413 void print_bitor(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01414 {
01415 lso_print_tabs(fp, tabs);
01416 fprintf(fp, "[0x%X]\tBITOR\n", offset++);
01417 }
01418
01419 void print_bitxor(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01420 {
01421 lso_print_tabs(fp, tabs);
01422 fprintf(fp, "[0x%X]\tBITXOR\n", offset++);
01423 }
01424
01425 void print_booland(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01426 {
01427 lso_print_tabs(fp, tabs);
01428 fprintf(fp, "[0x%X]\tBOOLAND\n", offset++);
01429 }
01430
01431 void print_boolor(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01432 {
01433 lso_print_tabs(fp, tabs);
01434 fprintf(fp, "[0x%X]\tBOOLOR\n", offset++);
01435 }
01436
01437 void print_shl(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01438 {
01439 lso_print_tabs(fp, tabs);
01440 fprintf(fp, "[0x%X]\tSHL\n", offset++);
01441 }
01442
01443 void print_shr(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01444 {
01445 lso_print_tabs(fp, tabs);
01446 fprintf(fp, "[0x%X]\tSHR\n", offset++);
01447 }
01448
01449
01450 void print_neg(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01451 {
01452 U8 type;
01453 lso_print_tabs(fp, tabs);
01454 fprintf(fp, "[0x%X]\tNEG ", offset++);
01455 type = *(buffer + offset++);
01456 fprintf(fp, "%s\n", LSCRIPTTypeNames[type]);
01457 }
01458
01459 void print_bitnot(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01460 {
01461 lso_print_tabs(fp, tabs);
01462 fprintf(fp, "[0x%X]\tBITNOT\n", offset++);
01463 }
01464
01465 void print_boolnot(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01466 {
01467 lso_print_tabs(fp, tabs);
01468 fprintf(fp, "[0x%X]\tBOOLNOT\n", offset++);
01469 }
01470
01471 void print_jump(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01472 {
01473 S32 arg;
01474 lso_print_tabs(fp, tabs);
01475 fprintf(fp, "[0x%X]\tJUMP ", offset++);
01476 arg = bytestream2integer(buffer, offset);
01477 fprintf(fp, "%d\n", arg);
01478 }
01479
01480 void print_jumpif(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01481 {
01482 S32 arg;
01483 U8 type;
01484 lso_print_tabs(fp, tabs);
01485 fprintf(fp, "[0x%X]\tJUMPIF ", offset++);
01486 type = *(buffer + offset++);
01487 arg = bytestream2integer(buffer, offset);
01488 fprintf(fp, "%s, %d\n", LSCRIPTTypeNames[type], arg);
01489 }
01490
01491 void print_jumpnif(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01492 {
01493 S32 arg;
01494 U8 type;
01495 lso_print_tabs(fp, tabs);
01496 fprintf(fp, "[0x%X]\tJUMPNIF ", offset++);
01497 type = *(buffer + offset++);
01498 arg = bytestream2integer(buffer, offset);
01499 fprintf(fp, "%s, %d\n", LSCRIPTTypeNames[type], arg);
01500 }
01501
01502 void print_state(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01503 {
01504 S32 arg;
01505 lso_print_tabs(fp, tabs);
01506 fprintf(fp, "[0x%X]\tSTATE ", offset++);
01507 arg = bytestream2integer(buffer, offset);
01508 fprintf(fp, "%d\n", arg);
01509 }
01510
01511 void print_call(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01512 {
01513 S32 arg;
01514 lso_print_tabs(fp, tabs);
01515 fprintf(fp, "[0x%X]\tCALL ", offset++);
01516 arg = bytestream2integer(buffer, offset);
01517 fprintf(fp, "%d\n", arg);
01518 }
01519
01520 void print_return(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01521 {
01522 lso_print_tabs(fp, tabs);
01523 fprintf(fp, "[0x%X]\tRETURN\n", offset++);
01524 }
01525
01526 void print_cast(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01527 {
01528 U8 types;
01529 U8 type1;
01530 U8 type2;
01531 lso_print_tabs(fp, tabs);
01532 fprintf(fp, "[0x%X]\tCAST ", offset++);
01533 types = *(buffer + offset++);
01534 type1 = types >> 4;
01535 type2 = types & 0xf;
01536 fprintf(fp, "%s, %s\n", LSCRIPTTypeNames[type1], LSCRIPTTypeNames[type2]);
01537 }
01538
01539 void print_stacktos(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01540 {
01541 S32 arg;
01542 lso_print_tabs(fp, tabs);
01543 fprintf(fp, "[0x%X]\tSTACKTOS ", offset++);
01544 arg = bytestream2integer(buffer, offset);
01545 fprintf(fp, "%d\n", arg);
01546 }
01547
01548 void print_stacktol(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01549 {
01550 S32 arg;
01551 lso_print_tabs(fp, tabs);
01552 fprintf(fp, "[0x%X]\tSTACKTOL ", offset++);
01553 arg = bytestream2integer(buffer, offset);
01554 fprintf(fp, "%d\n", arg);
01555 }
01556
01557 void print_print(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01558 {
01559 lso_print_tabs(fp, tabs);
01560 fprintf(fp, "[0x%X]\tPRINT ", offset++);
01561 U8 type = *(buffer + offset++);
01562 fprintf(fp, "%s\n", LSCRIPTTypeNames[type]);
01563 }
01564
01565 void print_calllib(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01566 {
01567 U8 arg;
01568 lso_print_tabs(fp, tabs);
01569 fprintf(fp, "[0x%X]\tCALLLIB ", offset++);
01570 arg = *(buffer + offset++);
01571 fprintf(fp, "%d (%s)\n", (U32)arg, gScriptLibrary.mFunctions[arg]->mName);
01572 }
01573
01574
01575 void print_calllib_two_byte(FILE *fp, U8 *buffer, S32 &offset, S32 tabs)
01576 {
01577 U16 arg;
01578 lso_print_tabs(fp, tabs);
01579 fprintf(fp, "[0x%X]\tCALLLIB_TWO_BYTE ", offset++);
01580 arg = bytestream2u16(buffer, offset);
01581 fprintf(fp, "%d (%s)\n", (U32)arg, gScriptLibrary.mFunctions[arg]->mName);
01582 }
01583