Skip to content

Commit 2b12beb

Browse files
committed
Replaced local()/global() pseudo-functions with local/global pseudo-dictionaries.
1 parent 03b9654 commit 2b12beb

File tree

6 files changed

+232
-227
lines changed

6 files changed

+232
-227
lines changed

changes.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ New Features
5656
- A new data container, `dictionary`, has been added to support structured
5757
storage of data.
5858

59+
- Pseudo-dictionaries `local` and `global` have been added, allowing to
60+
specifically access local or global identifiers, respectively.
61+
5962
- A new pattern, `potential`, has been added to define a pattern based on the
6063
potential field of a blob or isosurface object.
6164

@@ -93,9 +96,6 @@ New Features
9396
assignments. The main purpose is to allow macros to return a set of values
9497
rather than just a single one.
9598

96-
- `local()` and `global()` pseudo-functions have been added to specifically
97-
refer to a local or global identifier, respectively.
98-
9999
- The macro syntax has been extended to allow for optional parameters.
100100

101101
- Light sources' distance-based fading can now be set to obey an inverse-power

source/base/version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
#define OFFICIAL_VERSION_STRING "3.7.1"
4646
#define OFFICIAL_VERSION_NUMBER 371
4747

48-
#define POV_RAY_PRERELEASE "x.dictionary.8877243"
48+
#define POV_RAY_PRERELEASE "x.dictionary.8884653"
4949

5050
#if (POV_RAY_IS_AUTOBUILD == 1) && ((POV_RAY_IS_OFFICIAL == 1) || (POV_RAY_IS_SEMI_OFFICIAL == 1))
5151
#ifdef POV_RAY_PRERELEASE

source/parser/parser.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,12 +198,12 @@ void Parser::Run()
198198
if(i->second[0] == '\"')
199199
{
200200
string tmp(i->second, 1, i->second.length() - 2);
201-
Temp_Entry = Add_Symbol(1, const_cast<char *>(i->first.c_str()), STRING_ID_TOKEN);
201+
Temp_Entry = Add_Symbol(SYM_TABLE_GLOBAL, const_cast<char *>(i->first.c_str()), STRING_ID_TOKEN);
202202
Temp_Entry->Data = String_Literal_To_UCS2(const_cast<char *>(tmp.c_str()), false);
203203
}
204204
else
205205
{
206-
Temp_Entry = Add_Symbol(1, const_cast<char *>(i->first.c_str()), FLOAT_ID_TOKEN);
206+
Temp_Entry = Add_Symbol(SYM_TABLE_GLOBAL, const_cast<char *>(i->first.c_str()), FLOAT_ID_TOKEN);
207207
Temp_Entry->Data = Create_Float();
208208
*(reinterpret_cast<DBL *>(Temp_Entry->Data)) = atof(i->second.c_str());
209209
}
@@ -8611,7 +8611,7 @@ void Parser::Parse_Declare(bool is_local, bool after_hash)
86118611
}
86128612
else
86138613
{
8614-
Local_Index=1;
8614+
Local_Index = SYM_TABLE_GLOBAL;
86158615
}
86168616

86178617
LValue_Ok = true;

source/parser/parser.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@ const int SYM_TABLE_SIZE = 257;
8686
typedef struct Sym_Table_Entry SYM_ENTRY;
8787
typedef unsigned short SymTableEntryRefCount;
8888

89+
// Special symbol tables
90+
enum {
91+
SYM_TABLE_RESERVED = 0, // reserved words
92+
SYM_TABLE_GLOBAL, // identifiers declared using #declare (or #local in top-level file), #function, #macro, etc.
93+
};
94+
8995
/// Structure holding information about a symbol
9096
struct Sym_Table_Entry
9197
{
@@ -296,13 +302,6 @@ class Parser : public SceneTask
296302
bool R_Flag : 1;
297303
};
298304

299-
enum IdentifierMode
300-
{
301-
kIdentifierModeUndefined,
302-
kIdentifierModeLocal,
303-
kIdentifierModeGlobal,
304-
};
305-
306305
// constructor
307306
Parser(shared_ptr<BackendSceneData> sd, bool useclock, DBL clock);
308307

@@ -592,7 +591,6 @@ class Parser : public SceneTask
592591
CS_ENTRY *Cond_Stack;
593592
int CS_Index;
594593
bool Skipping, Inside_Ifdef, Inside_MacroDef, Parsing_Directive, parseRawIdentifiers;
595-
IdentifierMode Inside_IdentFn;
596594

597595
int Got_EOF; // WARNING: Changes to the use of this variable are very dangerous as it is used in many places assuming certain non-obvious side effects! [trf]
598596

0 commit comments

Comments
 (0)