diff options
Diffstat (limited to 'linden/indra/lscript/lscript_execute.h')
-rw-r--r-- | linden/indra/lscript/lscript_execute.h | 150 |
1 files changed, 144 insertions, 6 deletions
diff --git a/linden/indra/lscript/lscript_execute.h b/linden/indra/lscript/lscript_execute.h index 997e04d..ac23ff3 100644 --- a/linden/indra/lscript/lscript_execute.h +++ b/linden/indra/lscript/lscript_execute.h | |||
@@ -367,20 +367,158 @@ public: | |||
367 | class LLScriptExecute | 367 | class LLScriptExecute |
368 | { | 368 | { |
369 | public: | 369 | public: |
370 | LLScriptExecute(LLFILE *fp); | 370 | LLScriptExecute(); |
371 | LLScriptExecute(U8 *buffer); | 371 | virtual ~LLScriptExecute() {;} |
372 | ~LLScriptExecute(); | 372 | |
373 | virtual S32 getVersion() = 0; | ||
374 | virtual void deleteAllEvents() = 0; | ||
375 | virtual void addEvent(LLScriptDataCollection* event) = 0; | ||
376 | virtual U32 getEventCount() = 0; | ||
377 | virtual void removeEventType(LSCRIPTStateEventType event_type) = 0; | ||
378 | virtual S32 getFaults() = 0; | ||
379 | virtual void setFault(LSCRIPTRunTimeFaults fault) = 0; | ||
380 | virtual U32 getFreeMemory() = 0; | ||
381 | virtual S32 getParameter() = 0; | ||
382 | virtual void setParameter(S32 value) = 0; | ||
383 | virtual F32 getSleep() const = 0; | ||
384 | virtual void setSleep(F32 value) = 0; | ||
385 | virtual F32 getEnergy() const = 0; | ||
386 | virtual void setEnergy(F32 value) = 0; | ||
387 | virtual U64 getCurrentEvents(S32 version) = 0; | ||
388 | virtual void setCurrentEvents(U64 value, S32 version) = 0; | ||
389 | virtual U64 getEventHandlers(S32 version) = 0; | ||
390 | virtual void setEventHandlers(U64 value, S32 version) = 0; | ||
391 | virtual U64 getCurrentHandler(S32 version) = 0; | ||
392 | virtual void setCurrentHandler(U64 value, S32 version) = 0; | ||
393 | virtual BOOL isFinished() const = 0; | ||
394 | virtual BOOL isStateChangePending() const = 0; | ||
395 | virtual S32 writeState(U8 **dest, U32 header_size, U32 footer_size) = 0; // Allocate memory for header, state and footer return size of state. | ||
396 | virtual U32 getEventsSavedSize() = 0; // Returns 0 if events are written with state. | ||
397 | virtual S32 writeEvents(U8 *dest) = 0; // Must write and return exactly the number of bytes returned by getEventsSavedSize. | ||
398 | virtual void readEvents(U8* src, S32& offset) = 0; | ||
399 | virtual S32 readState(U8 *src) = 0; // Returns number of bytes read. | ||
400 | virtual void reset(); | ||
401 | virtual const U8* getBytecode() const = 0; | ||
402 | virtual U32 getBytecodeSize() const = 0; | ||
403 | virtual bool isMono() const = 0; | ||
404 | virtual void error() {;} // Processing that must be performed when error flag is set and so run is not called. | ||
405 | |||
406 | // Run current event handler for a maximum of time_slice seconds. | ||
407 | // Updates current handler and current events registers. | ||
408 | virtual void resumeEventHandler(BOOL b_print, const LLUUID &id, F32 time_slice) = 0; | ||
409 | |||
410 | // Run handler for event for a maximum of time_slice seconds. | ||
411 | // Updates current handler and current events registers. | ||
412 | virtual void callEventHandler(LSCRIPTStateEventType event, S32 major_version, const LLUUID &id, F32 time_slice) = 0;; | ||
413 | |||
414 | // Run handler for next queued event for maximum of time_slice seconds. | ||
415 | // Updates current handler and current events registers. | ||
416 | // Removes processed event from queue. | ||
417 | virtual void callNextQueuedEventHandler(U64 event_register, S32 major_version, const LLUUID &id, F32 time_slice) = 0; | ||
418 | |||
419 | // Run handler for event for a maximum of time_slice seconds. | ||
420 | // Updates current handler and current events registers. | ||
421 | // Removes processed event from queue. | ||
422 | virtual void callQueuedEventHandler(LSCRIPTStateEventType event, S32 major_version, const LLUUID &id, F32 time_slice) = 0; | ||
423 | |||
424 | // Switch to next state. | ||
425 | // Returns new set of handled events. | ||
426 | virtual U64 nextState() = 0; | ||
427 | |||
428 | // Returns time taken. | ||
429 | virtual F32 runQuanta(BOOL b_print, const LLUUID &id, | ||
430 | const char **errorstr, | ||
431 | BOOL &state_transition, F32 quanta, | ||
432 | U32& events_processed, LLTimer& timer); | ||
433 | |||
434 | // Run smallest possible amount of code: an instruction for LSL2, a segment | ||
435 | // between save tests for Mono | ||
436 | void runInstructions(BOOL b_print, const LLUUID &id, | ||
437 | const char **errorstr, | ||
438 | BOOL &state_transition, U32& events_processed, | ||
439 | F32 quanta); | ||
440 | |||
441 | bool isYieldDue() const; | ||
442 | |||
443 | void setReset(BOOL b) {mReset = b;} | ||
444 | BOOL getReset() const { return mReset; } | ||
445 | |||
446 | private: | ||
447 | |||
448 | BOOL mReset; | ||
449 | }; | ||
450 | |||
451 | class LLScriptExecuteLSL2 : public LLScriptExecute | ||
452 | { | ||
453 | public: | ||
454 | LLScriptExecuteLSL2(LLFILE *fp); | ||
455 | LLScriptExecuteLSL2(const U8* bytecode, U32 bytecode_size); | ||
456 | virtual ~LLScriptExecuteLSL2(); | ||
457 | |||
458 | virtual S32 getVersion() {return get_register(mBuffer, LREG_VN);} | ||
459 | virtual void deleteAllEvents() {mEventData.mEventDataList.deleteAllData();} | ||
460 | virtual void addEvent(LLScriptDataCollection* event); | ||
461 | virtual U32 getEventCount() {return mEventData.mEventDataList.getLength();} | ||
462 | virtual void removeEventType(LSCRIPTStateEventType event_type); | ||
463 | virtual S32 getFaults() {return get_register(mBuffer, LREG_FR);} | ||
464 | virtual void setFault(LSCRIPTRunTimeFaults fault) {set_fault(mBuffer, fault);} | ||
465 | virtual U32 getFreeMemory(); | ||
466 | virtual S32 getParameter(); | ||
467 | virtual void setParameter(S32 value); | ||
468 | virtual F32 getSleep() const; | ||
469 | virtual void setSleep(F32 value); | ||
470 | virtual F32 getEnergy() const; | ||
471 | virtual void setEnergy(F32 value); | ||
472 | virtual U64 getCurrentEvents(S32 version) {return get_event_register(mBuffer, LREG_CE, version);} | ||
473 | virtual void setCurrentEvents(U64 value, S32 version) {return set_event_register(mBuffer, LREG_CE, value, version);} | ||
474 | virtual U64 getEventHandlers(S32 version) {return get_event_register(mBuffer, LREG_ER, version);} | ||
475 | virtual void setEventHandlers(U64 value, S32 version) {set_event_register(mBuffer, LREG_ER, value, version);} | ||
476 | virtual U64 getCurrentHandler(S32 version); | ||
477 | virtual void setCurrentHandler(U64 value, S32 version) {return set_event_register(mBuffer, LREG_IE, value, version);} | ||
478 | virtual BOOL isFinished() const {return get_register(mBuffer, LREG_IP) == 0;} | ||
479 | virtual BOOL isStateChangePending() const {return get_register(mBuffer, LREG_CS) != get_register(mBuffer, LREG_NS);} | ||
480 | virtual S32 writeState(U8 **dest, U32 header_size, U32 footer_size); // Not including Events. | ||
481 | virtual U32 getEventsSavedSize() {return mEventData.getSavedSize();} | ||
482 | virtual S32 writeEvents(U8 *dest) {return mEventData.write2bytestream(dest);} | ||
483 | virtual void readEvents(U8* src, S32& offset) {mEventData.set(src, offset);} | ||
484 | virtual S32 writeBytecode(U8 **dest); | ||
485 | virtual S32 readState(U8 *src); | ||
486 | virtual void reset(); | ||
487 | virtual const U8* getBytecode() const {return mBytecode;} | ||
488 | virtual U32 getBytecodeSize() const {return mBytecodeSize;} | ||
489 | virtual bool isMono() const {return false;} | ||
490 | |||
491 | // Run current event handler for a maximum of time_slice seconds. | ||
492 | // Updates current handler and current events registers. | ||
493 | virtual void resumeEventHandler(BOOL b_print, const LLUUID &id, F32 time_slice); | ||
494 | |||
495 | // Run handler for event for a maximum of time_slice seconds. | ||
496 | // Updates current handler and current events registers. | ||
497 | virtual void callEventHandler(LSCRIPTStateEventType event, S32 major_version, const LLUUID &id, F32 time_slice); | ||
498 | |||
499 | // Run handler for next queued event for maximum of time_slice seconds. | ||
500 | // Updates current handler and current events registers. | ||
501 | // Removes processed event from queue. | ||
502 | virtual void callNextQueuedEventHandler(U64 event_register, S32 major_version, const LLUUID &id, F32 time_slice); | ||
503 | |||
504 | // Run handler for event for a maximum of time_slice seconds. | ||
505 | // Updates current handler and current events registers. | ||
506 | // Removes processed event from queue. | ||
507 | virtual void callQueuedEventHandler(LSCRIPTStateEventType event, S32 major_version, const LLUUID &id, F32 time_slice); | ||
508 | |||
509 | // Switch to next state. | ||
510 | // Returns new set of handled events. | ||
511 | virtual U64 nextState(); | ||
373 | 512 | ||
374 | void init(); | 513 | void init(); |
375 | U32 run(BOOL b_print, const LLUUID &id, char **errorstr, BOOL &state_transition); | ||
376 | 514 | ||
377 | BOOL (*mExecuteFuncs[0x100])(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id); | 515 | BOOL (*mExecuteFuncs[0x100])(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id); |
378 | 516 | ||
379 | U32 mInstructionCount; | 517 | U32 mInstructionCount; |
380 | U8 *mBuffer; | 518 | U8 *mBuffer; |
381 | LLScriptEventData mEventData; | 519 | LLScriptEventData mEventData; |
382 | 520 | U8* mBytecode; // Initial state and bytecode. | |
383 | static S64 sGlobalInstructionCount; | 521 | U32 mBytecodeSize; |
384 | 522 | ||
385 | private: | 523 | private: |
386 | void recordBoundaryError( const LLUUID &id ); | 524 | void recordBoundaryError( const LLUUID &id ); |