Files
PorygonLang/src/ScriptType.hpp
2019-05-28 18:50:23 +02:00

59 lines
1.1 KiB
C++

#ifndef PORYGONLANG_SCRIPTTYPE_HPP
#define PORYGONLANG_SCRIPTTYPE_HPP
enum class TypeClass{
Error,
Nil,
Number,
Bool,
String,
Function,
UserData,
Table,
};
class ScriptType{
TypeClass _class;
public:
explicit ScriptType(TypeClass c){
_class = c;
}
virtual ~ScriptType() = default;
const TypeClass GetClass(){
return _class;
}
virtual bool operator ==(ScriptType b){
return _class == b._class;
};
virtual bool operator !=(ScriptType b){
return ! (operator==(b));
}
};
class NumericScriptType : public ScriptType{
// Are we aware of whether this is a float or not?
bool _awareOfFloat;
// Is this value a float?
bool _isFloat;
public:
explicit NumericScriptType(bool floatAware, bool isFloat) : ScriptType(TypeClass::Number){
_awareOfFloat = floatAware;
_isFloat = isFloat;
}
bool IsAwareOfFloat(){
return _awareOfFloat;
}
bool IsFloat(){
return _isFloat;
}
};
#endif //PORYGONLANG_SCRIPTTYPE_HPP