Skip to content
Extraits de code Groupes Projets
Vérifiée Valider b9cbae06 rédigé par Kubat's avatar Kubat
Parcourir les fichiers

SCRIPT: Add a name getter for IrVariable + add constructors and enforce the...

SCRIPT: Add a name getter for IrVariable + add constructors and enforce the const-ness of the name of a variable
parent 23b8fdfb
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!25Draft: New Vivy module spec
Pipeline #2877 réussi
...@@ -26,7 +26,7 @@ private: ...@@ -26,7 +26,7 @@ private:
** the right and update the current expression pointer. ** the right and update the current expression pointer.
*/ */
template <typename IrT> IrExpression *createOpElement(IrExpression *&current, Token tok) template <IrElementObject IrT> IrExpression *createOpElement(IrExpression *&current, Token tok)
{ {
return dynamic_cast<IrExpression *>( return dynamic_cast<IrExpression *>(
IrElement::create<IrT>(nullptr, /* The parent, will be set later */ IrElement::create<IrT>(nullptr, /* The parent, will be set later */
......
...@@ -6,6 +6,18 @@ ...@@ -6,6 +6,18 @@
namespace Vivy::Script namespace Vivy::Script
{ {
IrVariable::IrVariable(StrV name) noexcept
: IrElement(nullptr)
, selfName(name)
{
}
StrV
IrVariable::name() const noexcept
{
return selfName;
}
std::string std::string
IrVariable::toString() const noexcept IrVariable::toString() const noexcept
{ {
...@@ -26,6 +38,11 @@ IrVariable::innerType() const noexcept ...@@ -26,6 +38,11 @@ IrVariable::innerType() const noexcept
namespace Vivy::Script namespace Vivy::Script
{ {
IrVPrimitive::IrVPrimitive(StrV name) noexcept
: IrVariable(name)
{
}
IrVariable::Type IrVariable::Type
IrVPrimitive::type() const noexcept IrVPrimitive::type() const noexcept
{ {
...@@ -41,6 +58,11 @@ IrVPrimitive::toString() const noexcept ...@@ -41,6 +58,11 @@ IrVPrimitive::toString() const noexcept
namespace Vivy::Script namespace Vivy::Script
{ {
IrVTable::IrVTable(StrV name) noexcept
: IrVariable(name)
{
}
IrVariable::Type IrVariable::Type
IrVTable::type() const noexcept IrVTable::type() const noexcept
{ {
......
#pragma once #pragma once
#include "IrElement.hh" #include "IrElement.hh"
#include "Lib/Script/FrontEnd/StrV.hh"
namespace Vivy::Script namespace Vivy::Script
{ {
...@@ -8,19 +9,25 @@ class IrVariable : public IrElement { ...@@ -8,19 +9,25 @@ class IrVariable : public IrElement {
VIVY_IR_ELEMENT(IrVariable) VIVY_IR_ELEMENT(IrVariable)
IrType *selfInnerType = nullptr; IrType *selfInnerType = nullptr;
const StrV selfName;
protected:
IrVariable(StrV name) noexcept;
public: public:
enum class Type { Primitive, Table }; enum class Type { Primitive, Table };
public:
virtual Type type() const noexcept = 0; virtual Type type() const noexcept = 0;
const IrType *innerType() const noexcept; const IrType *innerType() const noexcept;
std::string toString() const noexcept override; std::string toString() const noexcept override;
StrV name() const noexcept;
}; };
class IrVPrimitive : public IrVariable { class IrVPrimitive : public IrVariable {
VIVY_IR_ELEMENT(IrVPrimitive) VIVY_IR_ELEMENT(IrVPrimitive)
IrVPrimitive(StrV) noexcept;
public: public:
Type type() const noexcept override; Type type() const noexcept override;
std::string toString() const noexcept override; std::string toString() const noexcept override;
...@@ -29,6 +36,8 @@ public: ...@@ -29,6 +36,8 @@ public:
class IrVTable : public IrVariable { class IrVTable : public IrVariable {
VIVY_IR_ELEMENT(IrVTable) VIVY_IR_ELEMENT(IrVTable)
IrVTable(StrV) noexcept;
public: public:
Type type() const noexcept override; Type type() const noexcept override;
std::string toString() const noexcept override; std::string toString() const noexcept override;
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter