Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pugs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
code
pugs
Commits
8e9cab64
Commit
8e9cab64
authored
Feb 26, 2020
by
Stéphane Del Pino
Browse files
Options
Downloads
Patches
Plain Diff
Improve data type management for type_id's
parent
251e5762
No related branches found
No related tags found
1 merge request
!37
Feature/language
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/language/ASTNodeDataType.cpp
+11
-7
11 additions, 7 deletions
src/language/ASTNodeDataType.cpp
src/language/ASTNodeDataType.hpp
+12
-10
12 additions, 10 deletions
src/language/ASTNodeDataType.hpp
with
23 additions
and
17 deletions
src/language/ASTNodeDataType.cpp
+
11
−
7
View file @
8e9cab64
...
@@ -50,7 +50,7 @@ dataTypeName(const ASTNodeDataType& data_type)
...
@@ -50,7 +50,7 @@ dataTypeName(const ASTNodeDataType& data_type)
name
=
"type_name_id"
;
name
=
"type_name_id"
;
break
;
break
;
case
ASTNodeDataType
::
type_id_t
:
case
ASTNodeDataType
::
type_id_t
:
name
=
"type_id"
;
name
=
data_type
.
typeName
()
;
break
;
break
;
case
ASTNodeDataType
::
function_t
:
case
ASTNodeDataType
::
function_t
:
name
=
"function"
;
name
=
"function"
;
...
@@ -91,18 +91,22 @@ bool
...
@@ -91,18 +91,22 @@ bool
isNaturalConversion
(
const
ASTNodeDataType
&
data_type
,
const
ASTNodeDataType
&
target_data_type
)
isNaturalConversion
(
const
ASTNodeDataType
&
data_type
,
const
ASTNodeDataType
&
target_data_type
)
{
{
if
(
target_data_type
==
data_type
)
{
if
(
target_data_type
==
data_type
)
{
if
(
data_type
!=
ASTNodeDataType
::
type_id_t
)
{
return
true
;
return
true
;
}
else
{
return
{
data_type
.
typeName
()
==
target_data_type
.
typeName
()};
}
}
else
if
(
target_data_type
==
ASTNodeDataType
::
bool_t
)
{
}
else
if
(
target_data_type
==
ASTNodeDataType
::
bool_t
)
{
return
false
;
return
false
;
}
else
if
(
target_data_type
==
ASTNodeDataType
::
unsigned_int_t
)
{
}
else
if
(
target_data_type
==
ASTNodeDataType
::
unsigned_int_t
)
{
return
(
(
data_type
==
ASTNodeDataType
::
int_t
)
or
(
data_type
==
ASTNodeDataType
::
bool_t
)
)
;
return
{
(
data_type
==
ASTNodeDataType
::
int_t
)
or
(
data_type
==
ASTNodeDataType
::
bool_t
)
}
;
}
else
if
(
target_data_type
==
ASTNodeDataType
::
int_t
)
{
}
else
if
(
target_data_type
==
ASTNodeDataType
::
int_t
)
{
return
(
(
data_type
==
ASTNodeDataType
::
unsigned_int_t
)
or
(
data_type
==
ASTNodeDataType
::
bool_t
)
)
;
return
{
(
data_type
==
ASTNodeDataType
::
unsigned_int_t
)
or
(
data_type
==
ASTNodeDataType
::
bool_t
)
}
;
}
else
if
(
target_data_type
==
ASTNodeDataType
::
double_t
)
{
}
else
if
(
target_data_type
==
ASTNodeDataType
::
double_t
)
{
return
(
(
data_type
==
ASTNodeDataType
::
unsigned_int_t
)
or
(
data_type
==
ASTNodeDataType
::
int_t
)
or
return
{
(
data_type
==
ASTNodeDataType
::
unsigned_int_t
)
or
(
data_type
==
ASTNodeDataType
::
int_t
)
or
(
data_type
==
ASTNodeDataType
::
bool_t
)
)
;
(
data_type
==
ASTNodeDataType
::
bool_t
)
}
;
}
else
if
(
target_data_type
==
ASTNodeDataType
::
string_t
)
{
}
else
if
(
target_data_type
==
ASTNodeDataType
::
string_t
)
{
return
(
(
data_type
>=
ASTNodeDataType
::
bool_t
)
and
(
data_type
<
ASTNodeDataType
::
string_t
)
)
;
return
{
(
data_type
>=
ASTNodeDataType
::
bool_t
)
and
(
data_type
<
ASTNodeDataType
::
string_t
)
}
;
}
}
return
false
;
return
false
;
}
}
This diff is collapsed.
Click to expand it.
src/language/ASTNodeDataType.hpp
+
12
−
10
View file @
8e9cab64
...
@@ -30,7 +30,7 @@ class ASTNodeDataType
...
@@ -30,7 +30,7 @@ class ASTNodeDataType
private
:
private
:
DataType
m_data_type
;
DataType
m_data_type
;
size_t
m_dimension
;
size_t
m_dimension
;
std
::
string
_view
m_type_name
;
std
::
string
m_type_name
;
public
:
public
:
size_t
size_t
...
@@ -39,7 +39,7 @@ class ASTNodeDataType
...
@@ -39,7 +39,7 @@ class ASTNodeDataType
return
m_dimension
;
return
m_dimension
;
}
}
std
::
string
_view
const
std
::
string
&
typeName
()
const
typeName
()
const
{
{
return
m_type_name
;
return
m_type_name
;
...
@@ -53,11 +53,13 @@ class ASTNodeDataType
...
@@ -53,11 +53,13 @@ class ASTNodeDataType
ASTNodeDataType
&
operator
=
(
const
ASTNodeDataType
&
)
=
default
;
ASTNodeDataType
&
operator
=
(
const
ASTNodeDataType
&
)
=
default
;
ASTNodeDataType
&
operator
=
(
ASTNodeDataType
&&
)
=
default
;
ASTNodeDataType
&
operator
=
(
ASTNodeDataType
&&
)
=
default
;
constexpr
ASTNodeDataType
(
DataType
data_type
)
:
m_data_type
{
data_type
},
m_dimension
{
1
}
{}
ASTNodeDataType
(
DataType
data_type
)
:
m_data_type
{
data_type
},
m_dimension
{
1
}
,
m_type_name
{
"unknown"
}
{}
ASTNodeDataType
(
DataType
data_type
,
size_t
dimension
)
:
m_data_type
{
data_type
},
m_dimension
{
dimension
}
{}
ASTNodeDataType
(
DataType
data_type
,
size_t
dimension
)
:
m_data_type
{
data_type
},
m_dimension
{
dimension
},
m_type_name
{
"unknown"
}
{}
ASTNodeDataType
(
DataType
data_type
,
std
::
string
_view
type_name
)
ASTNodeDataType
(
DataType
data_type
,
const
std
::
string
&
type_name
)
:
m_data_type
{
data_type
},
m_dimension
{
1
},
m_type_name
{
type_name
}
:
m_data_type
{
data_type
},
m_dimension
{
1
},
m_type_name
{
type_name
}
{}
{}
...
@@ -79,15 +81,15 @@ bool isNaturalConversion(const ASTNodeDataType& data_type, const ASTNodeDataType
...
@@ -79,15 +81,15 @@ bool isNaturalConversion(const ASTNodeDataType& data_type, const ASTNodeDataType
// Traits ast_node_data_type_from_pod
// Traits ast_node_data_type_from_pod
template
<
typename
T
>
template
<
typename
T
>
inline
constexpr
ASTNodeDataType
ast_node_data_type_from_pod
=
ASTNodeDataType
::
undefined_t
;
inline
ASTNodeDataType
ast_node_data_type_from_pod
=
ASTNodeDataType
::
undefined_t
;
template
<
>
template
<
>
inline
constexpr
ASTNodeDataType
ast_node_data_type_from_pod
<
bool
>
=
ASTNodeDataType
::
bool_t
;
inline
ASTNodeDataType
ast_node_data_type_from_pod
<
bool
>
=
ASTNodeDataType
::
bool_t
;
template
<
>
template
<
>
inline
constexpr
ASTNodeDataType
ast_node_data_type_from_pod
<
int64_t
>
=
ASTNodeDataType
::
int_t
;
inline
ASTNodeDataType
ast_node_data_type_from_pod
<
int64_t
>
=
ASTNodeDataType
::
int_t
;
template
<
>
template
<
>
inline
constexpr
ASTNodeDataType
ast_node_data_type_from_pod
<
uint64_t
>
=
ASTNodeDataType
::
unsigned_int_t
;
inline
ASTNodeDataType
ast_node_data_type_from_pod
<
uint64_t
>
=
ASTNodeDataType
::
unsigned_int_t
;
template
<
>
template
<
>
inline
constexpr
ASTNodeDataType
ast_node_data_type_from_pod
<
double
>
=
ASTNodeDataType
::
double_t
;
inline
ASTNodeDataType
ast_node_data_type_from_pod
<
double
>
=
ASTNodeDataType
::
double_t
;
#endif // AST_NODE_DATA_TYPE_HPP
#endif // AST_NODE_DATA_TYPE_HPP
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment