Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cs444
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Xun Yang
cs444
Commits
a41f5afb
Commit
a41f5afb
authored
5 years ago
by
pycsham
Browse files
Options
Downloads
Patches
Plain Diff
fixed a small bug for checking double local var declaration
parent
3c42d6f8
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Environment.py
+17
-9
17 additions, 9 deletions
Environment.py
Test.py
+2
-0
2 additions, 0 deletions
Test.py
with
19 additions
and
9 deletions
Environment.py
+
17
−
9
View file @
a41f5afb
...
...
@@ -51,14 +51,15 @@ class Env:
return
self
.
parentEnv
.
getNode
(
name
,
namespace
)
raise
Exception
(
"
ERROR: Can
'
t find definition of {} in the Environment
"
.
format
(
name
))
# A wrapper around getNode to find if node exists in environment already
# A wrapper around getNode to find if node exists in environment already
. Terminates before reaching the global Env (see compEnv implementation)
def
findNode
(
self
,
name
,
namespace
):
try
:
self
.
getNode
(
name
,
namespace
)
except
:
return
False
# node is not found in environment
return
True
key
=
(
name
,
namespace
)
if
key
in
self
.
map
:
return
True
elif
self
.
parentEnv
:
return
self
.
parentEnv
.
findNode
(
name
,
namespace
)
return
False
###################################
...
...
@@ -124,7 +125,7 @@ class GlobalEnv(Env):
return
self
.
map
.
get
(
name
)
elif
(
i
+
name
)
in
self
.
map
:
return
self
.
map
.
get
(
i
+
name
)
raise
Exception
(
"
ERROR: Can
'
t find definition of {} in the Environment
"
.
format
(
key
))
# method for getting all the nodes under a package (import All)
...
...
@@ -149,4 +150,11 @@ class CompEnv(Env):
return
self
.
map
.
get
(
key
)
elif
self
.
parentEnv
:
# globalEnv
return
self
.
parentEnv
.
getNode
(
key
,
self
.
imported
,
self
.
packageName
)
raise
Exception
(
"
ERROR: Can
'
t find definition of {} in the Environment
"
.
format
(
name
))
\ No newline at end of file
raise
Exception
(
"
ERROR: Can
'
t find definition of {} in the Environment
"
.
format
(
name
))
def
findNode
(
self
,
name
,
namespace
):
key
=
(
name
,
namespace
)
if
key
in
self
.
map
:
return
True
else
:
return
False
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Test.py
+
2
−
0
View file @
a41f5afb
...
...
@@ -69,6 +69,8 @@ def run(testFiles):
for
f
in
testFiles
:
# print(f)
if
f
.
split
(
"
/
"
)[
-
1
]
==
"
.DS_Store
"
:
continue
content
=
open
(
f
,
"
r
"
).
read
()
# Scanning
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment