Skip to content

Commit

Permalink
Type
Browse files Browse the repository at this point in the history
* renamed 'AbstractType' to ''AbstractionType'
  - related to ref sealangdotorg/sea#30
  - related to ref sealangdotorg/sea#31
* added missing 'Type::is*()' helper methods
  • Loading branch information
ppaulweber committed Jun 8, 2017
1 parent f326674 commit 78c35fd
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 11 deletions.
31 changes: 26 additions & 5 deletions src/Type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ std::string Type::make_hash( void ) const
return "t:" + std::to_string( id() ) + ":" + description();
}

u1 Type::isSynthetic( void ) const
{
return isVoid() or isLabel() or isLocation() or isRelation();
}

u1 Type::isVoid( void ) const
{
return id() == Type::VOID;
Expand All @@ -93,6 +98,12 @@ u1 Type::isRelation( void ) const
return id() == Type::RELATION;
}

u1 Type::isPrimitive( void ) const
{
return isBoolean() or isInteger() or isBit() or isString() or isFloating()
or isRational();
}

u1 Type::isBoolean( void ) const
{
return id() == Type::BOOLEAN;
Expand Down Expand Up @@ -123,6 +134,11 @@ u1 Type::isRational( void ) const
return id() == Type::RATIONAL;
}

u1 Type::isComposed( void ) const
{
return isEnumeration() or isRange() or isTuple() or isList();
}

u1 Type::isEnumeration( void ) const
{
return id() == Type::ENUMERATION;
Expand Down Expand Up @@ -158,6 +174,11 @@ u1 Type::isFunctionReference( void ) const
return id() == Type::FUNCTION_REFERENCE;
}

u1 Type::isAbstraction( void ) const
{
return isFile() or isPort();
}

u1 Type::isFile( void ) const
{
return id() == Type::FILE;
Expand Down Expand Up @@ -244,7 +265,7 @@ std::string Type::token( const Type::ID id )
{
return "FuncRef";
}
// abstract
// abstraction
case FILE:
{
return "File";
Expand Down Expand Up @@ -1074,10 +1095,10 @@ FunctionReferenceType::FunctionReferenceType(

//
//
// Abstract Type
// Abstraction Type
//

AbstractType::AbstractType( Type::ID id )
AbstractionType::AbstractionType( Type::ID id )
: Type( id )
{
}
Expand All @@ -1088,7 +1109,7 @@ AbstractType::AbstractType( Type::ID id )
//

FileType::FileType( void )
: AbstractType( Type::FILE )
: AbstractionType( Type::FILE )
{
// TODO: PPA: add file properties?
}
Expand Down Expand Up @@ -1120,7 +1141,7 @@ Constant FileType::choose( void ) const
//

PortType::PortType( void )
: AbstractType( Type::PORT )
: AbstractionType( Type::PORT )
{
// TODO: PPA: add port properties?
}
Expand Down
18 changes: 13 additions & 5 deletions src/Type.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ namespace libcasm_ir
RULE_REFERENCE,
FUNCTION_REFERENCE,

// abstract
// abstraction
FILE,
PORT,

Expand Down Expand Up @@ -133,23 +133,31 @@ namespace libcasm_ir
return !operator==( rhs );
}

u1 isSynthetic( void ) const;
u1 isVoid( void ) const;
u1 isLabel( void ) const;
u1 isLocation( void ) const;
u1 isRelation( void ) const;

u1 isPrimitive( void ) const;
u1 isBoolean( void ) const;
u1 isInteger( void ) const;
u1 isBit( void ) const;
u1 isString( void ) const;
u1 isFloating( void ) const;
u1 isRational( void ) const;

u1 isComposed( void ) const;
u1 isEnumeration( void ) const;
u1 isRange( void ) const;
u1 isTuple( void ) const;
u1 isList( void ) const;

u1 isReference( void ) const;
u1 isRuleReference( void ) const;
u1 isFunctionReference( void ) const;

u1 isAbstraction( void ) const;
u1 isFile( void ) const;
u1 isPort( void ) const;

Expand Down Expand Up @@ -544,13 +552,13 @@ namespace libcasm_ir
const Type::Ptr& result, const Types& arguments );
};

class AbstractType : public Type
class AbstractionType : public Type
{
public:
AbstractType( Type::ID id );
AbstractionType( Type::ID id );
};

class FileType final : public AbstractType
class FileType final : public AbstractionType
{
public:
using Ptr = std::shared_ptr< FileType >;
Expand All @@ -568,7 +576,7 @@ namespace libcasm_ir
Constant choose( void ) const override;
};

class PortType final : public AbstractType
class PortType final : public AbstractionType
{
public:
using Ptr = std::shared_ptr< PortType >;
Expand Down
2 changes: 1 addition & 1 deletion uts/Type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ TEST( libcasm_ir__Type, id_to_token_string )
EXPECT_STREQ( Type::token( id ).c_str(), "FuncRef" );
break;
}
// abstract
// abstraction
case Type::FILE:
{
EXPECT_STREQ( Type::token( id ).c_str(), "File" );
Expand Down

0 comments on commit 78c35fd

Please sign in to comment.