Skip to content

Commit

Permalink
Merge branch 'qss-solver-dev' into mmoc/iss-216-add-code-generation-f…
Browse files Browse the repository at this point in the history
…or-pure-recursive-deps
  • Loading branch information
joaquinffernandez committed May 2, 2023
2 parents 554ab9f + 9bb5bcc commit 83dd66c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
25 changes: 15 additions & 10 deletions src/mmoc/util/symbol_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@

#include "symbol_table.h"

#include <sstream>
#include <math.h>
#include <sstream>

#include "../ast/ast_builder.h"
#include "../ast/expression.h"
#include "../ir/equation.h"
#include "../ir/expression.h"
#include "../ir/helpers.h"
#include "util.h"
#include <ast/ast_builder.h>
#include <ast/expression.h>
#include <ir/equation.h>
#include <ir/expression.h>
#include <ir/helpers.h>
#include <util/util.h>

namespace MicroModelica {
using namespace IR;
Expand Down Expand Up @@ -122,7 +122,6 @@ Variable &Variable::operator=(const Variable &other)
_hasOffset = other._hasOffset;
_offset = other._offset;
_realType = other._realType;

return *this;
}

Expand Down Expand Up @@ -175,6 +174,8 @@ void Variable::processModification()
}
}

void Variable::setName(string name) { _name = name; }

unsigned int Variable::size()
{
vector<int>::const_iterator it;
Expand Down Expand Up @@ -217,9 +218,9 @@ string Variable::declaration(string prefix)
{
stringstream buffer;
if (type()->print() == "Integer") {
buffer << "int ";
buffer << "int ";
} else {
buffer << "double ";
buffer << "double ";
}
buffer << prefix << name();
if (isArray()) {
Expand Down Expand Up @@ -271,6 +272,10 @@ void VarSymbolTable::initialize(TypeSymbolTable ty)
reinit.setBuiltIn();
reinit.setName("reinit");
insert("reinit", reinit);
Variable terminate(ty["Real"].get(), 0, nullptr, nullptr, vector<int>(1, 0), false);
terminate.setBuiltIn();
terminate.setName("terminate");
insert("terminate", terminate);
Variable chain_rule(ty["Real"].get(), TP_LOCAL, nullptr, nullptr, vector<int>(1, 0), false);
chain_rule.setBuiltIn();
chain_rule.setName("aux");
Expand Down
2 changes: 1 addition & 1 deletion src/mmoc/util/symbol_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class Variable {
inline bool hasEachModifier() { return _hasEach; };
inline void setEachModifier(bool each) { _hasEach = each; };
inline string name() const { return _name; };
inline void setName(string n) { _name = n; };
void setName(string name);
inline AST_Expression exp() { return _exp; };
inline bool isArray() const { return _isArray; };
inline bool isScalar() { return !isArray(); };
Expand Down
4 changes: 2 additions & 2 deletions src/mmoc/util/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ Option<CompiledPackage> Utils::readPackage(string file_name, bool full_path, str
{
fstream package;
string name;
string compiled_package_name = file_name;
string compiled_package_name = file_name;
if (full_path) {
name = file_name;
assert(!compiled_package_name.empty());
Expand Down Expand Up @@ -359,7 +359,7 @@ Variable Utils::variable(AST_Expression exp)
}
Option<Variable> var = ModelConfig::instance().lookup(var_name);
if (!var) {
Error::instance().add(exp->lineNum(), EM_IR | EM_VARIABLE_NOT_FOUND, ER_Error, "utils.cpp:342 %s", var_name.c_str());
Error::instance().add(exp->lineNum(), EM_IR | EM_VARIABLE_NOT_FOUND, ER_Fatal, "utils.cpp:342 %s", var_name.c_str());
}
return var.get();
}
Expand Down

0 comments on commit 83dd66c

Please sign in to comment.