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
703755da
Commit
703755da
authored
5 years ago
by
pycsham
Browse files
Options
Downloads
Patches
Plain Diff
Fixed issues with return statements in methods and also an AST building issue at if Nodes
parent
08e2af84
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
LineNodes.py
+1
-1
1 addition, 1 deletion
LineNodes.py
MemberNodes.py
+1
-10
1 addition, 10 deletions
MemberNodes.py
with
2 additions
and
11 deletions
LineNodes.py
+
1
−
1
View file @
703755da
...
...
@@ -179,7 +179,7 @@ class IfNode(ASTNode):
self
.
ifConditional
=
makeNodeFromExpr
(
parseTree
.
children
[
2
],
typeName
)
self
.
ifBody
=
makeNodeFromAllStatement
(
parseTree
.
children
[
4
],
typeName
)
if
parseTree
.
name
==
'
ifElseStatement
'
:
if
parseTree
.
name
==
'
ifElseStatement
'
or
parseTree
.
name
==
"
ifElseStatementNoShortIf
"
:
self
.
elseBody
=
makeNodeFromAllStatement
(
parseTree
.
children
[
6
],
typeName
)
self
.
children
.
append
(
self
.
ifConditional
)
...
...
This diff is collapsed.
Click to expand it.
MemberNodes.py
+
1
−
10
View file @
703755da
...
...
@@ -150,17 +150,10 @@ class MethodNode(ASTNode):
# With method body
returnNodes
=
getASTNode
([
"
ReturnNode
"
],
self
.
body
)
# Checking for cases where there are no return statements
if
not
returnNodes
:
# Either a constructor or the function has type Void
if
not
self
.
methodType
or
self
.
myType
.
name
==
"
void
"
:
return
raise
Exception
(
"
ERROR: no return statement at function {}
"
.
format
(
self
.
name
))
# Checking for cases where there are return statements
for
n
in
returnNodes
:
# Checking for functions of type void
# Only valid if either the function doesn't have a return statement
(checked above)
, or the return statement is a semicolon (return;)
# Only valid if either the function doesn't have a return statement, or the return statement is a semicolon (return;)
if
self
.
myType
and
self
.
myType
.
name
==
"
void
"
:
if
n
.
myType
:
raise
Exception
(
"
ERROR: return type of function {} doesn
'
t match with return statement.
"
.
format
(
self
.
name
))
...
...
@@ -174,11 +167,9 @@ class MethodNode(ASTNode):
self
.
outMaybe
=
False
# Check reachability of method body
# No need to check for empty function body, since the check is done in checkType
if
self
.
body
:
self
.
body
.
reachCheck
(
True
)
# For method bodies, in[L] = maybe by default
self
.
outMaybe
=
self
.
body
.
outMaybe
# Check if out[method body] is a maybe for non-void methods
if
not
self
.
methodType
or
self
.
myType
.
name
==
"
void
"
:
# Omitting the check for constructors and void functions
...
...
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