summaryrefslogtreecommitdiff
path: root/indra/lscript/lscript_compile
diff options
context:
space:
mode:
authorKelly Washington <kelly@lindenlab.com>2009-02-24 19:29:36 +0000
committerKelly Washington <kelly@lindenlab.com>2009-02-24 19:29:36 +0000
commitaa2b978bf59dd74083bec86c61a29fefb4ebb14c (patch)
tree63d0e55a524208eb2bdad1a1a6f0d03af1b39de2 /indra/lscript/lscript_compile
parentf5242719b628efb148f05ba44ce78f9818ec617a (diff)
merge -r 112783:112799 linden/branches/kelly/lsl-http-in-merge to linden/trunk
Diffstat (limited to 'indra/lscript/lscript_compile')
-rw-r--r--indra/lscript/lscript_compile/indra.l24
-rw-r--r--indra/lscript/lscript_compile/indra.y21
-rw-r--r--indra/lscript/lscript_compile/lscript_tree.cpp109
-rw-r--r--indra/lscript/lscript_compile/lscript_tree.h30
4 files changed, 172 insertions, 12 deletions
diff --git a/indra/lscript/lscript_compile/indra.l b/indra/lscript/lscript_compile/indra.l
index 2616b47c73..ac524326fc 100644
--- a/indra/lscript/lscript_compile/indra.l
+++ b/indra/lscript/lscript_compile/indra.l
@@ -118,6 +118,7 @@ extern "C" { int yyerror(const char *fmt, ...); }
"object_rez" { count(); return(OBJECT_REZ); }
"remote_data" { count(); return(REMOTE_DATA); }
"http_response" { count(); return(HTTP_RESPONSE); }
+"http_request" { count(); return(HTTP_REQUEST); }
"." { count(); return(PERIOD); }
@@ -221,16 +222,17 @@ extern "C" { int yyerror(const char *fmt, ...); }
"INVENTORY_ALL" { count(); yylval.ival = LLAssetType::AT_NONE; return(INTEGER_CONSTANT); }
"INVENTORY_NONE" { count(); yylval.ival = LLAssetType::AT_NONE; return(INTEGER_CONSTANT); }
-"CHANGED_INVENTORY" { count(); yylval.ival = 0x1; return(INTEGER_CONSTANT); }
-"CHANGED_COLOR" { count(); yylval.ival = 0x2; return(INTEGER_CONSTANT); }
-"CHANGED_SHAPE" { count(); yylval.ival = 0x4; return(INTEGER_CONSTANT); }
-"CHANGED_SCALE" { count(); yylval.ival = 0x8; return(INTEGER_CONSTANT); }
-"CHANGED_TEXTURE" { count(); yylval.ival = 0x10; return(INTEGER_CONSTANT); }
-"CHANGED_LINK" { count(); yylval.ival = 0x20; return(INTEGER_CONSTANT); }
-"CHANGED_ALLOWED_DROP" { count(); yylval.ival = 0x40; return(INTEGER_CONSTANT); }
-"CHANGED_OWNER" { count(); yylval.ival = 0x80; return(INTEGER_CONSTANT); }
-"CHANGED_REGION" { count(); yylval.ival = 0x100; return(INTEGER_CONSTANT); }
-"CHANGED_TELEPORT" { count(); yylval.ival = 0x200; return(INTEGER_CONSTANT); }
+"CHANGED_INVENTORY" { count(); yylval.ival = CHANGED_INVENTORY; return(INTEGER_CONSTANT); }
+"CHANGED_COLOR" { count(); yylval.ival = CHANGED_COLOR; return(INTEGER_CONSTANT); }
+"CHANGED_SHAPE" { count(); yylval.ival = CHANGED_SHAPE; return(INTEGER_CONSTANT); }
+"CHANGED_SCALE" { count(); yylval.ival = CHANGED_SCALE; return(INTEGER_CONSTANT); }
+"CHANGED_TEXTURE" { count(); yylval.ival = CHANGED_TEXTURE; return(INTEGER_CONSTANT); }
+"CHANGED_LINK" { count(); yylval.ival = CHANGED_LINK; return(INTEGER_CONSTANT); }
+"CHANGED_ALLOWED_DROP" { count(); yylval.ival = CHANGED_ALLOWED_DROP; return(INTEGER_CONSTANT); }
+"CHANGED_OWNER" { count(); yylval.ival = CHANGED_OWNER; return(INTEGER_CONSTANT); }
+"CHANGED_REGION" { count(); yylval.ival = CHANGED_REGION; return(INTEGER_CONSTANT); }
+"CHANGED_TELEPORT" { count(); yylval.ival = CHANGED_TELEPORT; return(INTEGER_CONSTANT); }
+"CHANGED_REGION_START" { count(); yylval.ival = CHANGED_REGION_START; return(INTEGER_CONSTANT); }
"OBJECT_UNKNOWN_DETAIL" { count(); yylval.ival = OBJECT_UNKNOWN_DETAIL; return(INTEGER_CONSTANT); }
"OBJECT_NAME" { count(); yylval.ival = OBJECT_NAME; return(INTEGER_CONSTANT); }
@@ -252,6 +254,8 @@ extern "C" { int yyerror(const char *fmt, ...); }
"NULL_KEY" { yylval.sval = new char[UUID_STR_LENGTH]; strcpy(yylval.sval, "00000000-0000-0000-0000-000000000000"); return(STRING_CONSTANT); }
"EOF" { yylval.sval = new char[UUID_STR_LENGTH]; strcpy(yylval.sval, "\n\n\n"); return(STRING_CONSTANT); }
+"URL_REQUEST_GRANTED" { yylval.sval = new char[UUID_STR_LENGTH]; strcpy(yylval.sval, URL_REQUEST_GRANTED); return(STRING_CONSTANT); }
+"URL_REQUEST_DENIED" { yylval.sval = new char[UUID_STR_LENGTH]; strcpy(yylval.sval, URL_REQUEST_DENIED); return(STRING_CONSTANT); }
"PI" { count(); yylval.fval = F_PI; return(FP_CONSTANT); }
"TWO_PI" { count(); yylval.fval = F_TWO_PI; return(FP_CONSTANT); }
diff --git a/indra/lscript/lscript_compile/indra.y b/indra/lscript/lscript_compile/indra.y
index fdc240c772..e4b10ffdd9 100644
--- a/indra/lscript/lscript_compile/indra.y
+++ b/indra/lscript/lscript_compile/indra.y
@@ -92,6 +92,7 @@
%token LINK_MESSAGE
%token REMOTE_DATA
%token HTTP_RESPONSE
+%token HTTP_REQUEST
%token <sval> IDENTIFIER
%token <sval> STATE_DEFAULT
@@ -195,6 +196,7 @@
%type <event> object_rez
%type <event> remote_data
%type <event> http_response
+%type <event> http_request
%type <event> link_message
%type <event> timer
%type <event> chat
@@ -848,6 +850,11 @@ event
$$ = new LLScriptEventHandler(gLine, gColumn, $1, $2);
gAllocationManager->addAllocation($$);
}
+ | http_request compound_statement
+ {
+ $$ = new LLScriptEventHandler(gLine, gColumn, $1, $2);
+ gAllocationManager->addAllocation($$);
+ }
;
state_entry
@@ -1216,6 +1223,20 @@ http_response
}
;
+http_request
+ : HTTP_REQUEST '(' LLKEY IDENTIFIER ',' STRING IDENTIFIER ',' STRING IDENTIFIER ')'
+ {
+ LLScriptIdentifier *id1 = new LLScriptIdentifier(gLine, gColumn, $4);
+ gAllocationManager->addAllocation(id1);
+ LLScriptIdentifier *id2 = new LLScriptIdentifier(gLine, gColumn, $7);
+ gAllocationManager->addAllocation(id2);
+ LLScriptIdentifier *id3 = new LLScriptIdentifier(gLine, gColumn, $10);
+ gAllocationManager->addAllocation(id3);
+ $$ = new LLScriptHTTPRequestEvent(gLine, gColumn, id1, id2, id3);
+ gAllocationManager->addAllocation($$);
+ }
+ ;
+
compound_statement
: '{' '}'
{
diff --git a/indra/lscript/lscript_compile/lscript_tree.cpp b/indra/lscript/lscript_compile/lscript_tree.cpp
index 51983bb41b..e291d4c6f8 100644
--- a/indra/lscript/lscript_compile/lscript_tree.cpp
+++ b/indra/lscript/lscript_compile/lscript_tree.cpp
@@ -3291,6 +3291,110 @@ S32 LLScriptHTTPResponseEvent::getSize()
return 16;
}
+void LLScriptHTTPRequestEvent::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, "http_request( key ");
+ mRequestId->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
+ fprintf(fp, ", string ");
+ mMethod->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
+ fprintf(fp, ", string ");
+ mBody->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, "http_request");
+ if (scope->checkEntry(mRequestId->mName))
+ {
+ gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
+ }
+ else
+ {
+ mRequestId->mScopeEntry = scope->addEntry(mRequestId->mName, LIT_VARIABLE, LST_KEY);
+ }
+
+ if (scope->checkEntry(mMethod->mName))
+ {
+ gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
+ }
+ else
+ {
+ mMethod->mScopeEntry = scope->addEntry(mMethod->mName, LIT_VARIABLE, LST_STRING);
+ }
+
+ if (scope->checkEntry(mBody->mName))
+ {
+ gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
+ }
+ else
+ {
+ mBody->mScopeEntry = scope->addEntry(mBody->mName, LIT_VARIABLE, LST_STRING);
+ }
+ break;
+
+ case LSCP_RESOURCE:
+ {
+ // we're just tryng to determine how much space the variable needs
+ if (mRequestId->mScopeEntry)
+ {
+ mRequestId->mScopeEntry->mOffset = (S32)count;
+ mRequestId->mScopeEntry->mSize = 4;
+ count += mRequestId->mScopeEntry->mSize;
+
+ mMethod->mScopeEntry->mOffset = (S32)count;
+ mMethod->mScopeEntry->mSize = 4;
+ count += mMethod->mScopeEntry->mSize;
+
+ mBody->mScopeEntry->mOffset = (S32)count;
+ mBody->mScopeEntry->mSize = 4;
+ count += mBody->mScopeEntry->mSize;
+ }
+ }
+ break;
+
+ case LSCP_EMIT_BYTE_CODE:
+ {
+#ifdef LSL_INCLUDE_DEBUG_INFO
+ char name[] = "http_request";
+ chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/
+ chunk->addBytes(mRequestId->mName, strlen(mRequestId->mName) + 1); /*Flawfinder: ignore*/
+ chunk->addBytes(mMethod->mName, strlen(mMethod->mName) + 1); /*Flawfinder: ignore*/
+ chunk->addBytes(mBody->mName, strlen(mBody->mName) + 1); /*Flawfinder: ignore*/
+#endif
+ }
+ break;
+ case LSCP_EMIT_CIL_ASSEMBLY:
+ fdotabs(fp, tabs, tabsize);
+ fprintf(fp, "http_request( valuetype [ScriptTypes]LindenLab.SecondLife.Key ");
+ mRequestId->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
+ fprintf(fp, ", string ");
+ mMethod->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
+ fprintf(fp, ", string ");
+ mBody->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
+ fprintf(fp, " )\n");
+ break;
+ default:
+ mRequestId->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
+ mMethod->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
+ mBody->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
+ break;
+ }
+}
+
+S32 LLScriptHTTPRequestEvent::getSize()
+{
+ // key + string + string = 12
+ return 12;
+}
void LLScriptMoneyEvent::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)
{
@@ -9658,6 +9762,11 @@ void LLScriptEventHandler::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCom
mScopeEntry->mFunctionArgs.addType(LST_LIST);
mScopeEntry->mFunctionArgs.addType(LST_STRING);
break;
+ case LSTT_HTTP_REQUEST:
+ mScopeEntry->mFunctionArgs.addType(LST_KEY);
+ mScopeEntry->mFunctionArgs.addType(LST_STRING);
+ mScopeEntry->mFunctionArgs.addType(LST_STRING);
+ break;
default:
break;
diff --git a/indra/lscript/lscript_compile/lscript_tree.h b/indra/lscript/lscript_compile/lscript_tree.h
index 369d775e5d..12c16908af 100644
--- a/indra/lscript/lscript_compile/lscript_tree.h
+++ b/indra/lscript/lscript_compile/lscript_tree.h
@@ -759,12 +759,12 @@ class LLScriptHTTPResponseEvent : public LLScriptEvent
{
public:
LLScriptHTTPResponseEvent(S32 line, S32 col,
- LLScriptIdentifier *reqeust_id,
+ LLScriptIdentifier *request_id,
LLScriptIdentifier *status,
LLScriptIdentifier *metadata,
LLScriptIdentifier *body)
: LLScriptEvent(line, col, LSTT_HTTP_RESPONSE),
- mRequestId(reqeust_id), mStatus(status), mMetadata(metadata), mBody(body)
+ mRequestId(request_id), mStatus(status), mMetadata(metadata), mBody(body)
{
}
@@ -783,6 +783,32 @@ public:
LLScriptIdentifier *mBody;
};
+class LLScriptHTTPRequestEvent : public LLScriptEvent
+{
+public:
+ LLScriptHTTPRequestEvent(S32 line, S32 col,
+ LLScriptIdentifier *request_id,
+ LLScriptIdentifier *method,
+ LLScriptIdentifier *body)
+ : LLScriptEvent(line, col, LSTT_HTTP_REQUEST),
+ mRequestId(request_id), mMethod(method), mBody(body)
+ {
+ }
+
+ 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 *mRequestId;
+ LLScriptIdentifier *mMethod;
+ LLScriptIdentifier *mBody;
+};
+
class LLScriptRezEvent : public LLScriptEvent
{
public: