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
2fb3c978
Commit
2fb3c978
authored
5 years ago
by
pycsham
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of
https://git.uwaterloo.ca/x299yang/cs444
parents
8f2b5dcc
8c9f9e70
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
MemberNodes.py
+22
-0
22 additions, 0 deletions
MemberNodes.py
NameNode.py
+3
-0
3 additions, 0 deletions
NameNode.py
with
25 additions
and
0 deletions
MemberNodes.py
+
22
−
0
View file @
2fb3c978
...
...
@@ -139,6 +139,13 @@ class MethodNode(ASTNode):
if
not
self
.
body
:
return
# check no use of this in static method
if
'
static
'
in
self
.
mods
:
names
=
getNameNodes
(
self
.
body
)
for
n
in
names
:
if
'
this
'
in
n
.
name
or
(
n
.
pointToThis
and
n
.
prefixLink
.
__class__
.
__name__
==
[
'
MethodNode
'
,
'
FieldNode
'
]
and
'
static
'
not
in
n
.
prefixLink
.
mods
):
raise
Exception
(
"
ERROR: Cannot use non-static member {} in static method {} in class {}
"
.
format
(
n
.
name
,
self
.
name
,
self
.
typeName
))
# With method body
returnNodes
=
getASTNode
([
"
ReturnNode
"
],
self
.
body
)
...
...
@@ -177,3 +184,18 @@ def getForwardRefNames(node):
result
.
extend
(
getForwardRefNames
(
c
))
return
result
# Input: AST Node
# Output: A list of names to be check
def
getNameNodes
(
node
):
if
not
node
:
return
[]
if
node
.
__class__
.
__name__
==
'
NameNode
'
:
return
[
node
]
result
=
[]
for
c
in
node
.
children
:
result
.
extend
(
getNameNodes
(
c
))
return
result
This diff is collapsed.
Click to expand it.
NameNode.py
+
3
−
0
View file @
2fb3c978
...
...
@@ -34,6 +34,7 @@ class NameNode(ASTNode):
self
.
children
=
[]
self
.
myType
=
None
# will become TypeStruct to tell us what the whole is/returns
self
.
shouldBeStatic
=
False
self
.
pointToThis
=
False
self
.
name
=
getParseTreeNodes
([
"
ID
"
,
"
COMPID
"
],
parseTree
)[
0
].
lex
...
...
@@ -170,6 +171,7 @@ class NameNode(ASTNode):
def
disambigName
(
self
):
# Checking if a1 is "this"
if
self
.
checkThis
():
self
.
pointToThis
=
True
return
# Checking if a1 is length
...
...
@@ -182,6 +184,7 @@ class NameNode(ASTNode):
# Checking if a1 is in contains set
if
self
.
checkContains
():
self
.
pointToThis
=
True
return
...
...
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