Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
sarah.grebing
ProofScriptParser
Commits
3953a34c
Commit
3953a34c
authored
May 19, 2017
by
Sarah Grebing
Browse files
deep copy of assignments bug
parent
74bb5b37
Pipeline
#10620
passed with stage
in 2 minutes and 9 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/edu/kit/formal/TestCommands/SplitCommand.java
View file @
3953a34c
...
...
@@ -2,6 +2,11 @@ package edu.kit.formal.TestCommands;
import
edu.kit.formal.interpreter.GoalNode
;
import
edu.kit.formal.interpreter.State
;
import
edu.kit.formal.interpreter.Value
;
import
edu.kit.formal.interpreter.VariableAssignment
;
import
edu.kit.formal.proofscriptparser.ast.Type
;
import
java.math.BigInteger
;
/**
* Created by sarah on 5/17/17.
...
...
@@ -10,12 +15,16 @@ public class SplitCommand extends AbstractCommand {
@Override
public
State
execute
(
State
s
)
{
GoalNode
g
=
s
.
getSelectedGoalNode
();
VariableAssignment
assignments
=
g
.
getAssignments
();
String
seq1
=
g
.
getSequent
().
concat
(
"1"
);
String
seq2
=
g
.
getSequent
().
concat
(
"2"
);
s
.
getGoals
().
remove
(
g
);
s
.
getGoals
().
add
(
new
GoalNode
(
g
,
seq1
));
s
.
getGoals
().
add
(
new
GoalNode
(
g
,
seq2
));
GoalNode
g2
=
new
GoalNode
(
g
,
seq2
);
g2
.
setVarValue
(
"z"
,
new
Value
(
Type
.
INT
,
BigInteger
.
valueOf
(
10
)));
s
.
getGoals
().
add
(
g2
);
return
s
;
}
}
src/main/java/edu/kit/formal/interpreter/GoalNode.java
View file @
3953a34c
...
...
@@ -19,11 +19,16 @@ public class GoalNode {
private
GoalNode
parent
;
public
GoalNode
(
GoalNode
parent
,
String
seq
)
{
this
.
assignments
=
new
VariableAssignment
(
parent
==
null
?
null
:
parent
.
assignments
);
//BUG: Hier muesste deepcopy der assignments passieren
this
.
assignments
=
new
VariableAssignment
(
parent
==
null
?
null
:
parent
.
deepCopyAssignments
());
this
.
parent
=
parent
;
this
.
sequent
=
seq
;
}
private
VariableAssignment
deepCopyAssignments
()
{
return
assignments
.
deepCopy
();
}
public
VariableAssignment
getAssignments
()
{
return
assignments
;
}
...
...
src/main/java/edu/kit/formal/interpreter/Interpreter.java
View file @
3953a34c
...
...
@@ -162,8 +162,6 @@ public class Interpreter<T> extends DefaultASTVisitor<T> {
Value
eval
=
goalEval
.
eval
(
guard
);
System
.
out
.
println
();
if
(
eval
.
getData
().
equals
(
true
))
{
// if (eval.getData().equals(Value.TRUE)) {
forCase
.
add
(
g
);
}
}
...
...
src/main/java/edu/kit/formal/interpreter/VariableAssignment.java
View file @
3953a34c
...
...
@@ -22,6 +22,7 @@ public class VariableAssignment {
this
.
parent
=
parent
;
}
public
VariableAssignment
()
{
this
(
null
);
}
...
...
@@ -118,4 +119,15 @@ public class VariableAssignment {
", types="
+
types
+
'}'
;
}
public
VariableAssignment
deepCopy
()
{
HashMap
<
String
,
Type
>
typeMapCopy
=
new
HashMap
<>();
types
.
forEach
((
k
,
v
)
->
typeMapCopy
.
put
(
k
,
v
));
HashMap
<
String
,
Value
>
valueMap
=
new
HashMap
<>();
values
.
forEach
((
k
,
v
)
->
valueMap
.
put
(
k
,
v
));
VariableAssignment
copy
=
new
VariableAssignment
(
parent
==
null
?
null
:
parent
.
deepCopy
());
copy
.
values
=
valueMap
;
copy
.
types
=
typeMapCopy
;
return
copy
;
}
}
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment