Skip to content

Commit

Permalink
Update type module interface.
Browse files Browse the repository at this point in the history
  • Loading branch information
joaquinffernandez committed Aug 27, 2024
1 parent 9e0a6c0 commit 40d55d0
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 323 deletions.
2 changes: 1 addition & 1 deletion src/mmoc/util/ast_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ bool EqualExp::equalTraverseElement(AST_Expression a, AST_Expression b)
case EXPCOMPREF: {
AST_Expression_ComponentReference compRefA = a->getAsComponentReference();
Option<Variable> varInfoA = ModelConfig::instance().lookup(CREF_NAME(compRefA));
if (varInfoA && varInfoA->type()->getType() == TYARRAY) {
if (varInfoA && varInfoA->type()->getType() == SymbolType::TYARRAY) {
return compareArrays(compRefA, b->getAsComponentReference());
} else {
return CREF_NAME(a).compare(CREF_NAME(b)) == 0;
Expand Down
1 change: 1 addition & 0 deletions src/mmoc/util/model_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class ModelConfig {
inline void clearLocalSymbols() { _local_symbols.clear(); };
inline void setLocalInitSymbols() { _init_symbols = true; };
inline void unsetLocalInitSymbols() { _init_symbols = false; };

inline void setEvents(IR::EventTable events) { _events = events; }
inline IR::EventTable events() const { return _events; }
inline bool functionOutputs() const { return _function_outputs; }
Expand Down
33 changes: 9 additions & 24 deletions src/mmoc/util/type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#include "type.h"

#include "../ast/ast_builder.h"
#include <ast/ast_builder.h>

ostream &operator<<(ostream &os, const Type_ &e)
{
Expand All @@ -35,10 +35,6 @@ ostream &operator<<(ostream &os, const Type &e)
return os;
}

Type_Real_::Type_Real_() {}

Type_Real_::~Type_Real_() {}

string Type_Real_::print() const
{
stringstream ret(stringstream::out);
Expand All @@ -50,10 +46,6 @@ Type_Real newType_Real() { return new Type_Real_(); }

void deleteType_Real(Type_Real m) { delete m; }

Type_Integer_::Type_Integer_() {}

Type_Integer_::~Type_Integer_() {}

string Type_Integer_::print() const
{
stringstream ret(stringstream::out);
Expand All @@ -72,8 +64,6 @@ string Type_Boolean_::print() const
return ret.str();
}

Type_String_::~Type_String_() {}

string Type_String_::print() const
{
stringstream ret(stringstream::out);
Expand All @@ -91,7 +81,7 @@ string Type_Array_::print() const
AST_ExpressionList exls = newAST_ExpressionList();
Type tt = _t;
AST_ListPrepend(exls, _dim);
while (tt->getType() == TYARRAY) {
while (tt->getType() == SymbolType::TYARRAY) {
AST_ListPrepend(exls, tt->getAsArray()->dimension());
tt = tt->getAsArray()->arrayOf();
}
Expand All @@ -107,8 +97,6 @@ string Type_Array_::print() const

Type_Array_::Type_Array_(Type t, AST_Expression dim) : _t(t), _dim(dim){};

Type_Array_::~Type_Array_() {}

Type Type_Array_::arrayOf() { return _t; }

Type_Array Type_::getAsArray() { return dynamic_cast<Type_Array_ *>(this); }
Expand All @@ -121,9 +109,9 @@ int operator==(Type_ &e1, Type_ &e2)
{
if (e1.getType() == e2.getType()) {
switch (e1.getType()) {
case TYARRAY:
case SymbolType::TYARRAY:
return *(e1.getAsArray()->arrayOf()) == e2.getAsArray()->arrayOf();
case TYTUPLA: {
case SymbolType::TYTUPLA: {
Type_Tupla t1 = e1.getAsTupla(), t2 = e2.getAsTupla();
if (t2->tupla()->size() != t1->tupla()->size()) return 0;
TypeListIterator it1 = t1->tupla()->begin(), it2 = t1->tupla()->begin();
Expand All @@ -133,8 +121,7 @@ int operator==(Type_ &e1, Type_ &e2)
}
return 1;
}
case TYFUNCTION: // No es necesario!!
{
case SymbolType::TYFUNCTION: {
Type_Function f1 = e1.getAsFunction(), f2 = e2.getAsFunction();
return *(f1->output()) == f2->output();
}
Expand All @@ -153,13 +140,12 @@ int operator!=(Type_ &e1, Type e2) { return !(e1 == *e2); }

Type_Tupla_::Type_Tupla_(TypeList tyl) : _tyl(tyl){};

Type_Tupla_::~Type_Tupla_() {}

string Type_Tupla_::print() const
{
stringstream ret(stringstream::out);
TypeListIterator tyit;
int i = 0, s = _tyl->size();
unsigned long i = 0;
unsigned long s = _tyl->size();
ret << "< ";
foreach (tyit, _tyl) {
i++;
Expand All @@ -172,13 +158,12 @@ string Type_Tupla_::print() const

Type_Function_::Type_Function_(Type o, TypeList i) : _input(i), _output(o){};

Type_Function_::~Type_Function_() {}

string Type_Function_::print() const
{
stringstream ret(stringstream::out);
TypeListIterator tyit;
int i = 0, s = _input->size();
unsigned long i = 0;
unsigned long s = _input->size();

ret << _output << " function ";

Expand Down
Loading

0 comments on commit 40d55d0

Please sign in to comment.