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
bf32e63a
Commit
bf32e63a
authored
5 years ago
by
pycsham
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of
https://git.uwaterloo.ca/x299yang/cs444
parents
4d26654c
5241f0bc
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
ExprPrimaryNodes.py
+5
-0
5 additions, 0 deletions
ExprPrimaryNodes.py
NameNode.py
+8
-2
8 additions, 2 deletions
NameNode.py
with
13 additions
and
2 deletions
ExprPrimaryNodes.py
+
5
−
0
View file @
bf32e63a
...
...
@@ -484,6 +484,11 @@ class MethodInvNode(ASTNode):
from
pprint
import
pprint
if
m
:
if
self
.
ID
.
shouldBeStatic
and
(
not
'
static
'
in
m
.
mods
):
raise
Exception
(
"
ERROR: Static access of non-static method {}.
"
.
format
(
m
.
name
))
if
(
not
self
.
ID
.
shouldBeStatic
)
and
'
static
'
in
m
.
mods
:
raise
Exception
(
"
ERROR: Non-static access of static method {}.
"
.
format
(
m
.
name
))
self
.
method
=
m
self
.
myType
=
m
.
methodType
.
myType
return
...
...
This diff is collapsed.
Click to expand it.
NameNode.py
+
8
−
2
View file @
bf32e63a
...
...
@@ -33,6 +33,7 @@ class NameNode(ASTNode):
self
.
typeName
=
typeName
# the name of the class or interface that this node belongs under
self
.
children
=
[]
self
.
myType
=
None
# will become TypeStruct to tell us what the whole is/returns
self
.
shouldBeStatic
=
False
self
.
name
=
getParseTreeNodes
([
"
ID
"
,
"
COMPID
"
],
parseTree
)[
0
].
lex
...
...
@@ -119,11 +120,11 @@ class NameNode(ASTNode):
typeFieldNode
=
typeNode
.
env
.
getNode
(
staticFieldName
,
"
fieldDcl
"
)
if
"
static
"
in
typeFieldNode
.
mods
:
self
.
prefixLink
=
typeFieldNode
.
variableDcl
# if it is primitive, then we leave it as a VarDclNode
if
not
self
.
prefixLink
.
dclType
.
myType
.
isPrimitive
:
self
.
prefixLink
=
self
.
prefixLink
.
dclType
.
myType
.
typePointer
self
.
prefix
=
currPrefix
+
"
.
"
+
staticFieldName
self
.
IDs
=
self
.
IDs
[
index
+
2
:]
return
True
...
...
@@ -160,6 +161,7 @@ class NameNode(ASTNode):
# Checking if the shortest prefix is a static field
if
self
.
checkStatic
():
self
.
shouldBeStatic
=
True
return
raise
Exception
(
"
ERROR at disambiguating namespace: no prefix of name {} is found in environment.
"
.
format
(
self
.
name
))
...
...
@@ -193,6 +195,10 @@ class NameNode(ASTNode):
else
:
curType
=
curType
.
env
.
getNode
(
self
.
IDs
[
0
],
'
fieldDcl
'
)
# at this stage, all newly resolved field should be non static:
if
curType
.
__class__
.
__name__
==
'
FieldNode
'
and
'
static
'
in
curType
.
mods
:
raise
Exception
(
"
ERROR: Non-static access of static field {}
"
.
format
(
curType
.
name
))
self
.
prefix
=
self
.
prefix
+
"
.
"
+
self
.
IDs
[
0
]
self
.
IDs
.
pop
(
0
)
...
...
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