projects
/
m6w6
/
ext-psi
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
cpp: sizeof, anon decls, etc
[m6w6/ext-psi]
/
src
/
types
/
number.c
diff --git
a/src/types/number.c
b/src/types/number.c
index 4cb1f0295153549f318f686d1822619afb9b342b..b45e00ea2fe4126890ba97ac89b07823d4c2f26f 100644
(file)
--- a/
src/types/number.c
+++ b/
src/types/number.c
@@
-86,6
+86,9
@@
struct psi_number *psi_number_init(token_t t, void *num, unsigned flags)
case PSI_T_FUNCTION:
exp->data.call = num;
break;
case PSI_T_FUNCTION:
exp->data.call = num;
break;
+ case PSI_T_SIZEOF:
+ exp->data.dtyp = num;
+ break;
default:
assert(0);
}
default:
assert(0);
}
@@
-130,6
+133,9
@@
struct psi_number *psi_number_copy(struct psi_number *exp)
case PSI_T_FUNCTION:
num->data.call = psi_cpp_macro_call_copy(num->data.call);
break;
case PSI_T_FUNCTION:
num->data.call = psi_cpp_macro_call_copy(num->data.call);
break;
+ case PSI_T_SIZEOF:
+ num->data.dtyp = psi_decl_type_copy(num->data.dtyp);
+ break;
default:
assert(0);
}
default:
assert(0);
}
@@
-173,6
+179,9
@@
void psi_number_free(struct psi_number **exp_ptr)
case PSI_T_NAME:
psi_decl_var_free(&exp->data.dvar);
break;
case PSI_T_NAME:
psi_decl_var_free(&exp->data.dvar);
break;
+ case PSI_T_SIZEOF:
+ psi_decl_type_free(&exp->data.dtyp);
+ break;
default:
assert(0);
}
default:
assert(0);
}
@@
-236,6
+245,9
@@
void psi_number_dump(int fd, struct psi_number *exp)
case PSI_T_NAME:
psi_decl_var_dump(fd, exp->data.dvar);
break;
case PSI_T_NAME:
psi_decl_var_dump(fd, exp->data.dvar);
break;
+ case PSI_T_SIZEOF:
+ psi_decl_type_dump(fd, exp->data.dtyp, 0);
+ break;
default:
assert(0);
}
default:
assert(0);
}
@@
-481,6
+493,16
@@
bool psi_number_validate(struct psi_data *data, struct psi_number *exp,
exp->data.dvar->name);
return false;
exp->data.dvar->name);
return false;
+ case PSI_T_SIZEOF:
+ if (psi_decl_type_validate(data, exp->data.dtyp, 0, NULL)) {
+ struct psi_decl_type *dtyp = exp->data.dtyp;
+
+ exp->type = PSI_T_UINT64;
+ exp->data.ival.u64 = psi_decl_type_get_size(dtyp, NULL);
+ return true;
+ }
+ break;
+
case PSI_T_NSNAME:
while (psi_plist_get(data->consts, i++, &cnst)) {
if (!strcmp(cnst->name, exp->data.numb)) {
case PSI_T_NSNAME:
while (psi_plist_get(data->consts, i++, &cnst)) {
if (!strcmp(cnst->name, exp->data.numb)) {
@@
-613,6
+635,10
@@
token_t psi_number_eval(struct psi_number *exp, impl_val *res, struct psi_call_f
if (frame) PSI_DEBUG_PRINT(frame->context, " %" PRIi64, res->i64);
return PSI_T_INT64;
if (frame) PSI_DEBUG_PRINT(frame->context, " %" PRIi64, res->i64);
return PSI_T_INT64;
+ case PSI_T_NUMBER:
+ res->i64 = atol(exp->data.numb);
+ return PSI_T_INT64;
+
case PSI_T_CONST:
return psi_number_eval_constant(exp, res, frame);
case PSI_T_CONST:
return psi_number_eval_constant(exp, res, frame);