Skip to content

Commit

Permalink
Removed uses of old get type in ast2ram main.
Browse files Browse the repository at this point in the history
  • Loading branch information
azreika committed Nov 2, 2020
1 parent d0f654b commit a7158b1
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/ast2ram/AstToRamTranslator.cpp
Expand Up @@ -243,9 +243,8 @@ Own<ram::Expression> AstToRamTranslator::translateValue(const ast::Argument* arg
}

Own<ram::Expression> visitNumericConstant(const ast::NumericConstant& c) override {
assert(c.getType().has_value() && "At this points all constants should have type.");

switch (*c.getType()) {
assert(!polyAnalysis->hasInvalidType(&c) && "constant should have valid type");
switch (polyAnalysis->getOverloadedType(&c)) {
case ast::NumericConstant::Type::Int:
return mk<ram::SignedConstant>(RamSignedFromString(c.getConstant(), nullptr, 0));
case ast::NumericConstant::Type::Uint:
Expand Down Expand Up @@ -400,8 +399,8 @@ RamDomain AstToRamTranslator::getConstantRamRepresentation(const ast::Constant&
} else if (isA<ast::NilConstant>(&constant)) {
return 0;
} else if (auto* numConstant = dynamic_cast<const ast::NumericConstant*>(&constant)) {
assert(numConstant->getType().has_value());
switch (*numConstant->getType()) {
assert(!polyAnalysis->hasInvalidType(numConstant) && "constant should have valid type");
switch (polyAnalysis->getOverloadedType(numConstant)) {
case ast::NumericConstant::Type::Int:
return RamSignedFromString(numConstant->getConstant(), nullptr, 0);
case ast::NumericConstant::Type::Uint:
Expand All @@ -417,7 +416,7 @@ Own<ram::Expression> AstToRamTranslator::translateConstant(ast::Constant const&
auto const rawConstant = getConstantRamRepresentation(c);

if (auto* const c_num = dynamic_cast<const ast::NumericConstant*>(&c)) {
switch (*c_num->getType()) {
switch (polyAnalysis->getOverloadedType(c_num)) {
case ast::NumericConstant::Type::Int: return mk<ram::SignedConstant>(rawConstant);
case ast::NumericConstant::Type::Uint: return mk<ram::UnsignedConstant>(rawConstant);
case ast::NumericConstant::Type::Float: return mk<ram::FloatConstant>(rawConstant);
Expand Down

0 comments on commit a7158b1

Please sign in to comment.