Skip to content

Commit

Permalink
Adds helper functions Type::is*() and getQualifiedName()
Browse files Browse the repository at this point in the history
Issue: #17
Issue: #92
  • Loading branch information
0x7CFE committed Jul 9, 2016
1 parent 31ff87f commit 63aacb2
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions include/inference.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ class Type {
m_value = klass;
}

bool isUndefined() const { return m_kind == tkUndefined; }
bool isLiteral() const { return m_kind == tkLiteral; }
bool isMonotype() const { return m_kind == tkMonotype; }
bool isComposite() const { return m_kind == tkComposite; }
bool isArray() const { return m_kind == tkArray; }
bool isPolytype() const { return m_kind == tkPolytype; }

const TSubTypes& getSubTypes() const { return m_subTypes; }

Type& pushSubType(const Type& type) { m_subTypes.push_back(type); return m_subTypes.back(); }
Expand Down Expand Up @@ -272,6 +279,13 @@ class Type {
typedef std::size_t TNodeIndex;
typedef std::map<TNodeIndex, Type> TTypeMap;

inline std::string getQualifiedMethodName(TMethod* method, const Type& arguments) {
return
arguments.toString(true) + "::" +
method->getClass()->name->toString() + ">>" +
method->name->toString();
}

class InferContext {
public:
InferContext(TMethod* method, std::size_t index, const Type& arguments) :
Expand All @@ -282,6 +296,8 @@ class InferContext {
m_recursionKind(rkUnknown)
{}

std::string getQualifiedName() const { return getQualifiedMethodName(m_method, m_arguments); }

TMethod* getMethod() const { return m_method; }
std::size_t getIndex() const { return m_index; }

Expand Down

0 comments on commit 63aacb2

Please sign in to comment.