Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Dynare
preprocessor
Commits
24f1276b
Commit
24f1276b
authored
Oct 10, 2018
by
Sébastien Villemot
Browse files
Make all DataTree::*_map private
Introducing a new DataTree::getVariable() const method was necessary in the process.
parent
f2cf86b7
Changes
3
Show whitespace changes
Inline
Side-by-side
src/DataTree.cc
View file @
24f1276b
...
...
@@ -148,6 +148,18 @@ DataTree::AddVariable(int symb_id, int lag)
return
p
;
}
VariableNode
*
DataTree
::
getVariable
(
int
symb_id
,
int
lag
)
const
{
auto
it
=
variable_node_map
.
find
({
symb_id
,
lag
});
if
(
it
==
variable_node_map
.
end
())
{
cerr
<<
"DataTree::getVariable: unknown variable node for symb_id="
<<
symb_id
<<
" and lag="
<<
lag
<<
endl
;
exit
(
EXIT_FAILURE
);
}
return
it
->
second
;
}
bool
DataTree
::
ParamUsedWithLeadLagInternal
()
const
{
...
...
src/DataTree.hh
View file @
24f1276b
...
...
@@ -48,7 +48,7 @@ public:
//! Is it possible to use leads/lags on variable nodes?
const
bool
is_dynamic
;
pr
otec
te
d
:
pr
iva
te:
//! num_constant_id -> NumConstNode
using
num_const_node_map_t
=
map
<
int
,
NumConstNode
*>
;
num_const_node_map_t
num_const_node_map
;
...
...
@@ -89,6 +89,7 @@ protected:
using
second_deriv_external_function_node_map_t
=
map
<
tuple
<
vector
<
expr_t
>
,
int
,
int
,
int
>
,
SecondDerivExternalFunctionNode
*>
;
second_deriv_external_function_node_map_t
second_deriv_external_function_node_map
;
protected:
//! Stores local variables value (maps symbol ID to corresponding node)
map
<
int
,
expr_t
>
local_variables_table
;
//! Stores the order of appearance of local variables in the model block. Needed following change in #563
...
...
@@ -153,6 +154,10 @@ public:
expr_t
AddNonNegativeConstant
(
const
string
&
value
);
//! Adds a variable
VariableNode
*
AddVariable
(
int
symb_id
,
int
lag
=
0
);
//! Gets a variable
/*! Same as AddVariable, except that it fails if the variable node has not
already been created */
VariableNode
*
getVariable
(
int
symb_id
,
int
lag
=
0
)
const
;
//! Adds "arg1+arg2" to model tree
expr_t
AddPlus
(
expr_t
iArg1
,
expr_t
iArg2
);
//! Adds "arg1-arg2" to model tree
...
...
src/ModelEquationBlock.cc
View file @
24f1276b
...
...
@@ -219,9 +219,7 @@ SteadyStateModel::writeSteadyStateFile(const string &basename, bool ramsey_model
output
<<
"["
;
for
(
size_t
j
=
0
;
j
<
symb_ids
.
size
();
j
++
)
{
auto
it
=
variable_node_map
.
find
({
symb_ids
[
j
],
0
});
assert
(
it
!=
variable_node_map
.
end
());
dynamic_cast
<
ExprNode
*>
(
it
->
second
)
->
writeOutput
(
output
,
output_type
);
getVariable
(
symb_ids
[
j
])
->
ExprNode
::
writeOutput
(
output
,
output_type
);
if
(
j
<
symb_ids
.
size
()
-
1
)
output
<<
","
;
}
...
...
@@ -269,11 +267,8 @@ SteadyStateModel::writeJsonSteadyStateFile(ostream &output, bool transformComput
{
if
(
j
!=
0
)
output
<<
","
;
auto
it
=
variable_node_map
.
find
({
symb_ids
[
j
],
0
});
assert
(
it
!=
variable_node_map
.
end
());
output
<<
"
\"
"
;
dynamic_cast
<
ExprNode
*>
(
it
->
second
)
->
writeJsonOutput
(
output
,
{},
{},
false
);
getVariable
(
symb_ids
[
j
]
)
->
writeJsonOutput
(
output
,
{},
{},
false
);
output
<<
"
\"
"
;
}
if
(
symb_ids
.
size
()
>
1
)
...
...
@@ -401,11 +396,8 @@ Epilogue::writeEpilogueFile(const string &basename) const
output
<<
endl
;
for
(
const
auto
&
it
:
def_table
)
{
auto
node
=
variable_node_map
.
find
({
it
.
first
,
0
});
assert
(
node
!=
variable_node_map
.
end
());
output
<<
" "
;
dynamic_cast
<
ExprNode
*>
(
node
->
second
)
->
writeOutput
(
output
,
output_type
);
getVariable
(
it
.
first
)
->
ExprNode
::
writeOutput
(
output
,
output_type
);
output
<<
" = "
;
it
.
second
->
writeOutput
(
output
,
output_type
,
temporary_terms
,
temporary_terms_idxs
,
tef_terms
);
output
<<
";"
<<
endl
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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