diff options
-rw-r--r-- | indra/llprimitive/lllslconstants.h | 19 | ||||
-rwxr-xr-x | indra/lscript/lscript_byteformat.h | 19 | ||||
-rwxr-xr-x | indra/lscript/lscript_compile/indra.y | 37 | ||||
-rwxr-xr-x | indra/lscript/lscript_compile/lscript_tree.cpp | 159 | ||||
-rwxr-xr-x | indra/lscript/lscript_compile/lscript_tree.h | 33 |
5 files changed, 260 insertions, 7 deletions
diff --git a/indra/llprimitive/lllslconstants.h b/indra/llprimitive/lllslconstants.h index 926ce32d75..b6baf98211 100644 --- a/indra/llprimitive/lllslconstants.h +++ b/indra/llprimitive/lllslconstants.h @@ -239,4 +239,23 @@ const U32 LSL_STATUS_INTERNAL_ERROR = 1999; // Start per-function errors below, starting at 2000: const U32 LSL_STATUS_WHITELIST_FAILED = 2001; + +const S32 LSL_XP_ERROR_NONE = 0; +const S32 LSL_XP_ERROR_THROTTLED = 1; +const S32 LSL_XP_ERROR_EXPERIENCES_DISABLED = 2; +const S32 LSL_XP_ERROR_INVALID_PARAMETERS = 3; +const S32 LSL_XP_ERROR_NOT_PERMITTED = 4; +const S32 LSL_XP_ERROR_NO_EXPERIENCE = 5; +const S32 LSL_XP_ERROR_NOT_FOUND = 6; +const S32 LSL_XP_ERROR_INVALID_EXPERIENCE = 7; +const S32 LSL_XP_ERROR_EXPERIENCE_DISABLED = 8; +const S32 LSL_XP_ERROR_EXPERIENCE_SUSPENDED = 9; +const S32 LSL_XP_ERROR_UNKNOWN_ERROR = 10; +const S32 LSL_XP_ERROR_QUOTA_EXCEEDED = 11; +const S32 LSL_XP_ERROR_STORE_DISABLED = 12; +const S32 LSL_XP_ERROR_STORAGE_EXCEPTION = 13; +const S32 LSL_XP_ERROR_KEY_NOT_FOUND = 14; +const S32 LSL_XP_ERROR_RETRY_UPDATE = 15; +const S32 LSL_XP_ERROR_MATURITY_EXCEEDED = 16; + #endif diff --git a/indra/lscript/lscript_byteformat.h b/indra/lscript/lscript_byteformat.h index 54031aaf05..a4703b7a61 100755 --- a/indra/lscript/lscript_byteformat.h +++ b/indra/lscript/lscript_byteformat.h @@ -355,6 +355,10 @@ typedef enum e_lscript_state_event_type LSTT_REMOTE_DATA, LSTT_HTTP_RESPONSE, LSTT_HTTP_REQUEST, + LSTT_EXPERMISSIONS, + LSTT_TRANSACTION_RESULT, + LSTT_PATH_UPDATE, + LSTT_EXPERMISSIONS_DENIED, LSTT_EOF, LSTT_STATE_BEGIN = LSTT_STATE_ENTRY, @@ -397,7 +401,11 @@ const U64 LSCRIPTStateBitField[LSTT_EOF] = 0x0000000040000000, // LSTT_OBJECT_REZ 0x0000000080000000, // LSTT_REMOTE_DATA 0x0000000100000000LL, // LSTT_HTTP_RESPOSE - 0x0000000200000000LL // LSTT_HTTP_REQUEST + 0x0000000200000000LL, // LSTT_HTTP_REQUEST + 0x0000000400000000LL, // LSTT_EXPERMISSIONS + 0x0000000800000000LL, // LSTT_TRANSACTION_RESULT + 0x0000001000000000LL, // LSTT_PATH_UPDATE + 0x0000002000000000LL, //LSTT_EXPERMISSIONS_DENIED }; inline S32 get_event_handler_jump_position(U64 bit_field, LSCRIPTStateEventType type) @@ -511,6 +519,7 @@ typedef enum e_lscript_runtime_faults LSRF_TOO_MANY_LISTENS, LSRF_NESTING_LISTS, LSRF_CLI, + LSRF_INVALID_STATE, LSRF_EOF } LSCRIPTRunTimeFaults; @@ -551,10 +560,10 @@ const U32 LSCRIPTRunTimePermissionBits[SCRIPT_PERMISSION_EOF] = (0x1 << 10),// SCRIPT_PERMISSION_TRACK_CAMERA (0x1 << 11),// SCRIPT_PERMISSION_CONTROL_CAMERA (0x1 << 12),// SCRIPT_PERMISSION_TELEPORT - (0x1 << 13),// SCRIPT_PERMISSION_EXPERIENCE, - (0x1 << 14),// SCRIPT_PERMISSION_SILENT_ESTATE_MANAGEMENT, - (0x1 << 15),// SCRIPT_PERMISSION_OVERRIDE_ANIMATIONS, - (0x1 << 16),// SCRIPT_PERMISSION_RETURN_OBJECTS, + (0x1 << 13),// SCRIPT_PERMISSION_EXPERIENCE + (0x1 << 14),// SCRIPT_PERMISSION_SILENT_ESTATE_MANAGEMENT + (0x1 << 15),// SCRIPT_PERMISSION_OVERRIDE_ANIMATIONS + (0x1 << 16),// SCRIPT_PERMISSION_RETURN_OBJECTS }; // http_request string constants diff --git a/indra/lscript/lscript_compile/indra.y b/indra/lscript/lscript_compile/indra.y index a0a034d21c..c451eee3d8 100755 --- a/indra/lscript/lscript_compile/indra.y +++ b/indra/lscript/lscript_compile/indra.y @@ -15,7 +15,6 @@ #pragma warning (disable : 4702) // warning C4702: unreachable code #pragma warning( disable : 4065 ) // warning: switch statement contains 'default' but no 'case' labels #endif - %} %union @@ -75,6 +74,8 @@ %token MONEY %token EMAIL %token RUN_TIME_PERMISSIONS +%token EXPERIENCE_PERMISSIONS +%token EXPERIENCE_PERMISSIONS_DENIED %token INVENTORY %token ATTACH %token DATASERVER @@ -180,6 +181,8 @@ %type <event> money %type <event> email %type <event> run_time_permissions +%type <event> experience_permissions +%type <event> experience_permissions_denied %type <event> inventory %type <event> attach %type <event> dataserver @@ -788,6 +791,16 @@ event $$ = new LLScriptEventHandler(gLine, gColumn, $1, $2); gAllocationManager->addAllocation($$); } + | experience_permissions compound_statement + { + $$ = new LLScriptEventHandler(gLine, gColumn, $1, $2); + gAllocationManager->addAllocation($$); + } + | experience_permissions_denied compound_statement + { + $$ = new LLScriptEventHandler(gLine, gColumn, $1, $2); + gAllocationManager->addAllocation($$); + } | inventory compound_statement { $$ = new LLScriptEventHandler(gLine, gColumn, $1, $2); @@ -1040,6 +1053,28 @@ run_time_permissions } ; +experience_permissions + : EXPERIENCE_PERMISSIONS '(' LLKEY IDENTIFIER ')' + { + LLScriptIdentifier *id1 = new LLScriptIdentifier(gLine, gColumn, $4); + gAllocationManager->addAllocation(id1); + $$ = new LLScriptEXPEvent(gLine, gColumn, id1); + gAllocationManager->addAllocation($$); + } + ; + +experience_permissions_denied + : EXPERIENCE_PERMISSIONS_DENIED '(' LLKEY IDENTIFIER ',' INTEGER IDENTIFIER ')' + { + LLScriptIdentifier *id1 = new LLScriptIdentifier(gLine, gColumn, $4); + gAllocationManager->addAllocation(id1); + LLScriptIdentifier *id2 = new LLScriptIdentifier(gLine, gColumn, $7); + gAllocationManager->addAllocation(id2); + $$ = new LLScriptEXPDeniedEvent(gLine, gColumn, id1, id2); + gAllocationManager->addAllocation($$); + } + ; + inventory : INVENTORY '(' INTEGER IDENTIFIER ')' { diff --git a/indra/lscript/lscript_compile/lscript_tree.cpp b/indra/lscript/lscript_compile/lscript_tree.cpp index 8a70dd9ac1..4215596c8b 100755 --- a/indra/lscript/lscript_compile/lscript_tree.cpp +++ b/indra/lscript/lscript_compile/lscript_tree.cpp @@ -3844,6 +3844,156 @@ S32 LLScriptNotAtTarget::getSize() return 0; } + +void LLScriptEXPEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata) +{ + if (gErrorToText.getErrors()) + { + return; + } + switch(pass) + { + case LSCP_PRETTY_PRINT: + case LSCP_EMIT_ASSEMBLY: + fdotabs(fp, tabs, tabsize); + fprintf(fp, "experience_permissions( key "); + mName->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, " )\n"); + break; + case LSCP_SCOPE_PASS1: + checkForDuplicateHandler(fp, this, scope, "experience_permissions"); + if (scope->checkEntry(mName->mName)) + { + gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME); + } + else + { + mName->mScopeEntry = scope->addEntry(mName->mName, LIT_VARIABLE, LST_KEY); + } + break; + case LSCP_RESOURCE: + { + // we're just tryng to determine how much space the variable needs + if (mName->mScopeEntry) + { + mName->mScopeEntry->mOffset = (S32)count; + mName->mScopeEntry->mSize = 4; + count += mName->mScopeEntry->mSize; + } + } + break; + + case LSCP_EMIT_BYTE_CODE: + { +#ifdef LSL_INCLUDE_DEBUG_INFO + char name[] = "experience_permissions"; + chunk->addBytes(name, strlen(name) + 1); + chunk->addBytes(mName->mName, strlen(mName->mName) + 1); +#endif + } + break; + case LSCP_EMIT_CIL_ASSEMBLY: + fdotabs(fp, tabs, tabsize); + fprintf(fp, "experience_permissions( valuetype [ScriptTypes]LindenLab.SecondLife.Key "); + mName->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, " )"); + break; + default: + mName->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + break; + } +} + +S32 LLScriptEXPEvent::getSize() +{ + // key = 4 + return 4; +} + + +void LLScriptEXPDeniedEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata) +{ + if (gErrorToText.getErrors()) + { + return; + } + switch(pass) + { + case LSCP_PRETTY_PRINT: + case LSCP_EMIT_ASSEMBLY: + fdotabs(fp, tabs, tabsize); + fprintf(fp, "experience_permissions_denied( key "); + mName->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, ", integer "); + mReason->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, " )\n"); + break; + case LSCP_SCOPE_PASS1: + checkForDuplicateHandler(fp, this, scope, "experience_permissions_denied"); + if (scope->checkEntry(mName->mName)) + { + gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME); + } + else + { + mName->mScopeEntry = scope->addEntry(mName->mName, LIT_VARIABLE, LST_KEY); + } + if (scope->checkEntry(mReason->mName)) + { + gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME); + } + else + { + mReason->mScopeEntry = scope->addEntry(mReason->mName, LIT_VARIABLE, LST_INTEGER); + } + break; + case LSCP_RESOURCE: + { + // we're just trying to determine how much space the variable needs + if (mName->mScopeEntry) + { + mName->mScopeEntry->mOffset = (S32)count; + mName->mScopeEntry->mSize = 4; + count += mName->mScopeEntry->mSize; + + mReason->mScopeEntry->mOffset = (S32)count; + mReason->mScopeEntry->mSize = 4; + count += mReason->mScopeEntry->mSize; + } + } + break; + + case LSCP_EMIT_BYTE_CODE: + { +#ifdef LSL_INCLUDE_DEBUG_INFO + char name[] = "experience_permissions_denied"; + chunk->addBytes(name, strlen(name) + 1); + chunk->addBytes(mName->mName, strlen(mName->mName) + 1); + chunk->addBytes(mReason->mName, strlen(mReason->mName) + 1); +#endif + } + break; + case LSCP_EMIT_CIL_ASSEMBLY: + fdotabs(fp, tabs, tabsize); + fprintf(fp, "experience_permissions_denied( valuetype [ScriptTypes]LindenLab.SecondLife.Key "); + mName->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, ", int32 "); + mReason->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, " )"); + break; + default: + mName->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + mReason->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + break; + } +} + +S32 LLScriptEXPDeniedEvent::getSize() +{ + // key = 4 + integer + return LSCRIPTDataSize[LST_KEY]+LSCRIPTDataSize[LST_INTEGER]; +} + void LLScriptAtRotTarget::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata) { if (gErrorToText.getErrors()) @@ -8569,6 +8719,7 @@ void LLScriptReturn::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePa } } prunearg = TRUE; + break; case LSCP_TYPE: // if there is a return expression, it must be promotable to the return type of the function if (mExpression) @@ -9767,7 +9918,13 @@ void LLScriptEventHandler::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCom mScopeEntry->mFunctionArgs.addType(LST_STRING); mScopeEntry->mFunctionArgs.addType(LST_STRING); break; - + case LSTT_EXPERMISSIONS: + mScopeEntry->mFunctionArgs.addType(LST_KEY); + break; + case LSTT_EXPERMISSIONS_DENIED: + mScopeEntry->mFunctionArgs.addType(LST_KEY); + mScopeEntry->mFunctionArgs.addType(LST_INTEGER); + break; default: break; } diff --git a/indra/lscript/lscript_compile/lscript_tree.h b/indra/lscript/lscript_compile/lscript_tree.h index 047c220b17..38a69cece8 100755 --- a/indra/lscript/lscript_compile/lscript_tree.h +++ b/indra/lscript/lscript_compile/lscript_tree.h @@ -627,6 +627,39 @@ public: LLScriptIdentifier *mRTPermissions; }; +class LLScriptEXPEvent : public LLScriptEvent +{ +public: + LLScriptEXPEvent(S32 line, S32 col, LLScriptIdentifier *name) + : LLScriptEvent(line, col, LSTT_EXPERMISSIONS), mName(name) + { + } + + ~LLScriptEXPEvent() {} + + void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata); + S32 getSize(); + + LLScriptIdentifier *mName; +}; + +class LLScriptEXPDeniedEvent : public LLScriptEvent +{ +public: + LLScriptEXPDeniedEvent(S32 line, S32 col, LLScriptIdentifier *name, LLScriptIdentifier *reason) + : LLScriptEvent(line, col, LSTT_EXPERMISSIONS_DENIED), mName(name), mReason(reason) + { + } + + ~LLScriptEXPDeniedEvent() {} + + void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata); + S32 getSize(); + + LLScriptIdentifier *mName; + LLScriptIdentifier *mReason; +}; + class LLScriptChatEvent : public LLScriptEvent { public: |