pike.git/
src/
pike_types.cmod
Branch:
Tag:
Non-build tags
All tags
No tags
2021-06-10
2021-06-10 13:13:12 by Henrik Grubbström (Grubba) <grubba@grubba.org>
1a85d158ebad7b9d1702e706ce14c88a736fe19b (
43
lines) (+
33
/-
10
)
[
Show
|
Annotate
]
Branch:
master
Compiler: Support nullable types in compile_type_to_runtime_type().
2976:
/******/
-
TYPE_T compile_type_to_runtime_type(struct pike_type *t)
+
static
TYPE_T
low_
compile_type_to_runtime_type(struct pike_type *t)
{
-
switch(t->type)
/* Note: No masking here. */
+
switch(t
?t
->type
:PIKE_T_UNKNOWN
) /* Note: No masking here. */
{ case PIKE_T_RING:
-
return compile_type_to_runtime_type(t->car);
+
return
low_
compile_type_to_runtime_type(t->car);
case T_OR: {
-
TYPE_T
tmp
= compile_type_to_runtime_type(t->car);
-
if(tmp
=
=
compile_type_to_runtime_type(t->cdr))
-
return
tmp
;
+
TYPE_T
car_t
=
low_
compile_type_to_runtime_type(t->car);
+
TYPE_T
cdr_t
=
low_
compile_type_to_runtime_type(t->cdr)
;
+
if(car_t = cdr_t
)
+
return
car_t
;
+
if (car_t == PIKE_T_VOID) {
+
car_t = PIKE_T_ZERO;
}
-
+
if (cdr_t == PIKE_T_VOID) {
+
cdr_t = PIKE_T_ZERO;
+
}
+
if ((car_t == PIKE_T_ZERO) && (cdr_t != PIKE_T_FLOAT)) {
+
return cdr_t;
+
}
+
if ((cdr_t == PIKE_T_ZERO) && (car_t != PIKE_T_FLOAT)) {
+
return car_t;
+
}
+
}
/* FALLTHRU */ case T_TUPLE:
2997:
default: return T_MIXED;
-
case T_ZERO:
-
return T_INT;
-
+
case T_SCOPE: case PIKE_T_NAME: case PIKE_T_ATTRIBUTE:
-
return compile_type_to_runtime_type(t->cdr);
+
return
low_
compile_type_to_runtime_type(t->cdr);
case T_MANY: case PIKE_T_FIND_LFUN:
3021:
case T_TYPE: case T_INT: case T_FLOAT:
+
case T_ZERO:
+
case T_VOID:
return t->type; } }
-
+
TYPE_T compile_type_to_runtime_type(struct pike_type *t)
+
{
+
TYPE_T ret = low_compile_type_to_runtime_type(t);
+
+
if ((ret == PIKE_T_ZERO) || (ret == PIKE_T_VOID)) {
+
return PIKE_T_INT;
+
}
+
return ret;
+
}
+
/** * Check whether a type is for a __deprecated__ value. *