Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
b2program
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
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
b2program
Commits
f76c93e8
Commit
f76c93e8
authored
May 16, 2024
by
Fabian Vu
Browse files
Options
Downloads
Patches
Plain Diff
Fix a bug in MachineProcessor
parent
40ae4fb4
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/de/hhu/stups/codegenerator/generators/MachinePreprocessor.java
+12
-10
12 additions, 10 deletions
...u/stups/codegenerator/generators/MachinePreprocessor.java
with
12 additions
and
10 deletions
src/main/java/de/hhu/stups/codegenerator/generators/MachinePreprocessor.java
+
12
−
10
View file @
f76c93e8
...
@@ -402,16 +402,16 @@ public class MachinePreprocessor implements AbstractVisitor<Node, Void> {
...
@@ -402,16 +402,16 @@ public class MachinePreprocessor implements AbstractVisitor<Node, Void> {
}
}
}
}
}
}
BType
lhsType
=
lhs
.
getType
();
List
<
PredicateNode
>
predicates
=
new
ArrayList
<>();
List
<
PredicateNode
>
predicates
=
new
ArrayList
<>();
ExpressionOperatorNode
emptySetNode
=
new
ExpressionOperatorNode
(
node
.
getSourceCodePosition
(),
ExpressionOperatorNode
.
ExpressionOperator
.
SET_ENUMERATION
);
// We can assume in the code generator that the cardinality is WD as we do not support code generation for infinite sets explicitly
predicates
.
add
(
new
PredicateOperatorWithExprArgsNode
(
sourceCodePosition
,
PredicateOperatorWithExprArgsNode
.
PredOperatorExprArgs
.
NOT_EQUAL
,
Arrays
.
asList
(
lhs
,
emptySetNode
)));
ExpressionOperatorNode
cardSetNode
=
new
ExpressionOperatorNode
(
node
.
getSourceCodePosition
(),
Collections
.
singletonList
(
lhs
),
ExpressionOperatorNode
.
ExpressionOperator
.
CARD
);
NumberNode
zeroNode
=
new
NumberNode
(
node
.
getSourceCodePosition
(),
new
BigInteger
(
"0"
));
predicates
.
add
(
new
PredicateOperatorWithExprArgsNode
(
sourceCodePosition
,
PredicateOperatorWithExprArgsNode
.
PredOperatorExprArgs
.
GREATER
,
Arrays
.
asList
(
cardSetNode
,
zeroNode
)));
predicates
.
add
(
new
PredicateOperatorWithExprArgsNode
(
sourceCodePosition
,
PredicateOperatorWithExprArgsNode
.
PredOperatorExprArgs
.
INCLUSION
,
Arrays
.
asList
(
lhs
,
rhsAsExpression
.
getExpressionNodes
().
get
(
0
))));
predicates
.
add
(
new
PredicateOperatorWithExprArgsNode
(
sourceCodePosition
,
PredicateOperatorWithExprArgsNode
.
PredOperatorExprArgs
.
INCLUSION
,
Arrays
.
asList
(
lhs
,
rhsAsExpression
.
getExpressionNodes
().
get
(
0
))));
PredicateNode
predicateNode
=
new
PredicateOperatorNode
(
sourceCodePosition
,
PredicateOperatorNode
.
PredicateOperator
.
AND
,
predicates
);
PredicateNode
predicateNode
=
new
PredicateOperatorNode
(
sourceCodePosition
,
PredicateOperatorNode
.
PredicateOperator
.
AND
,
predicates
);
predicateNode
.
setType
(
new
UntypedType
());
predicateNode
.
setType
(
new
UntypedType
());
typeChecker
.
checkPredicateNode
(
predicateNode
);
typeChecker
.
checkPredicateNode
(
predicateNode
);
predicateNode
=
visitPredicateNode
(
predicateNode
);
predicateNode
=
visitPredicateNode
(
predicateNode
);
emptySetNode
.
setType
(
lhsType
);
return
predicateNode
;
return
predicateNode
;
}
}
case
ID:
{
case
ID:
{
...
@@ -657,8 +657,10 @@ public class MachinePreprocessor implements AbstractVisitor<Node, Void> {
...
@@ -657,8 +657,10 @@ public class MachinePreprocessor implements AbstractVisitor<Node, Void> {
optimizationVariableCounter
++;
optimizationVariableCounter
++;
DeclarationNode
declarationNode
=
new
DeclarationNode
(
sourceCodePosition
,
"_opt_"
+
optimizationVariableCounter
,
DeclarationNode
.
Kind
.
VARIABLE
,
machineNode
);
DeclarationNode
declarationNode
=
new
DeclarationNode
(
sourceCodePosition
,
"_opt_"
+
optimizationVariableCounter
,
DeclarationNode
.
Kind
.
VARIABLE
,
machineNode
);
typeChecker
.
setDeclarationTypes
(
Collections
.
singletonList
(
declarationNode
));
declarationNode
.
setType
(((
SetType
)
lhs
.
getType
()).
getSubType
());
declarationNode
.
setType
(((
SetType
)
lhs
.
getType
()).
getSubType
());
IdentifierExprNode
newIdentifierNode
=
new
IdentifierExprNode
(
sourceCodePosition
,
"_opt_"
+
optimizationVariableCounter
,
false
);
IdentifierExprNode
newIdentifierNode
=
new
IdentifierExprNode
(
sourceCodePosition
,
"_opt_"
+
optimizationVariableCounter
,
false
);
newIdentifierNode
.
setType
(((
SetType
)
lhs
.
getType
()).
getSubType
());
PredicateOperatorWithExprArgsNode
firstPredicate
=
new
PredicateOperatorWithExprArgsNode
(
sourceCodePosition
,
PredicateOperatorWithExprArgsNode
.
PredOperatorExprArgs
.
ELEMENT_OF
,
Arrays
.
asList
(
newIdentifierNode
,
lhs
));
PredicateOperatorWithExprArgsNode
firstPredicate
=
new
PredicateOperatorWithExprArgsNode
(
sourceCodePosition
,
PredicateOperatorWithExprArgsNode
.
PredOperatorExprArgs
.
ELEMENT_OF
,
Arrays
.
asList
(
newIdentifierNode
,
lhs
));
PredicateNode
innerPredicate
=
new
PredicateOperatorWithExprArgsNode
(
sourceCodePosition
,
PredicateOperatorWithExprArgsNode
.
PredOperatorExprArgs
.
ELEMENT_OF
,
Arrays
.
asList
(
newIdentifierNode
,
rhs
));
PredicateNode
innerPredicate
=
new
PredicateOperatorWithExprArgsNode
(
sourceCodePosition
,
PredicateOperatorWithExprArgsNode
.
PredOperatorExprArgs
.
ELEMENT_OF
,
Arrays
.
asList
(
newIdentifierNode
,
rhs
));
innerPredicate
.
setType
(
new
UntypedType
());
innerPredicate
.
setType
(
new
UntypedType
());
...
@@ -667,7 +669,6 @@ public class MachinePreprocessor implements AbstractVisitor<Node, Void> {
...
@@ -667,7 +669,6 @@ public class MachinePreprocessor implements AbstractVisitor<Node, Void> {
PredicateNode
predicateNode
=
new
PredicateOperatorNode
(
sourceCodePosition
,
PredicateOperatorNode
.
PredicateOperator
.
IMPLIES
,
Arrays
.
asList
(
firstPredicate
,
innerPredicate
));
PredicateNode
predicateNode
=
new
PredicateOperatorNode
(
sourceCodePosition
,
PredicateOperatorNode
.
PredicateOperator
.
IMPLIES
,
Arrays
.
asList
(
firstPredicate
,
innerPredicate
));
QuantifiedPredicateNode
result
=
new
QuantifiedPredicateNode
(
sourceCodePosition
,
Collections
.
singletonList
(
declarationNode
),
predicateNode
,
QuantifiedPredicateNode
.
QuantifiedPredicateOperator
.
UNIVERSAL_QUANTIFICATION
);
QuantifiedPredicateNode
result
=
new
QuantifiedPredicateNode
(
sourceCodePosition
,
Collections
.
singletonList
(
declarationNode
),
predicateNode
,
QuantifiedPredicateNode
.
QuantifiedPredicateOperator
.
UNIVERSAL_QUANTIFICATION
);
result
.
setType
(
new
UntypedType
());
result
.
setType
(
new
UntypedType
());
typeChecker
.
setDeclarationTypes
(
result
.
getDeclarationList
());
typeChecker
.
checkPredicateNode
(
result
);
typeChecker
.
checkPredicateNode
(
result
);
return
result
;
return
result
;
}
}
...
@@ -688,8 +689,10 @@ public class MachinePreprocessor implements AbstractVisitor<Node, Void> {
...
@@ -688,8 +689,10 @@ public class MachinePreprocessor implements AbstractVisitor<Node, Void> {
optimizationVariableCounter
++;
optimizationVariableCounter
++;
DeclarationNode
declarationNode
=
new
DeclarationNode
(
sourceCodePosition
,
"_opt_"
+
optimizationVariableCounter
,
DeclarationNode
.
Kind
.
VARIABLE
,
machineNode
);
DeclarationNode
declarationNode
=
new
DeclarationNode
(
sourceCodePosition
,
"_opt_"
+
optimizationVariableCounter
,
DeclarationNode
.
Kind
.
VARIABLE
,
machineNode
);
typeChecker
.
setDeclarationTypes
(
Collections
.
singletonList
(
declarationNode
));
declarationNode
.
setType
(((
SetType
)
lhs
.
getType
()).
getSubType
());
declarationNode
.
setType
(((
SetType
)
lhs
.
getType
()).
getSubType
());
IdentifierExprNode
newIdentifierNode
=
new
IdentifierExprNode
(
sourceCodePosition
,
"_opt_"
+
optimizationVariableCounter
,
false
);
IdentifierExprNode
newIdentifierNode
=
new
IdentifierExprNode
(
sourceCodePosition
,
"_opt_"
+
optimizationVariableCounter
,
false
);
newIdentifierNode
.
setType
(((
SetType
)
lhs
.
getType
()).
getSubType
());
PredicateOperatorWithExprArgsNode
firstPredicate
=
new
PredicateOperatorWithExprArgsNode
(
sourceCodePosition
,
PredicateOperatorWithExprArgsNode
.
PredOperatorExprArgs
.
ELEMENT_OF
,
Arrays
.
asList
(
newIdentifierNode
,
lhs
));
PredicateOperatorWithExprArgsNode
firstPredicate
=
new
PredicateOperatorWithExprArgsNode
(
sourceCodePosition
,
PredicateOperatorWithExprArgsNode
.
PredOperatorExprArgs
.
ELEMENT_OF
,
Arrays
.
asList
(
newIdentifierNode
,
lhs
));
PredicateNode
innerPredicate
=
new
PredicateOperatorWithExprArgsNode
(
sourceCodePosition
,
PredicateOperatorWithExprArgsNode
.
PredOperatorExprArgs
.
NOT_BELONGING
,
Arrays
.
asList
(
newIdentifierNode
,
rhs
));
PredicateNode
innerPredicate
=
new
PredicateOperatorWithExprArgsNode
(
sourceCodePosition
,
PredicateOperatorWithExprArgsNode
.
PredOperatorExprArgs
.
NOT_BELONGING
,
Arrays
.
asList
(
newIdentifierNode
,
rhs
));
innerPredicate
.
setType
(
new
UntypedType
());
innerPredicate
.
setType
(
new
UntypedType
());
...
@@ -698,7 +701,6 @@ public class MachinePreprocessor implements AbstractVisitor<Node, Void> {
...
@@ -698,7 +701,6 @@ public class MachinePreprocessor implements AbstractVisitor<Node, Void> {
PredicateNode
predicateNode
=
new
PredicateOperatorNode
(
sourceCodePosition
,
PredicateOperatorNode
.
PredicateOperator
.
AND
,
Arrays
.
asList
(
firstPredicate
,
innerPredicate
));
PredicateNode
predicateNode
=
new
PredicateOperatorNode
(
sourceCodePosition
,
PredicateOperatorNode
.
PredicateOperator
.
AND
,
Arrays
.
asList
(
firstPredicate
,
innerPredicate
));
QuantifiedPredicateNode
result
=
new
QuantifiedPredicateNode
(
sourceCodePosition
,
Collections
.
singletonList
(
declarationNode
),
predicateNode
,
QuantifiedPredicateNode
.
QuantifiedPredicateOperator
.
EXISTENTIAL_QUANTIFICATION
);
QuantifiedPredicateNode
result
=
new
QuantifiedPredicateNode
(
sourceCodePosition
,
Collections
.
singletonList
(
declarationNode
),
predicateNode
,
QuantifiedPredicateNode
.
QuantifiedPredicateOperator
.
EXISTENTIAL_QUANTIFICATION
);
result
.
setType
(
new
UntypedType
());
result
.
setType
(
new
UntypedType
());
typeChecker
.
setDeclarationTypes
(
result
.
getDeclarationList
());
typeChecker
.
checkPredicateNode
(
result
);
typeChecker
.
checkPredicateNode
(
result
);
return
result
;
return
result
;
}
}
...
@@ -801,16 +803,16 @@ public class MachinePreprocessor implements AbstractVisitor<Node, Void> {
...
@@ -801,16 +803,16 @@ public class MachinePreprocessor implements AbstractVisitor<Node, Void> {
}
}
}
}
}
}
BType
lhsType
=
lhs
.
getType
();
List
<
PredicateNode
>
predicates
=
new
ArrayList
<>();
List
<
PredicateNode
>
predicates
=
new
ArrayList
<>();
ExpressionOperatorNode
emptySetNode
=
new
ExpressionOperatorNode
(
node
.
getSourceCodePosition
(),
ExpressionOperatorNode
.
ExpressionOperator
.
SET_ENUMERATION
);
// We can assume in the code generator that the cardinality is WD as we do not support code generation for infinite sets explicitly
predicates
.
add
(
new
PredicateOperatorWithExprArgsNode
(
sourceCodePosition
,
PredicateOperatorWithExprArgsNode
.
PredOperatorExprArgs
.
EQUAL
,
Arrays
.
asList
(
lhs
,
emptySetNode
)));
ExpressionOperatorNode
cardSetNode
=
new
ExpressionOperatorNode
(
node
.
getSourceCodePosition
(),
Collections
.
singletonList
(
lhs
),
ExpressionOperatorNode
.
ExpressionOperator
.
CARD
);
NumberNode
zeroNode
=
new
NumberNode
(
node
.
getSourceCodePosition
(),
new
BigInteger
(
"0"
));
predicates
.
add
(
new
PredicateOperatorWithExprArgsNode
(
sourceCodePosition
,
PredicateOperatorWithExprArgsNode
.
PredOperatorExprArgs
.
EQUAL
,
Arrays
.
asList
(
cardSetNode
,
zeroNode
)));
predicates
.
add
(
new
PredicateOperatorWithExprArgsNode
(
sourceCodePosition
,
PredicateOperatorWithExprArgsNode
.
PredOperatorExprArgs
.
NON_INCLUSION
,
Arrays
.
asList
(
lhs
,
rhsAsExpression
.
getExpressionNodes
().
get
(
0
))));
predicates
.
add
(
new
PredicateOperatorWithExprArgsNode
(
sourceCodePosition
,
PredicateOperatorWithExprArgsNode
.
PredOperatorExprArgs
.
NON_INCLUSION
,
Arrays
.
asList
(
lhs
,
rhsAsExpression
.
getExpressionNodes
().
get
(
0
))));
PredicateNode
predicateNode
=
new
PredicateOperatorNode
(
sourceCodePosition
,
PredicateOperatorNode
.
PredicateOperator
.
OR
,
predicates
);
PredicateNode
predicateNode
=
new
PredicateOperatorNode
(
sourceCodePosition
,
PredicateOperatorNode
.
PredicateOperator
.
OR
,
predicates
);
predicateNode
.
setType
(
new
UntypedType
());
predicateNode
.
setType
(
new
UntypedType
());
typeChecker
.
checkPredicateNode
(
predicateNode
);
typeChecker
.
checkPredicateNode
(
predicateNode
);
predicateNode
=
visitPredicateNode
(
predicateNode
);
predicateNode
=
visitPredicateNode
(
predicateNode
);
emptySetNode
.
setType
(
lhsType
);
return
predicateNode
;
return
predicateNode
;
}
}
case
ID:
{
case
ID:
{
...
...
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