pike.git/
src/
pike_types.cmod
Branch:
Tag:
Non-build tags
All tags
No tags
2021-11-28
2021-11-28 11:39:12 by Henrik Grubbström (Grubba) <grubba@grubba.org>
562fd5162eb7886650dbbc4e0ec4f77e8913a26f (
39
lines) (+
29
/-
10
)
[
Show
|
Annotate
]
Branch:
master
Compiler
[Typechecker]
: Support nested type operators.
7515:
case PIKE_T_OPERATOR: {
-
struct pike_type *t = a->car;
-
if (
(t
->type
>=
'0'
)
&&
(
t
->type
<= '9'
)
) {
-
t =
a
_
markers[t
->type
-
'0']
;
-
/* if
(
!t
) t =
zero
_type_
string;
*/
+
/* First match car & cdr against mixed to evaluate markers.
+
* It also applies any related type operators.
+
*/
+
struct pike_type *t
;
+
struct pike_type *t1
=
low_match_types(
a->car
, any_type_string, flags)
;
+
if (
a
->type
&
0x8000
)
{
+
struct pike_type *t2 = low_match_types
(
a
->
cdr, any_
type
_string,
flags
)
;
+
t =
apply_type_operator(
a->type
,
t1,
t2)
;
+
free_type
(
t2
)
;
+
} else {
+
t =
apply
_type_
operator(a->type, t1, a->cdr)
;
}
-
t = apply
_type
_operator
(
a->type,
t,
a->cdr
);
+
free
_type(
t1);
+
+
if (!
t
)
return NULL
;
ret = low_match_types(t, b, flags); free_type(t); return ret;
7655:
case PIKE_T_OPERATOR: {
-
struct pike_type *t = b->car;
-
if (
(t
->type
>=
'0'
)
&&
(t->
type
<
=
'9'))
{
-
t =
b
_
markers[t
->type
-
'0']
;
-
/* if
(
!t
) t =
zero
_type_
string;
*/
+
/* First match car & cdr against mixed to evaluate markers.
+
* It also applies any related type operators.
+
*/
+
struct pike_type *t
;
+
struct pike_type *t1
=
low_match_types(any_type_string,
b->car
, flags)
;
+
if (
b
->type
&
0x8000
)
{
+
struct pike_type *t2 = low_match_types
(
any_type_string, b
->
cdr,
flags
)
;
+
t =
apply_type_operator(
b->type
,
t1,
t2)
;
+
free_type
(
t2
)
;
+
} else {
+
t =
apply
_type_
operator(b->type, t1, b->cdr)
;
}
-
t = apply
_type
_operator
(
b->type,
t,
b->cdr
);
+
free
_type(
t1);
+
+
if (!
t
)
return NULL
;
ret = low_match_types(a, t, flags); free_type(t); return ret;