aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL/src/LuaSL_compile.c
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-02-01 21:36:05 +1000
committerDavid Walter Seikel2012-02-01 21:36:05 +1000
commitb46240b2f476c0194f8b25b24d8343128d889832 (patch)
tree5d270d91c58cf43f4f96410b5e39c585284637c8 /LuaSL/src/LuaSL_compile.c
parentLittle cleanups. (diff)
downloadSledjHamr-b46240b2f476c0194f8b25b24d8343128d889832.zip
SledjHamr-b46240b2f476c0194f8b25b24d8343128d889832.tar.gz
SledjHamr-b46240b2f476c0194f8b25b24d8343128d889832.tar.bz2
SledjHamr-b46240b2f476c0194f8b25b24d8343128d889832.tar.xz
Track event handlers differently from functions.
Diffstat (limited to '')
-rw-r--r--LuaSL/src/LuaSL_compile.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/LuaSL/src/LuaSL_compile.c b/LuaSL/src/LuaSL_compile.c
index a438a63..9c86f97 100644
--- a/LuaSL/src/LuaSL_compile.c
+++ b/LuaSL/src/LuaSL_compile.c
@@ -566,7 +566,10 @@ LSL_Leaf *addFunction(LuaSL_compiler *compiler, LSL_Leaf *type, LSL_Leaf *identi
566 } 566 }
567 else 567 else
568 identifier->basicType = OT_nothing; 568 identifier->basicType = OT_nothing;
569 eina_hash_add(compiler->script.functions, func->name.text, identifier); 569 if (compiler->inState)
570 eina_hash_add(compiler->state.handlers, func->name.text, func);
571 else
572 eina_hash_add(compiler->script.functions, func->name.text, identifier);
570#if LUASL_DIFF_CHECK 573#if LUASL_DIFF_CHECK
571// func->params = addParenthesis(open, params, LSL_PARAMETER_LIST, close); 574// func->params = addParenthesis(open, params, LSL_PARAMETER_LIST, close);
572#endif 575#endif
@@ -698,6 +701,9 @@ LSL_Leaf *addState(LuaSL_compiler *compiler, LSL_Leaf *state, LSL_Leaf *identifi
698 701
699 if ((identifier) && (result)) 702 if ((identifier) && (result))
700 { 703 {
704 memcpy(result, &(compiler->state), sizeof(LSL_State));
705 compiler->state.block = NULL;
706 compiler->state.handlers = NULL;
701 result->name.text = identifier->value.stringValue; 707 result->name.text = identifier->value.stringValue;
702#if LUASL_DIFF_CHECK 708#if LUASL_DIFF_CHECK
703 result->name.ignorable = identifier->ignorable; 709 result->name.ignorable = identifier->ignorable;
@@ -715,6 +721,7 @@ LSL_Leaf *addState(LuaSL_compiler *compiler, LSL_Leaf *state, LSL_Leaf *identifi
715 identifier->value.stateValue = result; 721 identifier->value.stateValue = result;
716 identifier->toKen = tokens[LSL_STATE - lowestToken]; 722 identifier->toKen = tokens[LSL_STATE - lowestToken];
717 eina_hash_add(compiler->script.states, result->name.text, identifier); 723 eina_hash_add(compiler->script.states, result->name.text, identifier);
724 compiler->inState = FALSE;
718 } 725 }
719 726
720 return identifier; 727 return identifier;
@@ -859,8 +866,13 @@ LSL_Leaf *collectStatements(LuaSL_compiler *compiler, LSL_Leaf *list, LSL_Leaf *
859 if (statement) 866 if (statement)
860 { 867 {
861 if (!wasNull) 868 if (!wasNull)
862 list->value.blockValue = compiler->currentBlock; // Maybe NULL. 869 list->value.blockValue = compiler->currentBlock; // Maybe NULL.
863 if (list->value.blockValue) 870
871 if ((compiler->inState) && (LSL_FUNCTION == statement->value.statementValue->type))
872 {
873 eina_clist_add_tail(&(compiler->state.block->statements), &(statement->value.statementValue->statement));
874 }
875 else if (list->value.blockValue)
864 { 876 {
865 eina_clist_add_tail(&(list->value.blockValue->statements), &(statement->value.statementValue->statement)); 877 eina_clist_add_tail(&(list->value.blockValue->statements), &(statement->value.statementValue->statement));
866 } 878 }
@@ -928,6 +940,12 @@ LSL_Leaf *beginBlock(LuaSL_compiler *compiler, LSL_Leaf *block)
928 eina_clist_init(&(blok->statements)); 940 eina_clist_init(&(blok->statements));
929 blok->variables = eina_hash_stringshared_new(burnLeaf); 941 blok->variables = eina_hash_stringshared_new(burnLeaf);
930 block->value.blockValue = blok; 942 block->value.blockValue = blok;
943 if ((NULL == compiler->currentBlock) && (NULL == compiler->currentFunction))
944 {
945 compiler->inState = TRUE;
946 compiler->state.block=blok;
947 compiler->state.handlers = eina_hash_stringshared_new(free);
948 }
931 blok->outerBlock = compiler->currentBlock; 949 blok->outerBlock = compiler->currentBlock;
932 compiler->currentBlock = blok; 950 compiler->currentBlock = blok;
933 blok->function = compiler->currentFunction; 951 blok->function = compiler->currentFunction;