@@ -8662,7 +8662,14 @@ void Parser::Parse_Declare(bool is_local, bool after_hash)
86628662 CASE (IDENTIFIER_TOKEN)
86638663 POV_PARSER_ASSERT (!Token.is_array_elem );
86648664 allow_redefine = true ; // should actually be irrelevant downstream, thanks to Previous==IDENTIFIER_TOKEN
8665- Temp_Entry = Add_Symbol (Local_Index,Token.Token_String ,IDENTIFIER_TOKEN);
8665+ if (Token.is_dictionary_elem )
8666+ {
8667+ if (is_local && (Token.context != Table_Index))
8668+ Error (" Cannot use '#local' to assign a non-local array or dictionary element." );
8669+ Temp_Entry = Add_Symbol (Token.table , Token.Token_String , IDENTIFIER_TOKEN);
8670+ }
8671+ else
8672+ Temp_Entry = Add_Symbol (Local_Index, Token.Token_String , IDENTIFIER_TOKEN);
86668673 numberPtr = &(Temp_Entry->Token_Number );
86678674 dataPtr = &(Temp_Entry->Data );
86688675 Previous = Token.Token_Id ;
@@ -8700,11 +8707,11 @@ void Parser::Parse_Declare(bool is_local, bool after_hash)
87008707 CASE4 (PIGMENT_MAP_ID_TOKEN, MEDIA_ID_TOKEN, STRING_ID_TOKEN, INTERIOR_ID_TOKEN)
87018708 CASE4 (DENSITY_MAP_ID_TOKEN, ARRAY_ID_TOKEN, DENSITY_ID_TOKEN, UV_ID_TOKEN)
87028709 CASE4 (VECTOR_4D_ID_TOKEN, RAINBOW_ID_TOKEN, FOG_ID_TOKEN, SKYSPHERE_ID_TOKEN)
8703- CASE2 (MATERIAL_ID_TOKEN, SPLINE_ID_TOKEN )
8704- if (is_local && (Token.Table_Index != Table_Index))
8710+ CASE3 (MATERIAL_ID_TOKEN, SPLINE_ID_TOKEN, DICTIONARY_ID_TOKEN )
8711+ if (is_local && (Token.context != Table_Index))
87058712 {
8706- if (Token.is_array_elem )
8707- Error (" Cannot use '#local' to assign a non-local array element." );
8713+ if (Token.is_array_elem || Token. is_dictionary_elem )
8714+ Error (" Cannot use '#local' to assign a non-local array or dictionary element." );
87088715 allow_redefine = true ; // should actually be irrelevant downstream, thanks to Previous==IDENTIFIER_TOKEN
87098716 Temp_Entry = Add_Symbol (Local_Index,Token.Token_String ,IDENTIFIER_TOKEN);
87108717 numberPtr = &(Temp_Entry->Token_Number );
@@ -8733,10 +8740,10 @@ void Parser::Parse_Declare(bool is_local, bool after_hash)
87338740 {
87348741 case VECTOR_ID_TOKEN:
87358742 case FLOAT_ID_TOKEN:
8736- if (is_local && (Token.Table_Index != Table_Index))
8743+ if (is_local && (Token.context != Table_Index))
87378744 {
8738- if (Token.is_array_elem )
8739- Error (" Cannot use '#local' to assign a non-local array element." );
8745+ if (Token.is_array_elem || Token. is_dictionary_elem )
8746+ Error (" Cannot use '#local' to assign a non-local array or dictionary element." );
87408747 allow_redefine = true ; // should actually be irrelevant downstream, thanks to Previous==IDENTIFIER_TOKEN
87418748 Temp_Entry = Add_Symbol (Local_Index,Token.Token_String ,IDENTIFIER_TOKEN);
87428749 numberPtr = &(Temp_Entry->Token_Number );
@@ -8766,7 +8773,7 @@ void Parser::Parse_Declare(bool is_local, bool after_hash)
87668773 // the resulting value.
87678774 // We do this by assigning the resulting value to a dummy symbol entry.
87688775 allow_redefine = true ; // should actually be irrelevant downstream, thanks to Previous=IDENTIFIER_TOKEN
8769- Temp_Entry = Create_Entry (0 , " " , DUMMY_SYMBOL_TOKEN);
8776+ Temp_Entry = Create_Entry (" " , DUMMY_SYMBOL_TOKEN, false );
87708777 numberPtr = &(Temp_Entry->Token_Number );
87718778 dataPtr = &(Temp_Entry->Data );
87728779 optional = true ;
@@ -8853,7 +8860,7 @@ void Parser::Parse_Declare(bool is_local, bool after_hash)
88538860 }
88548861 else if (larrayDeclare)
88558862 {
8856- SYM_ENTRY *rvalue = Create_Entry (0 , " " , DUMMY_SYMBOL_TOKEN);
8863+ SYM_ENTRY *rvalue = Create_Entry (" " , DUMMY_SYMBOL_TOKEN, false );
88578864 if (!Parse_RValue (IDENTIFIER_TOKEN, &(rvalue->Token_Number ), &(rvalue->Data ), NULL , false , false , true , true , false , MAX_NUMBER_OF_TABLES) ||
88588865 (rvalue->Token_Number != ARRAY_ID_TOKEN))
88598866 Expectation_Error (" array RValue" );
@@ -8879,7 +8886,7 @@ void Parser::Parse_Declare(bool is_local, bool after_hash)
88798886 *dataPtr = Copy_Identifier (a->DataPtrs [i], a->Type );
88808887 }
88818888
8882- Destroy_Entry (0 , rvalue );
8889+ Destroy_Entry (rvalue, false );
88838890 }
88848891 else
88858892 {
@@ -8944,7 +8951,7 @@ void Parser::Parse_Declare(bool is_local, bool after_hash)
89448951 for (vector<LValue>::iterator i = lvalues.begin (); i != lvalues.end (); ++i)
89458952 {
89468953 if ((i->symEntry != NULL ) && (i->symEntry ->Token_Number == DUMMY_SYMBOL_TOKEN))
8947- Destroy_Entry (0 , i->symEntry );
8954+ Destroy_Entry (i->symEntry , false );
89488955 }
89498956
89508957 if ( after_hash )
@@ -8955,6 +8962,18 @@ void Parser::Parse_Declare(bool is_local, bool after_hash)
89558962 }
89568963}
89578964
8965+ bool Parser::PassParameterByReference (int callingContext)
8966+ {
8967+ if (Token.is_dictionary_elem )
8968+ {
8969+ return true ;
8970+ }
8971+ else
8972+ {
8973+ return (Token.context <= callingContext);
8974+ }
8975+ }
8976+
89588977bool Parser::Parse_RValue (int Previous, int *NumberPtr, void **DataPtr, SYM_ENTRY *sym, bool ParFlag, bool SemiFlag, bool is_local, bool allow_redefine, bool allowUndefined, int old_table_index)
89598978{
89608979 EXPRESS Local_Express;
@@ -8987,14 +9006,13 @@ bool Parser::Parse_RValue (int Previous, int *NumberPtr, void **DataPtr, SYM_ENT
89879006 CASE4 (SLOPE_MAP_ID_TOKEN,NORMAL_MAP_ID_TOKEN,TEXTURE_MAP_ID_TOKEN,ARRAY_ID_TOKEN)
89889007 CASE4 (PIGMENT_MAP_ID_TOKEN, MEDIA_ID_TOKEN,INTERIOR_ID_TOKEN,DENSITY_ID_TOKEN)
89899008 CASE4 (DENSITY_MAP_ID_TOKEN, RAINBOW_ID_TOKEN, FOG_ID_TOKEN, SKYSPHERE_ID_TOKEN)
8990- CASE2 (MATERIAL_ID_TOKEN, STRING_ID_TOKEN)
8991- if ((ParFlag) && (Token. Table_Index <= old_table_index))
9009+ CASE3 (MATERIAL_ID_TOKEN, STRING_ID_TOKEN, DICTIONARY_ID_TOKEN )
9010+ if ((ParFlag) && PassParameterByReference ( old_table_index))
89929011 {
89939012 // pass by reference
89949013 New_Par = reinterpret_cast <POV_PARAM *>(POV_MALLOC (sizeof (POV_PARAM)," parameter" ));
89959014 New_Par->NumberPtr = Token.NumberPtr ;
89969015 New_Par->DataPtr = Token.DataPtr ;
8997- New_Par->Table_Index = Token.Table_Index ;
89989016 *NumberPtr = PARAMETER_ID_TOKEN;
89999017 *DataPtr = reinterpret_cast <void *>(New_Par);
90009018 }
@@ -9078,7 +9096,7 @@ bool Parser::Parse_RValue (int Previous, int *NumberPtr, void **DataPtr, SYM_ENT
90789096 if ((Token.Token_Id ==FUNCT_ID_TOKEN) || (Token.Token_Id ==VECTFUNCT_ID_TOKEN) || (Token.Token_Id ==SPLINE_ID_TOKEN) ||
90799097 (Token.Token_Id ==UV_ID_TOKEN) || (Token.Token_Id ==VECTOR_4D_ID_TOKEN) || (Token.Token_Id ==COLOUR_ID_TOKEN))
90809098 {
9081- symbol_entry = Find_Symbol (Token.Table_Index , Token.Token_String );
9099+ symbol_entry = Find_Symbol (Token.table , Token.Token_String );
90829100 if (symbol_entry)
90839101 Acquire_Entry_Reference (symbol_entry);
90849102 }
@@ -9102,7 +9120,7 @@ bool Parser::Parse_RValue (int Previous, int *NumberPtr, void **DataPtr, SYM_ENT
91029120 Error (" Identifier expected, incomplete function call or spline call found instead." );
91039121
91049122 // only one identifier token has been found so pass it by reference
9105- if (((Temp_Count==-1 ) || (Temp_Count==TOKEN_OVERFLOW_RESET_COUNT)) && (Token. Table_Index <= old_table_index))
9123+ if (((Temp_Count==-1 ) || (Temp_Count==TOKEN_OVERFLOW_RESET_COUNT)) && PassParameterByReference ( old_table_index))
91069124 {
91079125 // It is important that functions are passed by value and not by reference! [trf]
91089126 if (!(ParFlag) || (ParFlag && function_identifier))
@@ -9119,7 +9137,6 @@ bool Parser::Parse_RValue (int Previous, int *NumberPtr, void **DataPtr, SYM_ENT
91199137 New_Par = reinterpret_cast <POV_PARAM *>(POV_MALLOC (sizeof (POV_PARAM)," parameter" ));
91209138 New_Par->NumberPtr = Token.NumberPtr ;
91219139 New_Par->DataPtr = Token.DataPtr ;
9122- New_Par->Table_Index = Token.Table_Index ;
91239140
91249141 *NumberPtr = PARAMETER_ID_TOKEN;
91259142 *DataPtr = reinterpret_cast <void *>(New_Par);
@@ -9164,7 +9181,7 @@ bool Parser::Parse_RValue (int Previous, int *NumberPtr, void **DataPtr, SYM_ENT
91649181 }
91659182 }
91669183 if (symbol_entry)
9167- Release_Entry_Reference (Token.Table_Index , symbol_entry);
9184+ Release_Entry_Reference (Token.table , symbol_entry);
91689185
91699186 // allow #declares again
91709187 Ok_To_Declare = true ;
@@ -9407,6 +9424,14 @@ bool Parser::Parse_RValue (int Previous, int *NumberPtr, void **DataPtr, SYM_ENT
94079424 EXIT
94089425 END_CASE
94099426
9427+ CASE (DICTIONARY_TOKEN)
9428+ Temp_Data = reinterpret_cast <void *>(Create_Sym_Table (true ));
9429+ *NumberPtr = DICTIONARY_ID_TOKEN;
9430+ Test_Redefine (Previous,NumberPtr,*DataPtr, allow_redefine);
9431+ *DataPtr = Temp_Data;
9432+ EXIT
9433+ END_CASE
9434+
94109435 OTHERWISE
94119436 UNGET
94129437 Local_Object = Parse_Object ();
@@ -9527,6 +9552,9 @@ void Parser::Destroy_Ident_Data(void *Data, int Type)
95279552 }
95289553 POV_FREE (a);
95299554 break ;
9555+ case DICTIONARY_ID_TOKEN:
9556+ Destroy_Sym_Table (reinterpret_cast <SYM_TABLE *>(Data));
9557+ break ;
95309558 case PARAMETER_ID_TOKEN:
95319559 POV_FREE (Data);
95329560 break ;
@@ -10602,6 +10630,9 @@ void *Parser::Copy_Identifier (void *Data, int Type)
1060210630 }
1060310631 New = reinterpret_cast <void *>(na);
1060410632 break ;
10633+ case DICTIONARY_ID_TOKEN:
10634+ New = reinterpret_cast <void *>(Copy_Sym_Table (reinterpret_cast <SYM_TABLE *>(Data)));
10635+ break ;
1060510636 case FUNCT_ID_TOKEN:
1060610637 case VECTFUNCT_ID_TOKEN:
1060710638 New = reinterpret_cast <void *>(fnVMContext->functionvm ->CopyFunction ((FUNCTION_PTR )Data));
0 commit comments