Implements indexing with period identifier style (`foo.bar`)
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
#include <utility>
|
||||
|
||||
|
||||
#ifndef PORYGONLANG_SCRIPTTYPE_HPP
|
||||
#define PORYGONLANG_SCRIPTTYPE_HPP
|
||||
@@ -30,28 +32,34 @@ public:
|
||||
|
||||
virtual ~ScriptType() = default;
|
||||
|
||||
const TypeClass GetClass(){
|
||||
const TypeClass GetClass() const{
|
||||
return _class;
|
||||
}
|
||||
|
||||
virtual bool operator ==(const ScriptType& b){
|
||||
virtual bool operator ==(const ScriptType& b) const{
|
||||
return _class == b._class;
|
||||
};
|
||||
|
||||
virtual bool operator ==(ScriptType* b){
|
||||
virtual bool operator ==(ScriptType* b) const{
|
||||
return _class == b->_class;
|
||||
};
|
||||
|
||||
virtual bool operator !=(const ScriptType& b){
|
||||
virtual bool operator !=(const ScriptType& b) const{
|
||||
return ! (operator==(b));
|
||||
}
|
||||
virtual bool operator !=(ScriptType* b){
|
||||
virtual bool operator !=(ScriptType* b) const{
|
||||
return ! (operator==(b));
|
||||
}
|
||||
|
||||
virtual bool CanBeIndexedWith(ScriptType* indexer);
|
||||
virtual const bool CanBeIndexedWith(ScriptType* indexer) const;
|
||||
virtual const bool CanBeIndexedWithIdentifier(uint32_t hash) const{
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual shared_ptr<ScriptType> GetIndexedType(ScriptType* indexer);
|
||||
virtual const shared_ptr<ScriptType> GetIndexedType(ScriptType* indexer) const;
|
||||
virtual const shared_ptr<ScriptType> GetIndexedType(uint32_t hash) const{
|
||||
throw "Shouldn't be possible";
|
||||
}
|
||||
};
|
||||
|
||||
class NumericScriptType : public ScriptType{
|
||||
@@ -65,11 +73,11 @@ public:
|
||||
_isFloat = isFloat;
|
||||
}
|
||||
|
||||
bool IsAwareOfFloat(){
|
||||
const bool IsAwareOfFloat() const{
|
||||
return _awareOfFloat;
|
||||
}
|
||||
|
||||
bool IsFloat(){
|
||||
const bool IsFloat() const{
|
||||
return _isFloat;
|
||||
}
|
||||
};
|
||||
@@ -83,11 +91,11 @@ public:
|
||||
_hashValue = hashValue;
|
||||
}
|
||||
|
||||
bool IsKnownAtBind(){
|
||||
const bool IsKnownAtBind() const{
|
||||
return _isKnownAtBind;
|
||||
}
|
||||
|
||||
uint32_t GetHashValue(){
|
||||
const uint32_t GetHashValue() const{
|
||||
return _hashValue;
|
||||
}
|
||||
};
|
||||
@@ -106,23 +114,23 @@ public:
|
||||
_parameterKeys = std::move(parameterKeys);
|
||||
_scopeIndex = scopeIndex;
|
||||
}
|
||||
shared_ptr<ScriptType> GetReturnType(){
|
||||
const shared_ptr<ScriptType> GetReturnType() const{
|
||||
return _returnType;
|
||||
}
|
||||
|
||||
void SetReturnType(shared_ptr<ScriptType> t){
|
||||
_returnType = t;
|
||||
_returnType = std::move(t);
|
||||
}
|
||||
|
||||
vector<shared_ptr<ScriptType>> GetParameterTypes(){
|
||||
const vector<shared_ptr<ScriptType>> GetParameterTypes() const{
|
||||
return _parameterTypes;
|
||||
}
|
||||
|
||||
vector<shared_ptr<BoundVariableKey>> GetParameterKeys(){
|
||||
const vector<shared_ptr<BoundVariableKey>> GetParameterKeys() const{
|
||||
return _parameterKeys;
|
||||
}
|
||||
|
||||
int GetScopeIndex(){
|
||||
const int GetScopeIndex() const{
|
||||
return _scopeIndex;
|
||||
}
|
||||
};
|
||||
@@ -135,11 +143,11 @@ public:
|
||||
_valueType = std::move(valueType);
|
||||
}
|
||||
|
||||
bool CanBeIndexedWith(ScriptType* indexer) final{
|
||||
const bool CanBeIndexedWith(ScriptType* indexer) const final{
|
||||
return indexer->GetClass() == TypeClass ::Number;
|
||||
}
|
||||
|
||||
shared_ptr<ScriptType> GetIndexedType(ScriptType* indexer) final{
|
||||
const shared_ptr<ScriptType> GetIndexedType(ScriptType* indexer) const final{
|
||||
return _valueType;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user