diff --git a/src/Lib/Script/Ast/IrExpression.hh b/src/Lib/Script/Ast/IrExpression.hh index fa03a36df7fba3957708a4047bd60801b865d54f..cb8bf1a47c09a1a7855200de0ef41251665277ac 100644 --- a/src/Lib/Script/Ast/IrExpression.hh +++ b/src/Lib/Script/Ast/IrExpression.hh @@ -26,7 +26,7 @@ private: ** the right and update the current expression pointer. */ - template <typename IrT> IrExpression *createOpElement(IrExpression *¤t, Token tok) + template <IrElementObject IrT> IrExpression *createOpElement(IrExpression *¤t, Token tok) { return dynamic_cast<IrExpression *>( IrElement::create<IrT>(nullptr, /* The parent, will be set later */ diff --git a/src/Lib/Script/Ast/IrVariable.cc b/src/Lib/Script/Ast/IrVariable.cc index 573c0130ec6358a86246950b69cbe20f82ecf83f..f844b3a98c8aefd1246f3c72e94c29962e525341 100644 --- a/src/Lib/Script/Ast/IrVariable.cc +++ b/src/Lib/Script/Ast/IrVariable.cc @@ -6,6 +6,18 @@ namespace Vivy::Script { +IrVariable::IrVariable(StrV name) noexcept + : IrElement(nullptr) + , selfName(name) +{ +} + +StrV +IrVariable::name() const noexcept +{ + return selfName; +} + std::string IrVariable::toString() const noexcept { @@ -26,6 +38,11 @@ IrVariable::innerType() const noexcept namespace Vivy::Script { +IrVPrimitive::IrVPrimitive(StrV name) noexcept + : IrVariable(name) +{ +} + IrVariable::Type IrVPrimitive::type() const noexcept { @@ -41,6 +58,11 @@ IrVPrimitive::toString() const noexcept namespace Vivy::Script { +IrVTable::IrVTable(StrV name) noexcept + : IrVariable(name) +{ +} + IrVariable::Type IrVTable::type() const noexcept { diff --git a/src/Lib/Script/Ast/IrVariable.hh b/src/Lib/Script/Ast/IrVariable.hh index 161fa99e63f01c19804e8092f509153c7dff853f..d25d9a5f7b25efb3f032505652e2640c1c4fecc2 100644 --- a/src/Lib/Script/Ast/IrVariable.hh +++ b/src/Lib/Script/Ast/IrVariable.hh @@ -1,6 +1,7 @@ #pragma once #include "IrElement.hh" +#include "Lib/Script/FrontEnd/StrV.hh" namespace Vivy::Script { @@ -8,19 +9,25 @@ class IrVariable : public IrElement { VIVY_IR_ELEMENT(IrVariable) IrType *selfInnerType = nullptr; + const StrV selfName; + +protected: + IrVariable(StrV name) noexcept; public: enum class Type { Primitive, Table }; -public: virtual Type type() const noexcept = 0; const IrType *innerType() const noexcept; std::string toString() const noexcept override; + StrV name() const noexcept; }; class IrVPrimitive : public IrVariable { VIVY_IR_ELEMENT(IrVPrimitive) + IrVPrimitive(StrV) noexcept; + public: Type type() const noexcept override; std::string toString() const noexcept override; @@ -29,6 +36,8 @@ public: class IrVTable : public IrVariable { VIVY_IR_ELEMENT(IrVTable) + IrVTable(StrV) noexcept; + public: Type type() const noexcept override; std::string toString() const noexcept override;