Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
old_macaon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
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
Franck Dary
old_macaon
Commits
52974429
Commit
52974429
authored
6 years ago
by
Franck Dary
Browse files
Options
Downloads
Patches
Plain Diff
Fixed a bug related do undoing actions
parent
fe396e89
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
maca_common/include/LimitedArray.hpp
+12
-6
12 additions, 6 deletions
maca_common/include/LimitedArray.hpp
transition_machine/src/ActionBank.cpp
+13
-3
13 additions, 3 deletions
transition_machine/src/ActionBank.cpp
transition_machine/src/Config.cpp
+2
-2
2 additions, 2 deletions
transition_machine/src/Config.cpp
with
27 additions
and
11 deletions
maca_common/include/LimitedArray.hpp
+
12
−
6
View file @
52974429
...
...
@@ -13,16 +13,18 @@ class LimitedArray
{
private
:
std
::
vector
<
T
>
data
;
std
::
vector
<
std
::
pair
<
T
,
bool
>
>
data
;
int
nbElements
;
int
lastElementDataIndex
;
int
lastElementRealIndex
;
T
mask
;
public
:
LimitedArray
(
unsigned
int
limit
)
:
data
(
limit
)
LimitedArray
(
unsigned
int
limit
,
const
T
&
mask
)
:
data
(
limit
)
{
clear
();
this
->
mask
=
mask
;
}
void
clear
()
...
...
@@ -44,17 +46,21 @@ class LimitedArray
lastElementRealIndex
++
;
data
[
lastElementDataIndex
]
=
elem
;
data
[
lastElementDataIndex
]
.
first
=
elem
;
}
const
T
&
get
(
unsigned
int
index
)
const
{
return
data
[
index
%
data
.
size
()];
if
(
data
[
index
%
data
.
size
()].
second
)
return
mask
;
return
data
[
index
%
data
.
size
()].
first
;
}
void
set
(
unsigned
int
index
,
const
T
&
value
)
{
data
[
index
%
data
.
size
()]
=
value
;
data
[
index
%
data
.
size
()].
first
=
value
;
data
[
index
%
data
.
size
()].
second
=
false
;
}
int
getLastIndex
()
const
...
...
@@ -70,7 +76,7 @@ class LimitedArray
void
printForDebug
(
FILE
*
out
)
const
{
for
(
int
i
=
0
;
i
<
std
::
min
(
nbElements
,(
int
)
data
.
size
());
i
++
)
fprintf
(
out
,
"<%s>"
,
data
[
i
].
c_str
());
fprintf
(
out
,
"<%s>"
,
data
[
i
].
first
.
c_str
());
fprintf
(
out
,
"
\n
"
);
}
...
...
This diff is collapsed.
Click to expand it.
transition_machine/src/ActionBank.cpp
+
13
−
3
View file @
52974429
...
...
@@ -401,6 +401,7 @@ std::vector<Action::BasicAction> ActionBank::str2sequence(const std::string & na
}
auto
deps
=
split
(
ba
.
data
,
'+'
);
for
(
auto
s
:
deps
)
if
(
!
s
.
empty
())
simpleBufferWrite
(
c
,
"GOV"
,
""
,
std
::
stoi
(
s
));
ba
.
data
.
clear
();
};
...
...
@@ -453,7 +454,9 @@ std::vector<Action::BasicAction> ActionBank::str2sequence(const std::string & na
}
auto
deps
=
split
(
ba
.
data
,
'+'
);
for
(
auto
&
dep
:
deps
)
if
(
!
dep
.
empty
())
simpleBufferWrite
(
c
,
"LABEL"
,
""
,
std
::
stoi
(
dep
));
ba
.
data
.
clear
();
};
auto
appliable2
=
[](
Config
&
c
,
Action
::
BasicAction
&
)
{
...
...
@@ -480,7 +483,9 @@ std::vector<Action::BasicAction> ActionBank::str2sequence(const std::string & na
{
auto
elems
=
split
(
ba
.
data
);
for
(
auto
elem
:
elems
)
if
(
!
elem
.
empty
())
c
.
stackPush
(
std
::
stoi
(
elem
));
ba
.
data
.
clear
();
};
auto
appliable4
=
[](
Config
&
c
,
Action
::
BasicAction
&
)
{
...
...
@@ -530,6 +535,11 @@ std::vector<Action::BasicAction> ActionBank::str2sequence(const std::string & na
while
(
true
)
{
if
(
c
.
pastActions
.
empty
())
{
fprintf
(
stderr
,
"ERROR (%s) : trying to undo action while pastActions is empty. Aborting.
\n
"
,
ERRINFO
);
exit
(
1
);
}
auto
a
=
c
.
pastActions
.
pop
();
if
(
ProgramParameters
::
debug
)
fprintf
(
stderr
,
"Undoing... <%s><%s>
\n
"
,
a
.
first
.
c_str
(),
a
.
second
.
name
.
c_str
());
...
...
This diff is collapsed.
Click to expand it.
transition_machine/src/Config.cpp
+
2
−
2
View file @
52974429
...
...
@@ -5,7 +5,7 @@
#include
"Action.hpp"
#include
"ProgramOutput.hpp"
Config
::
Config
(
BD
&
bd
,
const
std
::
string
inputFilename
)
:
bd
(
bd
),
hashHistory
(
3
0
),
pastActions
(
100
)
Config
::
Config
(
BD
&
bd
,
const
std
::
string
inputFilename
)
:
bd
(
bd
),
hashHistory
(
9
0
),
pastActions
(
100
)
{
this
->
outputFile
=
nullptr
;
this
->
stackHistory
=
-
1
;
...
...
@@ -36,7 +36,7 @@ Config::Config(const Config & other) : bd(other.bd), hashHistory(other.hashHisto
this
->
file
.
reset
(
new
File
(
*
other
.
file
.
get
()));
}
Config
::
Tape
::
Tape
(
const
std
::
string
&
name
,
bool
isKnown
)
:
ref
(
ProgramParameters
::
readSize
*
4
+
1
),
hyp
(
ProgramParameters
::
readSize
*
4
+
1
)
Config
::
Tape
::
Tape
(
const
std
::
string
&
name
,
bool
isKnown
)
:
ref
(
ProgramParameters
::
readSize
*
4
+
1
,
Dict
::
unknownValueStr
),
hyp
(
ProgramParameters
::
readSize
*
4
+
1
,
std
::
make_pair
(
Dict
::
unknownValueStr
,
0.0
)
)
{
this
->
head
=
0
;
this
->
name
=
name
;
...
...
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