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
74f25b39
Commit
74f25b39
authored
5 months ago
by
Jan Gruteser
Browse files
Options
Downloads
Patches
Plain Diff
minor simplifications
parent
5c34eeb1
No related branches found
No related tags found
No related merge requests found
Pipeline
#148715
passed
5 months ago
Stage: test
Stage: deploy
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/de/tla2b/translation/BMacroHandler.java
+21
-45
21 additions, 45 deletions
src/main/java/de/tla2b/translation/BMacroHandler.java
with
21 additions
and
45 deletions
src/main/java/de/tla2b/translation/BMacroHandler.java
+
21
−
45
View file @
74f25b39
...
...
@@ -6,44 +6,34 @@ import de.tla2b.config.ConfigfileEvaluator;
import
tla2sany.semantic.*
;
import
java.util.*
;
import
java.util.stream.Collectors
;
public
class
BMacroHandler
extends
AbstractASTVisitor
{
private
final
Hashtable
<
FormalParamNode
,
String
>
renamingTable
=
new
Hash
table
<>();
private
final
Map
<
FormalParamNode
,
String
>
renamingTable
=
new
Hash
Map
<>();
public
BMacroHandler
(
SpecAnalyser
specAnalyser
,
ConfigfileEvaluator
conEval
)
{
ModuleNode
moduleNode
=
specAnalyser
.
getModuleNode
();
ArrayList
<
OpDefNode
>
bDefs
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
moduleNode
.
getOpDefs
().
length
;
i
++)
{
OpDefNode
def
=
moduleNode
.
getOpDefs
()[
i
];
if
(
specAnalyser
.
getUsedDefinitions
().
contains
(
def
))
{
if
(
conEval
!=
null
&&
conEval
.
getConstantOverrides
()
.
containsValue
(
def
))
{
continue
;
}
bDefs
.
add
(
def
);
}
}
List
<
OpDefNode
>
bDefs
=
Arrays
.
stream
(
moduleNode
.
getOpDefs
())
.
filter
(
def
->
specAnalyser
.
getUsedDefinitions
().
contains
(
def
))
.
filter
(
def
->
conEval
==
null
||
!
conEval
.
getConstantOverrides
().
containsValue
(
def
))
.
collect
(
Collectors
.
toList
());
for
(
OpDefNode
opDefNode
:
bDefs
)
{
visitDefinition
(
opDefNode
);
}
visitAssumptions
(
moduleNode
.
getAssumptions
());
}
public
BMacroHandler
()
{
}
private
Hash
Set
<
FormalParamNode
>
definitionParameters
;
private
Hash
Set
<
FormalParamNode
>
localVariables
;
private
final
Hashtable
<
FormalParamNode
,
Set
<
FormalParamNode
>>
parameterContext
=
new
Hash
table
<>();
private
Set
<
FormalParamNode
>
definitionParameters
;
private
Set
<
FormalParamNode
>
localVariables
;
private
final
Map
<
FormalParamNode
,
Set
<
FormalParamNode
>>
parameterContext
=
new
Hash
Map
<>();
@Override
public
void
visitDefinition
(
OpDefNode
def
)
{
definitionParameters
=
new
HashSet
<>();
definitionParameters
.
addAll
(
Arrays
.
asList
(
def
.
getParams
()));
definitionParameters
=
new
HashSet
<>(
Arrays
.
asList
(
def
.
getParams
()));
for
(
FormalParamNode
param
:
definitionParameters
)
{
parameterContext
.
put
(
param
,
new
HashSet
<>());
}
...
...
@@ -64,7 +54,6 @@ public class BMacroHandler extends AbstractASTVisitor {
definitionParameters
=
null
;
localVariables
=
null
;
}
@Override
...
...
@@ -77,50 +66,37 @@ public class BMacroHandler extends AbstractASTVisitor {
case
OPCODE_bf:
// \A x \in S : P
case
OPCODE_bc:
// CHOOSE x \in S: P
case
OPCODE_sso:
// $SubsetOf Represents {x \in S : P}
case
OPCODE_soa:
// $SetOfAll Represents {e : p1 \in S, p2,p3 \in S2}
{
FormalParamNode
[][]
params
=
n
.
getBdedQuantSymbolLists
();
HashSet
<
FormalParamNode
>
set
=
new
HashSet
<>();
for
(
FormalParamNode
[]
param
:
params
)
{
case
OPCODE_soa:
{
// $SetOfAll Represents {e : p1 \in S, p2,p3 \in S2}
Set
<
FormalParamNode
>
set
=
new
HashSet
<>();
for
(
FormalParamNode
[]
param
:
n
.
getBdedQuantSymbolLists
())
{
Collections
.
addAll
(
set
,
param
);
}
localVariables
.
addAll
(
set
);
ExprNode
[]
in
=
n
.
getBdedQuantBounds
();
for
(
ExprNode
exprNode
:
in
)
{
for
(
ExprNode
exprNode
:
n
.
getBdedQuantBounds
())
{
// in
visitExprNode
(
exprNode
);
}
ExprOrOpArgNode
[]
arguments
=
n
.
getArgs
();
for
(
ExprOrOpArgNode
exprOrOpArgNode
:
arguments
)
{
visitExprOrOpArgNode
(
exprOrOpArgNode
);
for
(
ExprOrOpArgNode
argument
:
n
.
getArgs
())
{
visitExprOrOpArgNode
(
argument
);
}
localVariables
.
removeAll
(
set
);
return
;
}
default
:
{
default
:
super
.
visitBuiltInNode
(
n
);
}
}
}
private
Set
<
String
>
getStringSet
(
Set
<
FormalParamNode
>
set
)
{
HashSet
<
String
>
stringSet
=
new
HashSet
<>();
for
(
FormalParamNode
formalParamNode
:
set
)
{
stringSet
.
add
(
formalParamNode
.
getName
().
toString
());
}
return
stringSet
;
return
set
.
stream
().
map
(
s
->
s
.
getName
().
toString
()).
collect
(
Collectors
.
toSet
());
}
private
Hash
Set
<
FormalParamNode
>
illegalParams
;
private
Set
<
FormalParamNode
>
illegalParams
;
private
void
addToIllegalParams
(
Set
<
FormalParamNode
>
set
)
{
if
(
illegalParams
==
null
)
{
illegalParams
=
new
HashSet
<>(
set
);
}
else
{
illegalParams
.
addAll
(
set
);
illegalParams
=
new
HashSet
<>();
}
illegalParams
.
addAll
(
set
);
}
private
Set
<
FormalParamNode
>
getContextOfParam
(
FormalParamNode
param
)
{
...
...
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