Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
magicseteditor
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
magicseteditor
Commits
4adf0c46
Commit
4adf0c46
authored
Aug 05, 2008
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed bug in dependency checker that caused it to overwrite variables outside its scope
parent
9c763a82
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
7 deletions
+20
-7
src/script/context.cpp
src/script/context.cpp
+10
-0
src/script/context.hpp
src/script/context.hpp
+5
-1
src/script/dependency.cpp
src/script/dependency.cpp
+5
-6
No files found.
src/script/context.cpp
View file @
4adf0c46
...
...
@@ -265,12 +265,22 @@ ScriptValueP Context::makeClosure(const ScriptValueP& fun) {
size_t
Context
::
openScope
()
{
level
+=
1
;
#ifdef _DEBUG
scopes
.
push_back
(
shadowed
.
size
());
assert
(
scopes
.
size
()
==
level
);
#endif
return
shadowed
.
size
();
}
void
Context
::
closeScope
(
size_t
scope
)
{
assert
(
level
>
0
);
assert
(
scope
<=
shadowed
.
size
());
level
-=
1
;
#ifdef _DEBUG
assert
(
!
scopes
.
empty
());
assert
(
scopes
.
back
()
==
scope
);
scopes
.
pop_back
();
assert
(
scopes
.
size
()
==
level
);
#endif
// restore shadowed variables
while
(
shadowed
.
size
()
>
scope
)
{
variables
[
shadowed
.
back
().
variable
]
=
shadowed
.
back
().
value
;
...
...
src/script/context.hpp
View file @
4adf0c46
...
...
@@ -102,7 +102,11 @@ class Context {
/// Number of scopes opened
unsigned
int
level
;
/// Stack of values
vector
<
ScriptValueP
>
stack
;
vector
<
ScriptValueP
>
stack
;
#ifdef _DEBUG
/// The opened scopes, for sanity checking
vector
<
size_t
>
scopes
;
#endif
// utility types for dependency analysis
struct
Jump
;
...
...
src/script/dependency.cpp
View file @
4adf0c46
...
...
@@ -159,7 +159,7 @@ ScriptValueP Context::dependencies(const Dependency& dep, const Script& script)
}
// unify bindings
FOR_EACH
(
v
,
j
->
bindings
)
{
unify
(
variables
[
v
.
variable
].
value
,
v
.
value
.
value
);
setVariable
(
v
.
variable
,
unified
(
variables
[
v
.
variable
].
value
,
v
.
value
.
value
)
);
}
delete
j
;
}
...
...
@@ -368,9 +368,8 @@ void Context::getBindings(size_t scope, vector<Binding>& bindings) {
}
void
Context
::
resetBindings
(
size_t
scope
)
{
// same as closeScope()
while
(
shadowed
.
size
()
>
scope
)
{
variables
[
shadowed
.
back
().
variable
]
=
shadowed
.
back
().
value
;
shadowed
.
pop_back
();
}
// close and re-open the scope
closeScope
(
scope
);
size_t
same_scope
=
openScope
();
assert
(
scope
==
same_scope
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment