Commit af8bfabb authored by Sebastian Biewer's avatar Sebastian Biewer
Browse files

See Changelog

parent 1fe659c4
# Change Log for PseuCo Language
## 0.9.1 - 2021-01-26
### Changed
- Detect and reject nested procedure declarations.
### Fixed
- Potentially incorrect type checking after redeclaration of procedures.
## 0.9.0 - 2020-10-27
### Added
- Support for assertions via `assert(<boolean expression>)`.
## 0.8.5 - 2020-06-04
### Fixed
......
......@@ -62,6 +62,9 @@ class PCTEnvironmentController
getGlobal: -> @root
getStackState: -> @_envStack
restoreStackState: (stackState) -> @_envStack = stackState
openEnvironment: (node) ->
node.__id = @blockCounter++
child = new PCTEnvironmentNode(node, "##{node.__id}")
......@@ -137,12 +140,14 @@ class PCTEnvironmentController
beginNewProcedure: (node, procedureName, returnType, args) ->
tnode = new PCTProcedure(node, procedureName, returnType, args)
@_beginNewProcedure(tnode)
_beginNewProcedure: (node) ->
try
@_envStack.getProcedureWithName(node.getName())
catch
@_envStack.addChild(node)
if node.isNestedProcedure()
throw ({"line" : node.node.line, "column" : node.node.column, "wholeFile" : false, "name" : "Nested Procedure", "message" : "Nested procedures are not allowed! You can define procedures globally or in monitors or structs."})
@beginProcedure(node.getName())
return
throw ({"line" : 0, "column" : 0, "wholeFile" : false, "name" : "Redeclaration", "message" : "Procedure #{node.getName()} already declared!"})
......@@ -253,6 +258,8 @@ class PCTEnvironmentNode
else
throw ({"line" : 0, "column" : 0, "wholeFile" : false, "name" : "InvalidLocation", "message" : "Return statements are only allowed inside procedures!"})
isDescendantOfProcedure: -> @parent?.isDescendantOfProcedure()
isReturnExhaustive: -> @isRetExhaust
setReturnExhaustive: -> @isRetExhaust = true
......@@ -290,6 +297,10 @@ class PCTProcedure extends PCTEnvironmentNode
getName: -> @label
isDescendantOfProcedure: -> true
isNestedProcedure: -> @parent.isDescendantOfProcedure()
isClassProcedure: -> @parent instanceof PCTClass
isMonitorProcedure: -> @parent instanceof PCTClass and @parent.isMonitor()
......
......@@ -167,10 +167,12 @@ class PCProgram extends PCNode
collectClasses: (env) ->
for c in @children
stackState = env.getStackState()
try
c.collectClasses(env)
catch e
if e and e.wholeFile?
env.restoreStackState stackState
PCErrorList.push e
else
throw e
......@@ -178,10 +180,12 @@ class PCProgram extends PCNode
collectEnvironment: (env) ->
@globalDeclarations(env)
for c in @children
stackState = env.getStackState()
try
c.collectEnvironment(env)
catch e
if e and e.wholeFile?
env.restoreStackState stackState
PCErrorList.push e
else
throw e
......@@ -190,10 +194,12 @@ class PCProgram extends PCNode
_collectEnvironment: (env) ->
@globalDeclarations(env)
for child in @children
stackState = env.getStackState()
try
child._collectEnvironment(env)
catch e
if e and e.wholeFile?
env.restoreStackState stackState
PCErrorList.push e
else
throw e
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment