Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tla2bAST
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
general
stups
tla2bAST
Commits
d43d54a0
Commit
d43d54a0
authored
6 months ago
by
Jan Gruteser
Browse files
Options
Downloads
Patches
Plain Diff
minor changes and comments in SpecAnalyser
parent
8c8f4ae7
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/de/tla2b/analysis/SpecAnalyser.java
+14
-9
14 additions, 9 deletions
src/main/java/de/tla2b/analysis/SpecAnalyser.java
with
14 additions
and
9 deletions
src/main/java/de/tla2b/analysis/SpecAnalyser.java
+
14
−
9
View file @
d43d54a0
...
@@ -89,7 +89,7 @@ public class SpecAnalyser extends BuiltInOPs {
...
@@ -89,7 +89,7 @@ public class SpecAnalyser extends BuiltInOPs {
}
}
// TODO are constant in the right order
// TODO are constant in the right order
specAnalyser
.
bConstants
.
addAll
(
Arrays
.
asList
(
m
.
getConstantDecls
())
)
;
specAnalyser
.
bConstants
=
Arrays
.
asList
(
m
.
getConstantDecls
());
return
specAnalyser
;
return
specAnalyser
;
}
}
...
@@ -106,19 +106,23 @@ public class SpecAnalyser extends BuiltInOPs {
...
@@ -106,19 +106,23 @@ public class SpecAnalyser extends BuiltInOPs {
public
void
start
()
throws
SemanticErrorException
,
ConfigFileErrorException
,
NotImplementedException
{
public
void
start
()
throws
SemanticErrorException
,
ConfigFileErrorException
,
NotImplementedException
{
evalSpec
();
evalSpec
();
for
(
OpDefNode
inv
:
new
ArrayList
<>(
invariants
))
{
invariants
.
replaceAll
(
inv
->
{
try
{
try
{
// resolve nested definitions in invariants, e.g. Inv == Inv2
// only Inv2 will appear in the translated B machine
// not simplified if the topmost operator of the definition is a built-in operator
OpApplNode
opApplNode
=
(
OpApplNode
)
inv
.
getBody
();
OpApplNode
opApplNode
=
(
OpApplNode
)
inv
.
getBody
();
OpDefNode
opDefNode
=
(
OpDefNode
)
opApplNode
.
getOperator
();
OpDefNode
opDefNode
=
(
OpDefNode
)
opApplNode
.
getOperator
();
// nested definition
if
(
opDefNode
.
getKind
()
==
UserDefinedOpKind
&&
!
BBuiltInOPs
.
contains
(
opDefNode
.
getName
()))
{
if
(
opDefNode
.
getKind
()
==
UserDefinedOpKind
&&
!
BBuiltInOPs
.
contains
(
opDefNode
.
getName
()))
{
int
i
=
invariants
.
indexOf
(
inv
);
DebugUtils
.
printDebugMsg
(
"replacing invariant definition "
+
inv
.
getName
()
+
" by its inner definition "
+
opDefNode
.
getName
());
invariants
.
set
(
i
,
opDefNode
);
return
opDefNode
;
DebugUtils
.
printDebugMsg
(
"Adding invariant "
+
i
);
}
}
catch
(
ClassCastException
e
)
{
}
}
}
catch
(
ClassCastException
ignored
)
{
// should not happen; otherwise no problem: invariant is already registered
}
}
return
inv
;
});
DebugUtils
.
printDebugMsg
(
"Detecting OPERATIONS from disjunctions"
);
DebugUtils
.
printDebugMsg
(
"Detecting OPERATIONS from disjunctions"
);
bOperations
=
new
OperationsFinder
(
this
).
getBOperations
();
bOperations
=
new
OperationsFinder
(
this
).
getBOperations
();
...
@@ -130,7 +134,7 @@ public class SpecAnalyser extends BuiltInOPs {
...
@@ -130,7 +134,7 @@ public class SpecAnalyser extends BuiltInOPs {
DebugUtils
.
printDebugMsg
(
"Computing variable declarations"
);
DebugUtils
.
printDebugMsg
(
"Computing variable declarations"
);
// test whether there is an init predicate if there is a variable
// test whether there is an init predicate if there is a variable
if
(
moduleNode
.
getVariableDecls
().
length
>
0
&&
inits
==
null
)
{
if
(
moduleNode
.
getVariableDecls
().
length
>
0
&&
inits
.
isEmpty
()
)
{
throw
new
SemanticErrorException
(
"No initial predicate is defined."
);
throw
new
SemanticErrorException
(
"No initial predicate is defined."
);
}
}
...
@@ -222,6 +226,7 @@ public class SpecAnalyser extends BuiltInOPs {
...
@@ -222,6 +226,7 @@ public class SpecAnalyser extends BuiltInOPs {
Set
<
OpDefNode
>
set
=
new
HashSet
<>(
usedDefinitions
);
Set
<
OpDefNode
>
set
=
new
HashSet
<>(
usedDefinitions
);
for
(
OpDefNode
def
:
set
)
{
for
(
OpDefNode
def
:
set
)
{
if
(
def
.
getInRecursive
())
{
if
(
def
.
getInRecursive
())
{
// TODO: implement
throw
new
NotImplementedException
(
"Recursive definitions are currently not supported: "
+
def
.
getName
()
throw
new
NotImplementedException
(
"Recursive definitions are currently not supported: "
+
def
.
getName
()
+
"\n"
+
def
.
getLocation
());
+
"\n"
+
def
.
getLocation
());
// bDefinitionsSet.remove(def);
// bDefinitionsSet.remove(def);
...
...
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