| 893 | } |
| 894 | |
| 895 | void ScriptCompiler::processVariables( Ogre::AbstractNodeList *nodes ) |
| 896 | { |
| 897 | AbstractNodeList::iterator i = nodes->begin(); |
| 898 | while( i != nodes->end() ) |
| 899 | { |
| 900 | AbstractNodeList::iterator cur = i; |
| 901 | ++i; |
| 902 | |
| 903 | if( ( *cur )->type == ANT_OBJECT ) |
| 904 | { |
| 905 | // Only process if this object is not abstract |
| 906 | ObjectAbstractNode *obj = (ObjectAbstractNode *)( *cur ).get(); |
| 907 | if( !obj->abstract ) |
| 908 | { |
| 909 | processVariables( &obj->children ); |
| 910 | processVariables( &obj->values ); |
| 911 | } |
| 912 | } |
| 913 | else if( ( *cur )->type == ANT_PROPERTY ) |
| 914 | { |
| 915 | PropertyAbstractNode *prop = (PropertyAbstractNode *)( *cur ).get(); |
| 916 | processVariables( &prop->values ); |
| 917 | } |
| 918 | else if( ( *cur )->type == ANT_VARIABLE_ACCESS ) |
| 919 | { |
| 920 | VariableAccessAbstractNode *var = (VariableAccessAbstractNode *)( *cur ).get(); |
| 921 | |
| 922 | // Look up the enclosing scope |
| 923 | ObjectAbstractNode *scope = 0; |
| 924 | AbstractNode *temp = var->parent; |
| 925 | while( temp ) |
| 926 | { |
| 927 | if( temp->type == ANT_OBJECT ) |
| 928 | { |
| 929 | scope = (ObjectAbstractNode *)temp; |
| 930 | break; |
| 931 | } |
| 932 | temp = temp->parent; |
| 933 | } |
| 934 | |
| 935 | // Look up the variable in the environment |
| 936 | std::pair<bool, String> varAccess; |
| 937 | if( scope ) |
| 938 | varAccess = scope->getVariable( var->name ); |
| 939 | if( !scope || !varAccess.first ) |
| 940 | { |
| 941 | map<String, String>::type::iterator k = mEnv.find( var->name ); |
| 942 | varAccess.first = k != mEnv.end(); |
| 943 | if( varAccess.first ) |
| 944 | varAccess.second = k->second; |
| 945 | } |
| 946 | |
| 947 | if( varAccess.first ) |
| 948 | { |
| 949 | // Found the variable, so process it and insert it into the tree |
| 950 | ScriptLexer lexer; |
| 951 | ScriptParser parser; |
| 952 | ConcreteNodeListPtr cst = |
nothing calls this directly
no test coverage detected