#include "ModelComp.h"
#include "AmplModel.h"
#include "backend.h"
#include "GlobalVariables.h"
#include "nodes.h"
#include <cassert>
#include <cstdlib>
#include <iostream>
Defines | |
#define | LogMC(X) |
Functions | |
void | modified_write (ostream &fout, ModelComp *comp) |
Writes out a component of a model. | |
static int | buildModelPath (const AmplModel *path[], const AmplModel *model) |
string | getGlobalName (const ModelComp *node, const SyntaxNode *opn, const AmplModel *current_model, int witharg) |
Find the global name of the model component pointed to by 'node':
| |
string | getGlobalNameNew (const ModelComp *node, const SyntaxNode *opn, const AmplModel *current_model, int witharg) |
New version of getGlobalName that does *not* use the addIndex stack but creates the modified argument list by looking at the indexing expressions of the submodel tree leading to this ModelComp. |
#define LogMC | ( | X | ) |
Referenced by ModelComp::findDependencies(), and ModelComp::setUpDependencies().
References AmplModel::parent.
Referenced by getGlobalName(), and getGlobalNameNew().
string getGlobalName | ( | const ModelComp * | node, | |
const SyntaxNode * | opn, | |||
const AmplModel * | current_model, | |||
int | witharg | |||
) |
Find the global name of the model component pointed to by 'node':
[in] | node | The model component in question. |
[in] | opn | The node (IDREF) of the model component (needed for the (local) argument list). |
[in] | current_model | The block for which this is written: indexing is given in the original SML model wrt a given node in the model tree. FIXME: what happens if the component referenced in the definition is not in the same model_tree node as the component to be defined? In the original ampl file this is correct, since the indexing will be given relative to the current_model. However the local indexing is lost(?) in the node representation => I don't think so, it is still encoded in the rest of the SyntaxNode structure |
[in] | witharg | WITHARG: if the argument list should be processed, NOARG: only the global name, ONLYARG: only the argument list. |
References buildModelPath(), SyntaxNode::getArgumentList(), ModelComp::id, l_addIndex, ModelComp::model, AmplModel::name, SyntaxNode::nchild(), NOARG, AmplModel::parent, SyntaxNode::printDummyVar(), and WITHARG.
Referenced by AmplModel::createExpandedModel(), modified_write(), and process_model().
string getGlobalNameNew | ( | const ModelComp * | node, | |
const SyntaxNode * | opn, | |||
const AmplModel * | current_model, | |||
int | witharg | |||
) |
New version of getGlobalName that does *not* use the addIndex stack but creates the modified argument list by looking at the indexing expressions of the submodel tree leading to this ModelComp.
[in] | node | The model component in question. |
[in] | opn | The node (IDREF) of the model component (needed for the (local) argument list). |
[in] | current_model | The block for which this is written: indexing is given in the original SML model wrt a given node in the model tree. |
[in] | witharg | WITHARG: if the argument list should be processed, NOARG: only the global name, ONLYARG: only the argument list. |
Find the global name of the model component pointed to by 'node':
References buildModelPath(), SyntaxNode::getArgumentList(), SyntaxNodeIx::getDummyVarExpr(), SyntaxNodeIx::getNComp(), ModelComp::id, ModelComp::indexing, ModelComp::model, AmplModel::name, SyntaxNode::nchild(), NOARG, AmplModel::node, AmplModel::parent, SyntaxNode::printDummyVar(), and WITHARG.
Referenced by SyntaxNodeIDREF::put().
void modified_write | ( | ostream & | fout, | |
ModelComp * | comp | |||
) |
Writes out a component of a model.
Components can be modified: if this is down into a submodel, then
[in] | fout | The file to write to. |
[in] | comp | The component definition to write out. |
Prints the global definition of the given ModelComponent to the given file.
The last part is simply done by a call to (comp->attributes)->print() (SyntaxNode::print) (with SyntaxNode::use_global_names set to true => the argument list version of ModelComp::getGlobalName is called)
References ModelComp::attributes, ModelComp::compTypes, add_index::dummyVar, SyntaxNode::front(), getGlobalName(), SyntaxNode::getOpCode(), ModelComp::id, ModelComp::indexing, l_addIndex, ModelComp::model, NOARG, AmplModel::parent, prt_modwrite, add_index::set, TCON, TMAX, TMIN, TMODEL, and ModelComp::type.