diff options
| author | dolphin <dolphin@lindenlab.com> | 2014-08-06 13:49:29 -0700 | 
|---|---|---|
| committer | dolphin <dolphin@lindenlab.com> | 2014-08-06 13:49:29 -0700 | 
| commit | d576e66210c020a8a86bcc88898a352bc0875d9a (patch) | |
| tree | b9923d67ce516eb0300f237894d1fcc23885662d /indra/lscript/lscript_compile | |
| parent | 97c4c4cf60a5fbbcef4e1bd4213244a5c906d276 (diff) | |
Pulling over more lsl changes to support the adding of the LSL_XP_XXX constants
Diffstat (limited to 'indra/lscript/lscript_compile')
| -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 | 
3 files changed, 227 insertions, 2 deletions
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:  | 
