Lines Matching refs:expr

37 	struct Exnode_s*expr;
125 %type <expr> statement statement_list arg_list
126 %type <expr> else_opt expr_opt expr
127 %type <expr> args variable assign
128 %type <expr> dcl_list dcl_item index
129 %type <expr> initialize switch_item constant
130 %type <expr> formals formal_list formal_item
157 if ($1 && !(expr.program->disc->flags & EX_STRICT))
159 if (expr.program->main.value && !(expr.program->disc->flags & EX_RETAIN))
160 exfreenode(expr.program, expr.program->main.value);
168 exfreenode(expr.program, x);
170 expr.program->main.lex = PROCEDURE;
171 expr.program->main.value = exnewnode(expr.program, PROCEDURE, 1, $1->type, NiL, $1);
183 if (expr.procedure)
186 expr.procedure = $1->value = exnewnode(expr.program, PROCEDURE, 1, $1->type, NiL, NiL);
187 expr.procedure->type = INTEGER;
191 if (expr.assigned && !streq($1->name, "begin"))
193 if (!(expr.procedure->data.procedure.frame = dtopen(disc, Dtset)) || !dtview(expr.procedure->data.procedure.frame, expr.program->symbols))
195 expr.program->symbols = expr.program->frame = expr.procedure->data.procedure.frame;
199 expr.procedure = 0;
200 if (expr.program->frame)
202 expr.program->symbols = expr.program->frame->view;
203 dtview(expr.program->frame, NiL);
204 expr.program->frame = 0;
213 exfreenode(expr.program, x);
215 $1->value->data.operand.right = excast(expr.program, $4, $1->type, NiL, 0);
231 exfreenode(expr.program, $1);
237 $1->data.operand.last = $1->data.operand.last->data.operand.right = exnewnode(expr.program, ';', 1, $2->type, $2, NiL);
241 $$ = exnewnode(expr.program, ';', 1, $1->type, $1, NiL);
242 $$->data.operand.last = $$->data.operand.right = exnewnode(expr.program, ';', 1, $2->type, $2, NiL);
253 $$ = ($1 && $1->type == STRING) ? exnewnode(expr.program, S2B, 1, INTEGER, $1, NiL) : $1;
255 | static {expr.instatic=$1;} DECLARE {expr.declare=$3->type;} dcl_list ';'
258 expr.declare = 0;
260 | IF '(' expr ')' statement else_opt
263 $3 = exnewnode(expr.program, S2B, 1, INTEGER, $3, NiL);
265 $3 = excast(expr.program, $3, INTEGER, NiL, 0);
266 $$ = exnewnode(expr.program, $1->index, 1, INTEGER, $3, exnewnode(expr.program, ':', 1, $5 ? $5->type : 0, $5, $6));
270 $$ = exnewnode(expr.program, ITERATE, 0, INTEGER, NiL, NiL);
277 exfreenode(expr.program, $3->data.variable.index);
285 $5 = exnewnode(expr.program, CONSTANT, 0, INTEGER, NiL, NiL);
289 $5 = exnewnode(expr.program, S2B, 1, INTEGER, $5, NiL);
291 $5 = excast(expr.program, $5, INTEGER, NiL, 0);
292 $$ = exnewnode(expr.program, $1->index, 1, INTEGER, $5, exnewnode(expr.program, ';', 1, 0, $7, $9));
294 $$ = exnewnode(expr.program, ';', 1, INTEGER, $3, $$);
296 | WHILE '(' expr ')' statement
299 $3 = exnewnode(expr.program, S2B, 1, INTEGER, $3, NiL);
301 $3 = excast(expr.program, $3, INTEGER, NiL, 0);
302 $$ = exnewnode(expr.program, $1->index, 1, INTEGER, $3, exnewnode(expr.program, ';', 1, 0, NiL, $5));
304 | SWITCH '(' expr {expr.declare=$3->type;} ')' '{' switch_list '}'
306 register Switch_t* sw = expr.swstate;
308 $$ = exnewnode(expr.program, $1->index, 1, INTEGER, $3, exnewnode(expr.program, DEFAULT, 1, 0, sw->defcase, sw->firstcase));
309 expr.swstate = expr.swstate->prev;
314 expr.declare = 0;
321 $2 = exnewnode(expr.program, CONSTANT, 0, INTEGER, NiL, NiL);
325 $2 = excast(expr.program, $2, INTEGER, NiL, 0);
326 $$ = exnewnode(expr.program, $1->index, 1, INTEGER, $2, NiL);
336 if (expr.procedure && !expr.procedure->type)
338 $2 = excast(expr.program, $2, expr.procedure ? expr.procedure->type : INTEGER, NiL, 0);
340 $$ = exnewnode(expr.program, RETURN, 1, $2 ? $2->type : 0, $2, NiL);
349 if (expr.swstate)
356 sw->prev = expr.swstate;
360 expr.swstate = sw;
361 sw->type = expr.declare;
380 register Switch_t* sw = expr.swstate;
383 $$ = exnewnode(expr.program, CASE, 1, 0, $2, NiL);
393 $$->data.select.constant = (Extype_t**)exalloc(expr.program, (n + 1) * sizeof(Extype_t*));
418 if (expr.swstate->cur >= expr.swstate->last)
420 n = expr.swstate->cur - expr.swstate->base;
421 if (!(expr.swstate->base = newof(expr.swstate->base, Extype_t*, 2 * n, 0)))
426 expr.swstate->cur = expr.swstate->base + n;
427 expr.swstate->last = expr.swstate->base + 2 * n;
429 if (expr.swstate->cur)
431 $2 = excast(expr.program, $2, expr.swstate->type, NiL, 0);
432 *expr.swstate->cur++ = &($2->data.constant.value);
437 expr.swstate->def = 1;
455 $$ = $1 ? exnewnode(expr.program, ',', 1, $3->type, $1, $3) : $3;
459 dcl_item : reference NAME {expr.id=$2;} array initialize
462 if (!$2->type || expr.declare)
463 $2->type = expr.declare;
467 if (!expr.program->disc->getf || !expr.program->symbols)
471 else if (expr.program->disc->reff)
472 (*expr.program->disc->reff)(expr.program, $$, $2, $1, NiL, EX_SCALAR, expr.program->disc);
482 $2->value = exnewnode(expr.program, 0, 0, 0, NiL, NiL);
498 $5->data.operand.right = excast(expr.program, $5->data.operand.right, $2->type, NiL, 0);
500 $5->data.operand.left = exnewnode(expr.program, DYNAMIC, 0, $2->type, NiL, NiL);
503 if (!expr.program->frame && !expr.program->errors)
505 expr.assigned++;
506 exeval(expr.program, $$, NiL);
533 | expr
536 expr : '(' expr ')'
540 | '(' DECLARE ')' expr %prec CAST
542 $$ = ($4->type == $2->type) ? $4 : excast(expr.program, $4, $2->type, NiL, 0);
544 | expr '<' expr
566 $1 = excast(expr.program, $1, $3->type, $3, 0);
568 $3 = excast(expr.program, $3, $1->type, $1, 0);
570 $3 = excast(expr.program, $3, FLOATING, $1, 0);
572 $1 = excast(expr.program, $1, FLOATING, $3, 0);
576 $$ = exnewnode(expr.program, $2, 1, rel, $1, $3);
577 if (!expr.program->errors && $1->op == CONSTANT && $3->op == CONSTANT)
579 $$->data.constant.value = exeval(expr.program, $$, NiL);
582 exfreenode(expr.program, $1);
583 exfreenode(expr.program, $3);
586 | expr '-' expr
590 | expr '*' expr
594 | expr '/' expr
598 | expr '%' expr
602 | expr LS expr
606 | expr RS expr
610 | expr '>' expr
614 | expr LE expr
618 | expr GE expr
622 | expr EQ expr
626 | expr NE expr
630 | expr '&' expr
634 | expr '|' expr
638 | expr '^' expr
642 | expr '+' expr
646 | expr AND expr
650 $1 = exnewnode(expr.program, S2B, 1, INTEGER, $1, NiL);
652 $3 = exnewnode(expr.program, S2B, 1, INTEGER, $3, NiL);
655 | expr OR expr
659 | expr ',' expr
663 exfreenode(expr.program, $1);
667 $$ = exnewnode(expr.program, ',', 1, $3->type, $1, $3);
669 | expr '?' {expr.nolabel=1;} expr ':' {expr.nolabel=0;} expr
681 $1 = exnewnode(expr.program, S2B, 1, INTEGER, $1, NiL);
683 $1 = excast(expr.program, $1, INTEGER, NiL, 0);
689 $7 = excast(expr.program, $7, FLOATING, NiL, 0);
691 $4 = excast(expr.program, $4, FLOATING, NiL, 0);
698 exfreenode(expr.program, $7);
703 exfreenode(expr.program, $4);
705 exfreenode(expr.program, $1);
708 $$ = exnewnode(expr.program, '?', 1, $4->type, $1, exnewnode(expr.program, ':', 1, $4->type, $4, $7));
710 | '!' expr
714 $2 = exnewnode(expr.program, S2B, 1, INTEGER, $2, NiL);
716 $2 = excast(expr.program, $2, INTEGER, NiL, 0);
718 $$ = exnewnode(expr.program, $1, 1, $2->type == UNSIGNED ? INTEGER : $2->type, $2, NiL);
721 $$->data.constant.value = exeval(expr.program, $$, NiL);
724 exfreenode(expr.program, $2);
727 | '~' expr
731 | '-' expr %prec UNARY
735 | '+' expr %prec UNARY
741 $$ = exnewnode(expr.program, ADDRESS, 0, T($2->type), $2, NiL);
745 $$ = exnewnode(expr.program, FUNCTION, 1, T($2->type), call($1, $2, $4), $4);
746 if (!expr.program->disc->getf)
748 else if (expr.program->disc->reff)
749 (*expr.program->disc->reff)(expr.program, $$->data.operand.left, $$->data.operand.left->data.variable.symbol, $1, NiL, EX_CALL, expr.program->disc);
751 | EXIT '(' expr ')'
754 $3 = excast(expr.program, $3, INTEGER, NiL, 0);
755 $$ = exnewnode(expr.program, EXIT, 1, INTEGER, $3, NiL);
759 $$ = exnewnode(expr.program, CALL, 1, $1->type, NiL, $3);
764 $$ = exnewnode(expr.program, $1->index, 0, $1->type, NiL, NiL);
774 $$->data.print.descriptor = exnewnode(expr.program, CONSTANT, 0, INTEGER, NiL, NiL);
778 $$->data.print.descriptor = exnewnode(expr.program, CONSTANT, 0, INTEGER, NiL, NiL);
791 $$ = exnewnode(expr.program, $1->index, 0, $1->type, NiL, NiL);
825 $$ = exnewnode(expr.program, CONSTANT, 0, $3->type, NiL, NiL);
826 if (!expr.program->disc->reff)
830 $$->data.constant.value = (*expr.program->disc->reff)(expr.program, $$, $3, NiL, $1, EX_SCALAR, expr.program->disc);
838 if ($1->op == ID && !expr.program->disc->setf)
851 $2->data.operand.right = excast(expr.program, $2->data.operand.right, $1->type, NiL, 0);
863 $$ = exnewnode(expr.program, $1, 0, $2->type, $2, NiL);
871 $$ = exnewnode(expr.program, $2, 0, $1->type, $1, NiL);
887 $$ = exnewnode(expr.program, CONSTANT, 0, $1->type, NiL, NiL);
888 if (!expr.program->disc->reff)
891 $$->data.constant.value = (*expr.program->disc->reff)(expr.program, $$, $1, NiL, NiL, EX_SCALAR, expr.program->disc);
895 $$ = exnewnode(expr.program, CONSTANT, 0, FLOATING, NiL, NiL);
900 $$ = exnewnode(expr.program, CONSTANT, 0, INTEGER, NiL, NiL);
905 $$ = exnewnode(expr.program, CONSTANT, 0, STRING, NiL, NiL);
910 $$ = exnewnode(expr.program, CONSTANT, 0, UNSIGNED, NiL, NiL);
926 $$ = exnewnode(expr.program, ID, 0, $2->type, NiL, NiL);
930 $3 = excast(expr.program, $3, INTEGER, NiL, 0);
932 if (!expr.program->disc->getf)
934 else if (expr.program->disc->reff)
935 (*expr.program->disc->reff)(expr.program, $$, $$->data.variable.symbol, $1, NiL, $3 ? 0 : EX_SCALAR, expr.program->disc);
940 $$ = exnewnode(expr.program, DYNAMIC, 0, $1->type, NiL, NiL);
948 $$ = exnewnode(expr.program, ID, 0, 0, NiL, NiL);
952 if (!(expr.program->disc->flags & EX_UNDECLARED))
971 | '[' expr ']'
985 exfreenode(expr.program, $1);
989 arg_list : expr %prec ','
991 $$ = exnewnode(expr.program, ';', 1, 0, exnewnode(expr.program, ';', 1, $1->type, $1, NiL), NiL);
994 | arg_list ',' expr
996 $1->data.operand.right = $1->data.operand.right->data.operand.right = exnewnode(expr.program, ',', 1, $1->type, $3, NiL);
1015 $$ = exnewnode(expr.program, ',', 1, $1->type, $1, NiL);
1024 x->data.operand.right = exnewnode(expr.program, ',', 1, $3->type, $3, NiL);
1028 formal_item : DECLARE {expr.declare=$1->type;} name
1030 $$ = exnewnode(expr.program, ID, 0, $3->type, NiL, NiL);
1033 $3->value = exnewnode(expr.program, 0, 0, 0, NiL, NiL);
1034 expr.procedure->data.procedure.arity++;
1035 expr.declare = 0;
1041 $$ = expr.refs = expr.lastref = 0;
1047 r = ALLOCATE(expr.program, Exref_t);
1048 if (expr.lastref)
1050 r->symbol = QUALIFY(expr.lastref, $2);
1051 expr.lastref->next = r;
1056 expr.refs = r;
1058 expr.lastref = r;
1061 $$ = expr.refs;
1069 | '=' expr
1071 $$ = exnewnode(expr.program, '=', 1, $2->type, NiL, $2);
1080 if (expr.procedure)
1081 exerror("%s: nested function definitions not supported", expr.id->name);
1082 expr.procedure = exnewnode(expr.program, PROCEDURE, 1, expr.declare, NiL, NiL);
1086 if (!streq(expr.id->name, "begin"))
1088 if (!(expr.procedure->data.procedure.frame = dtopen(disc, Dtset)) || !dtview(expr.procedure->data.procedure.frame, expr.program->symbols))
1090 expr.program->symbols = expr.program->frame = expr.procedure->data.procedure.frame;
1091 expr.program->formals = 1;
1093 expr.declare = 0;
1095 expr.id->lex = PROCEDURE;
1096 expr.id->type = expr.procedure->type;
1097 expr.program->formals = 0;
1098 expr.declare = 0;
1101 $$ = expr.procedure;
1102 expr.procedure = 0;
1103 if (expr.program->frame)
1105 expr.program->symbols = expr.program->frame->view;
1106 dtview(expr.program->frame, NiL);
1107 expr.program->frame = 0;
1110 $$->data.operand.right = excast(expr.program, $7, $$->type, NiL, 0);
1118 exunlex(expr.program, ';');