Branch: Tag:

2016-01-04

2016-01-04 14:57:57 by Per Hedbor <ph@opera.com>

Allow typeof(X) to be used as a type.

Use this feature to allow bool to be int(1..1)|int(0..0), that is,
bypass the optimization that removes int(0..0) from it.

1333:    | TOK_PROGRAM_ID opt_program_type { push_type(T_PROGRAM); }    | TOK_ARRAY_ID opt_array_type { push_type(T_ARRAY); }    | TOK_MULTISET_ID opt_array_type { push_type(T_MULTISET); } +  | TOK_TYPEOF '(' expr0 ')' { +  node *tmp; +  struct pike_type *t; +  tmp=mknode(F_COMMA_EXPR, $3, 0); +  optimize_node(tmp); +  +  t=(tmp && CAR(tmp) && CAR(tmp)->type ? CAR(tmp)->type : mixed_type_string); +  push_finished_type(t); +  free_node(tmp); +  }    | TOK_ATTRIBUTE_ID '(' string_constant ',' full_type ')'    {    push_type_attribute($3->u.sval.u.string);