Skip to content
GitLab
Explorer
Connexion
Navigation principale
Rechercher ou aller à…
Projet
Vivy
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Wiki externe
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté GitLab
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
Elliu
Vivy
Validations
c3b1855d
Vérifiée
Valider
c3b1855d
rédigé
Il y a 3 ans
par
Kubat
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
WIP: Continue the implementation of the IrType
parent
eb3a19b8
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion
!25
Draft: New Vivy module spec
Modifications
2
Afficher les modifications d'espaces
En ligne
Côte à côte
Affichage de
2 fichiers modifiés
src/Lib/Script/Ast/IrType.cc
+80
-3
80 ajouts, 3 suppressions
src/Lib/Script/Ast/IrType.cc
src/Lib/Script/Ast/IrType.hh
+23
-6
23 ajouts, 6 suppressions
src/Lib/Script/Ast/IrType.hh
avec
103 ajouts
et
9 suppressions
src/Lib/Script/Ast/IrType.cc
+
80
−
3
Voir le fichier @
c3b1855d
...
@@ -26,6 +26,35 @@ IrType::~IrType() noexcept {}
...
@@ -26,6 +26,35 @@ IrType::~IrType() noexcept {}
namespace
Vivy
::
Script
namespace
Vivy
::
Script
{
{
IrTAss
::
IrTAss
(
const
Token
&
name
)
{
setSelfInnerTypeFromToken
(
name
);
}
IrTAss
::
IrTAss
(
const
AssType
type
,
unsigned
int
size
)
noexcept
:
selfInnerType
(
type
)
,
selfArraySize
(
size
)
{
}
IrTAss
::
IrTAss
(
const
AssType
type
)
noexcept
:
AssType
(
type
,
1
)
{
}
void
IrTAss
::
setSelfInnerTypeFromToken
(
const
Token
&
name
)
{
name
.
assertType
(
Token
::
Type
::
SIMPLE
);
if
(
name
.
isSimple
(
TOKEN_LINE
))
{
selfInnerType
=
IrType
::
AssType
::
Line
;
}
else
if
(
name
.
isSimple
(
TOKEN_SYLLABE
))
{
selfInnerType
=
IrType
::
AssType
::
Syllabe
;
}
else
{
throw
std
::
logic_error
(
"IrTPrimitive unexpected token "
+
name
.
toString
());
}
}
IrType
::
Type
IrType
::
Type
IrTAss
::
type
()
const
noexcept
IrTAss
::
type
()
const
noexcept
{
{
...
@@ -41,7 +70,13 @@ IrTAss::innerType() const noexcept
...
@@ -41,7 +70,13 @@ IrTAss::innerType() const noexcept
unsigned
int
unsigned
int
IrTAss
::
innerTypeCount
()
const
noexcept
IrTAss
::
innerTypeCount
()
const
noexcept
{
{
return
selfArraySize
;
/* 0 is same as 1, it's not an array! */
const
unsigned
int
ret
=
std
::
reduce
(
std
::
execution
::
seq
,
std
::
begin
(
arraySizes
),
std
::
end
(
arraySizes
),
1
,
[](
unsigned
int
a
,
unsigned
int
b
)
noexcept
->
unsigned
int
{
return
a
*
b
;
}
);
return
ret
<=
1
?
1
:
ret
;
}
}
std
::
string
std
::
string
...
@@ -50,6 +85,28 @@ IrTAss::toString() const noexcept
...
@@ -50,6 +85,28 @@ IrTAss::toString() const noexcept
return
"IrTAss"
;
return
"IrTAss"
;
}
}
bool
IrTAss
::
isArray
()
const
{
return
selfArraySize
>=
2
;
}
unsigned
int
IrTAss
::
getArrayDimensions
()
const
{
isArray
()
?
selfArraySize
:
0
;
}
unsigned
int
IrTAss
::
getArrayDimensionAt
(
unsigned
int
level
)
const
{
return
level
>=
selfArraySize
?
0
:
arraySizes
.
at
(
level
);
}
void
IrTAss
::
assertInnerType
(
AssType
type
)
const
{
if
(
innerType
()
!=
t
)
{
throw
std
::
runtime_error
(
"Expected inner type "
+
std
::
to_string
(
static_cast
<
int
>
(
t
))
+
" but was type "
+
std
::
to_string
(
static_cast
<
int
>
(
innerType
())));
}
}
void
void
IrTAss
::
parse
(
std
::
vector
<
Token
>
*
)
IrTAss
::
parse
(
std
::
vector
<
Token
>
*
)
{
{
...
@@ -148,11 +205,31 @@ IrTPrimitive::innerType() const noexcept
...
@@ -148,11 +205,31 @@ IrTPrimitive::innerType() const noexcept
return
selfInnerType
;
return
selfInnerType
;
}
}
bool
IrTPrimitive
::
isArray
()
const
{
return
selfArraySize
>=
2
;
}
unsigned
int
IrTPrimitive
::
getArrayDimensions
()
const
{
isArray
()
?
selfArraySize
:
0
;
}
unsigned
int
IrTPrimitive
::
getArrayDimensionAt
(
unsigned
int
level
)
const
{
return
level
>=
selfArraySize
?
0
:
arraySizes
.
at
(
level
);
}
unsigned
int
unsigned
int
IrT
Primitive
::
innerTypeCount
()
const
noexcept
IrT
Ass
::
innerTypeCount
()
const
noexcept
{
{
/* 0 is same as 1, it's not an array! */
/* 0 is same as 1, it's not an array! */
return
selfArraySize
<=
1
?
1
:
selfArraySize
;
const
unsigned
int
ret
=
std
::
reduce
(
std
::
execution
::
seq
,
std
::
begin
(
arraySizes
),
std
::
end
(
arraySizes
),
1
,
[](
unsigned
int
a
,
unsigned
int
b
)
noexcept
->
unsigned
int
{
return
a
*
b
;
}
);
return
ret
<=
1
?
1
:
ret
;
}
}
std
::
string
std
::
string
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
src/Lib/Script/Ast/IrType.hh
+
23
−
6
Voir le fichier @
c3b1855d
...
@@ -23,13 +23,26 @@ class IrTAss final : public IrType {
...
@@ -23,13 +23,26 @@ class IrTAss final : public IrType {
VIVY_IR_ELEMENT
(
IrTAss
)
VIVY_IR_ELEMENT
(
IrTAss
)
AssType
selfType
;
AssType
selfType
;
unsigned
int
selfArraySize
=
1
;
/* One for no array! */
unsigned
int
selfArraySize
=
1
;
std
::
vector
<
unsigned
int
>
arraySizes
=
{
1
};
IrTAss
(
const
Token
&
);
IrTAss
(
const
AssType
)
noexcept
;
IrTAss
(
const
AssType
,
unsigned
int
)
noexcept
;
void
setSelfInnerTypeFromToken
(
const
Token
&
name
);
public
:
public
:
Type
type
()
const
noexcept
override
;
Type
type
()
const
noexcept
override
;
AssType
innerType
()
const
noexcept
;
AssType
innerType
()
const
noexcept
;
unsigned
int
innerTypeCount
()
const
noexcept
;
unsigned
int
innerTypeCount
()
const
noexcept
;
void
assertInnerType
(
AssType
)
const
;
bool
isArray
()
const
;
unsigned
int
getArrayDimensions
()
const
;
unsigned
int
getArrayDimensionAt
(
unsigned
int
level
)
const
;
std
::
string
toString
()
const
noexcept
override
;
std
::
string
toString
()
const
noexcept
override
;
void
parse
(
std
::
vector
<
Token
>
*
)
override
;
void
parse
(
std
::
vector
<
Token
>
*
)
override
;
};
};
...
@@ -37,7 +50,7 @@ public:
...
@@ -37,7 +50,7 @@ public:
class
IrTOption
final
:
public
IrType
{
class
IrTOption
final
:
public
IrType
{
VIVY_IR_ELEMENT
(
IrTOption
)
VIVY_IR_ELEMENT
(
IrTOption
)
IrOption
*
selfInnerOption
;
IrOption
*
selfInnerOption
=
nullptr
;
public:
public:
Type
type
()
const
noexcept
override
;
Type
type
()
const
noexcept
override
;
...
@@ -51,7 +64,7 @@ class IrTPrimitive final : public IrType {
...
@@ -51,7 +64,7 @@ class IrTPrimitive final : public IrType {
VIVY_IR_ELEMENT
(
IrTPrimitive
)
VIVY_IR_ELEMENT
(
IrTPrimitive
)
PrimitiveType
selfInnerType
;
PrimitiveType
selfInnerType
;
unsigned
int
selfArraySize
;
unsigned
int
selfArraySize
=
1
;
std
::
vector
<
unsigned
int
>
arraySizes
=
{
1
};
std
::
vector
<
unsigned
int
>
arraySizes
=
{
1
};
IrTPrimitive
(
const
Token
&
);
IrTPrimitive
(
const
Token
&
);
...
@@ -67,24 +80,28 @@ public:
...
@@ -67,24 +80,28 @@ public:
void
assertInnerType
(
PrimitiveType
)
const
;
void
assertInnerType
(
PrimitiveType
)
const
;
bool
isArray
()
const
;
unsigned
int
getArrayDimensions
()
const
;
unsigned
int
getArrayDimensionAt
(
unsigned
int
level
)
const
;
std
::
string
toString
()
const
noexcept
override
;
std
::
string
toString
()
const
noexcept
override
;
void
parse
(
std
::
vector
<
Token
>
*
)
override
;
void
parse
(
std
::
vector
<
Token
>
*
)
override
;
};
};
[[
maybe_unused
]]
static
bool
[[
maybe_unused
]]
static
bool
operator
==
(
const
::
Vivy
::
Script
::
IrTAss
&
a
,
const
::
Vivy
::
Script
::
IrTAss
&
b
)
operator
==
(
const
::
Vivy
::
Script
::
IrTAss
&
a
,
const
::
Vivy
::
Script
::
IrTAss
&
b
)
noexcept
{
{
return
(
a
.
innerType
()
==
b
.
innerType
())
&&
(
a
.
innerTypeCount
()
==
b
.
innerTypeCount
());
return
(
a
.
innerType
()
==
b
.
innerType
())
&&
(
a
.
innerTypeCount
()
==
b
.
innerTypeCount
());
}
}
[[
maybe_unused
]]
static
bool
[[
maybe_unused
]]
static
bool
operator
==
(
const
::
Vivy
::
Script
::
IrTPrimitive
&
a
,
const
::
Vivy
::
Script
::
IrTPrimitive
&
b
)
operator
==
(
const
::
Vivy
::
Script
::
IrTPrimitive
&
a
,
const
::
Vivy
::
Script
::
IrTPrimitive
&
b
)
noexcept
{
{
return
(
a
.
innerType
()
==
b
.
innerType
())
&&
(
a
.
innerTypeCount
()
==
b
.
innerTypeCount
());
return
(
a
.
innerType
()
==
b
.
innerType
())
&&
(
a
.
innerTypeCount
()
==
b
.
innerTypeCount
());
}
}
[[
maybe_unused
]]
static
bool
[[
maybe_unused
]]
static
bool
operator
==
(
const
::
Vivy
::
Script
::
IrType
&
a
,
const
::
Vivy
::
Script
::
IrType
&
b
)
operator
==
(
const
::
Vivy
::
Script
::
IrType
&
a
,
const
::
Vivy
::
Script
::
IrType
&
b
)
noexcept
{
{
if
(
a
.
type
()
!=
b
.
type
())
if
(
a
.
type
()
!=
b
.
type
())
return
false
;
return
false
;
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter