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
Dóra Kocsis
dynare
Commits
4b96b35d
Commit
4b96b35d
authored
Mar 16, 2010
by
Sébastien Villemot
Browse files
Preprocessor: changed the prototype of DataTree::AddLocalVariable()
parent
208210c6
Changes
4
Hide whitespace changes
Inline
Side-by-side
preprocessor/DataTree.cc
View file @
4b96b35d
...
...
@@ -457,18 +457,16 @@ DataTree::AddEqual(NodeID iArg1, NodeID iArg2)
}
void
DataTree
::
AddLocalVariable
(
const
string
&
name
,
NodeID
value
)
throw
(
LocalVariableException
)
DataTree
::
AddLocalVariable
(
int
symb_id
,
NodeID
value
)
throw
(
LocalVariableException
)
{
int
id
=
symbol_table
.
getID
(
name
);
assert
(
symbol_table
.
getType
(
id
)
==
eModelLocalVariable
);
assert
(
symbol_table
.
getType
(
symb_id
)
==
eModelLocalVariable
);
// Throw an exception if symbol already declared
map
<
int
,
NodeID
>::
iterator
it
=
local_variables_table
.
find
(
id
);
map
<
int
,
NodeID
>::
iterator
it
=
local_variables_table
.
find
(
symb_
id
);
if
(
it
!=
local_variables_table
.
end
())
throw
LocalVariableException
(
name
);
throw
LocalVariableException
(
symbol_table
.
getName
(
symb_id
)
);
local_variables_table
[
id
]
=
value
;
local_variables_table
[
symb_
id
]
=
value
;
}
NodeID
...
...
preprocessor/DataTree.hh
View file @
4b96b35d
...
...
@@ -189,7 +189,7 @@ public:
//! Adds "arg1=arg2" to model tree
NodeID
AddEqual
(
NodeID
iArg1
,
NodeID
iArg2
);
//! Adds a model local variable with its value
void
AddLocalVariable
(
const
string
&
name
,
NodeID
value
)
throw
(
LocalVariableException
);
void
AddLocalVariable
(
int
symb_id
,
NodeID
value
)
throw
(
LocalVariableException
);
//! Adds an external function node
NodeID
AddExternalFunction
(
const
string
&
function_name
,
const
vector
<
NodeID
>
&
arguments
);
//! Adds an external function node
...
...
preprocessor/DynamicModel.cc
View file @
4b96b35d
...
...
@@ -2455,7 +2455,7 @@ DynamicModel::toStatic(StaticModel &static_model) const
// Convert model local variables (need to be done first)
for
(
map
<
int
,
NodeID
>::
const_iterator
it
=
local_variables_table
.
begin
();
it
!=
local_variables_table
.
end
();
it
++
)
static_model
.
AddLocalVariable
(
symbol_table
.
getName
(
it
->
first
)
,
it
->
second
->
toStatic
(
static_model
));
static_model
.
AddLocalVariable
(
it
->
first
,
it
->
second
->
toStatic
(
static_model
));
// Convert equations
for
(
vector
<
BinaryOpNode
*>::
const_iterator
it
=
equations
.
begin
();
...
...
preprocessor/ParsingDriver.cc
View file @
4b96b35d
...
...
@@ -1399,7 +1399,8 @@ ParsingDriver::declare_and_init_model_local_variable(string *name, NodeID rhs)
error
(
"Local model variable "
+
*
name
+
" declared twice."
);
}
model_tree
->
AddLocalVariable
(
*
name
,
rhs
);
int
symb_id
=
mod_file
->
symbol_table
.
getID
(
*
name
);
model_tree
->
AddLocalVariable
(
symb_id
,
rhs
);
delete
name
;
}
...
...
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