Lines Matching refs:expr
76 getdyn(Expr_t* ex, register Exnode_t* expr, void* env, Exassoc_t** assoc)
81 if (expr->data.variable.index)
85 v = eval(ex, expr->data.variable.index, env);
86 if (expr->data.variable.index->type != STRING)
91 if (!(b = (Exassoc_t*)dtmatch((Dt_t*)expr->data.variable.symbol->local.pointer, v.string)))
96 dtinsert((Dt_t*)expr->data.variable.symbol->local.pointer, b);
101 if (expr->data.variable.symbol->type == STRING && !b->value.string)
102 b->value = exzero(expr->data.variable.symbol->type);
105 v = exzero(expr->data.variable.symbol->type);
109 return expr->data.variable.symbol->value->data.constant.value;
115 Expr_t* expr;
143 fmt->value = exeval(fmt->expr, node, fmt->env);
178 fmt->value = exeval(fmt->expr, node, fmt->env);
181 node = excast(fmt->expr, node, to, NiL, 0);
182 fmt->value = exeval(fmt->expr, node, fmt->env);
184 exfree(fmt->expr, node);
192 vmfree(fmt->expr->vm, fmt->value.string);
296 print(Expr_t* ex, Exnode_t* expr, void* env, Sfio_t* sp)
304 v = eval(ex, expr->data.print.descriptor, env);
314 fmt.expr = ex;
316 x = expr->data.print.args;
377 if (node->data.variable.symbol->value->data.constant.value.string == expr.nullstring)
380 *((void**)vp) = node->data.variable.symbol->value->data.constant.value.string = vmnewof(fmt->expr->vm, node->data.variable.symbol->value->data.constant.value.string, char, fmt->fmt.size, 0);
402 scan(Expr_t* ex, Exnode_t* expr, void* env, Sfio_t* sp)
411 if (expr->data.scan.descriptor)
413 v = eval(ex, expr->data.scan.descriptor, env);
414 if (expr->data.scan.descriptor->type == STRING)
429 fmt.expr = ex;
431 u = eval(ex, expr->data.scan.format, env);
433 fmt.actuals = expr->data.scan.args;
539 eval(Expr_t* ex, register Exnode_t* expr, void* env)
554 if (!expr || ex->loopcount)
559 x = expr->data.operand.left;
560 switch (expr->op)
566 ex->loopop = expr->op;
569 return expr->data.constant.value;
619 if (expr->subop == PRE)
623 return getdyn(ex, expr, env, &assoc);
633 eval(ex, expr->data.operand.right->data.operand.left, env);
635 eval(ex, expr->data.operand.right->data.operand.right, env);
640 expr = expr->data.operand.right;
649 if (expr->data.operand.right)
651 eval(ex, expr->data.operand.right, env);
658 if (expr->data.operand.left)
659 eval(ex, expr->data.operand.left, env);
666 x = expr->data.operand.right;
684 if ((ex->disc->version >= 19981111L && ex->disc->matchf) ? (*ex->disc->matchf)(ex, x, (*t)->string, expr->data.operand.left, v.string, env, ex->disc) : strmatch((*t)->string, v.string))
719 if (expr->data.generate.array->op == DYNAMIC)
721 n = expr->data.generate.index->type == STRING;
722 for (assoc = (Exassoc_t*)dtfirst((Dt_t*)expr->data.generate.array->data.variable.symbol->local.pointer); assoc; assoc = (Exassoc_t*)dtnext((Dt_t*)expr->data.generate.array->data.variable.symbol->local.pointer, assoc))
726 expr->data.generate.index->value->data.constant.value.string = assoc->name;
728 expr->data.generate.index->value->data.constant.value.integer = strtol(assoc->name, NiL, 0);
729 eval(ex, expr->data.generate.statement, env);
739 r = (*ex->disc->getf)(ex, expr, expr->data.generate.array->data.variable.symbol, expr->data.generate.array->data.variable.reference, env, 0, ex->disc);
742 expr->data.generate.index->value->data.constant.value.integer = v.integer;
743 eval(ex, expr->data.generate.statement, env);
753 x = expr->data.call.args;
754 for (n = 0, a = expr->data.call.procedure->value->data.procedure.args; a && x; a = a->data.operand.right)
765 for (n = 0, a = expr->data.call.procedure->value->data.procedure.args; a && n < elementsof(save); a = a->data.operand.right)
771 v = exeval(ex, expr->data.call.procedure->value->data.procedure.body, env);
772 for (n = 0, a = expr->data.call.procedure->value->data.procedure.args; a && n < elementsof(save); a = a->data.operand.right)
778 for (x = expr->data.operand.right; x && n < elementsof(args); x = x->data.operand.right)
780 return (*ex->disc->getf)(ex, expr->data.operand.left, expr->data.operand.left->data.variable.symbol, expr->data.operand.left->data.variable.reference, args+1, EX_CALL, ex->disc);
782 if (expr->data.variable.index)
783 i = eval(ex, expr->data.variable.index, env);
786 return (*ex->disc->getf)(ex, expr, expr->data.variable.symbol, expr->data.variable.reference, env, (int)i.integer, ex->disc);
791 v.integer = print(ex, expr, env, NiL);
794 print(ex, expr, env, sfstderr);
800 ex->loopop = expr->op;
804 v.integer = scan(ex, expr, env, NiL);
807 print(ex, expr, env, ex->tmp);
811 v = eval(ex, expr->data.operand.right, env);
812 if (expr->subop != '=')
828 switch (expr->subop)
876 switch (expr->subop)
919 switch (expr->subop)
956 while ((expr = expr->data.operand.right) && (expr->op == ';' || expr->op == ','))
958 v = eval(ex, expr->data.operand.left, env);
962 return expr ? eval(ex, expr, env) : v;
965 return v.integer ? eval(ex, expr->data.operand.right->data.operand.left, env) : eval(ex, expr->data.operand.right->data.operand.right, env);
968 return v.integer ? eval(ex, expr->data.operand.right, env) : v;
971 return v.integer ? v : eval(ex, expr->data.operand.right, env);
974 if (x = expr->data.operand.right)
976 switch (expr->data.operand.left->type)
979 switch (expr->op)
985 tmp = *expr->data.operand.left;
987 if (expr->data.operand.left->op != DYNAMIC && expr->data.operand.left->op != ID)
992 else if ((*ex->disc->convertf)(ex, &tmp, STRING, expr->data.operand.right ? expr->data.operand.right->data.variable.symbol : (Exid_t*)0, 0, ex->disc))
993 exerror("%s: cannot convert value to string", expr->data.operand.left->data.variable.symbol->name);
997 tmp = *expr->data.operand.left;
999 if ((*ex->disc->convertf)(ex, &tmp, expr->type, expr->data.operand.right ? expr->data.operand.right->data.variable.symbol : (Exid_t*)0, 0, ex->disc))
1001 tmp.type = expr->type;
1069 switch (expr->op)
1072 tmp = *expr->data.operand.left;
1074 if ((*ex->disc->convertf)(ex, &tmp, FLOATING, expr->data.operand.right ? expr->data.operand.right->data.variable.symbol : (Exid_t*)0, 0, ex->disc))
1075 exerror("%s: cannot convert value to floating", expr->data.operand.left->data.variable.symbol->name);
1079 tmp = *expr->data.operand.left;
1081 if ((*ex->disc->convertf)(ex, &tmp, INTEGER, expr->data.operand.right ? expr->data.operand.right->data.variable.symbol : (Exid_t*)0, 0, ex->disc))
1082 exerror("%s: cannot convert value to integer", expr->data.operand.left->data.variable.symbol->name);
1086 tmp = *expr->data.operand.left;
1088 if ((*ex->disc->convertf)(ex, &tmp, STRING, expr->data.operand.right ? expr->data.operand.right->data.variable.symbol : (Exid_t*)0, 0, ex->disc))
1089 exerror("%s: cannot convert value to string", expr->data.operand.left->data.variable.symbol->name);
1095 switch (expr->op)
1113 switch (expr->op)
1119 if (expr->type == UNSIGNED)
1126 tmp = *expr->data.operand.left;
1128 if (expr->data.operand.left->op != DYNAMIC && expr->data.operand.left->op != ID)
1130 if (expr->data.operand.left->type == UNSIGNED)
1136 else if ((*ex->disc->convertf)(ex, &tmp, STRING, expr->data.operand.right ? expr->data.operand.right->data.variable.symbol : (Exid_t*)0, 0, ex->disc))
1137 exerror("%s: cannot convert value to string", expr->data.operand.left->data.variable.symbol->name);
1141 tmp = *expr->data.operand.left;
1143 if ((*ex->disc->convertf)(ex, &tmp, expr->type, expr->data.operand.right ? expr->data.operand.right->data.variable.symbol : (Exid_t*)0, 0, ex->disc))
1145 tmp.type = expr->type;
1213 switch (expr->op)
1219 tmp = *expr->data.operand.left;
1221 if ((*ex->disc->convertf)(ex, &tmp, FLOATING, expr->data.operand.right ? expr->data.operand.right->data.variable.symbol : (Exid_t*)0, 0, ex->disc))
1230 tmp = *expr->data.operand.left;
1232 if ((*ex->disc->convertf)(ex, &tmp, INTEGER, expr->data.operand.right ? expr->data.operand.right->data.variable.symbol : (Exid_t*)0, 0, ex->disc))
1241 tmp = *expr->data.operand.left;
1243 if ((*ex->disc->convertf)(ex, &tmp, expr->type, expr->data.operand.right ? expr->data.operand.right->data.variable.symbol : (Exid_t*)0, 0, ex->disc))
1245 tmp.type = expr->type;
1249 v.integer = ((v.string && r.string) ? ((ex->disc->version >= 19981111L && ex->disc->matchf) ? (*ex->disc->matchf)(ex, expr->data.operand.left, v.string, expr->data.operand.right, r.string, env, ex->disc) : strmatch(v.string, r.string)) : (v.string == r.string)) == (expr->op == EQ);
1271 switch (expr->op)
1289 if (expr->binary)
1290 exerror("operator %s %s %s not implemented", lexname(expr->data.operand.left->type, -1), lexname(expr->op, expr->subop), expr->data.operand.right ? lexname(expr->data.operand.right->type, -1) : "UNARY");
1292 exerror("operator %s %s not implemented", lexname(expr->op, expr->subop), lexname(expr->data.operand.left->type, -1));
1293 return exzero(expr->type);
1297 * evaluate expression expr
1301 exeval(Expr_t* ex, Exnode_t* expr, void* env)
1306 if (expr->compiled.integer)
1308 switch (expr->type)
1311 v.floating = (*expr->compiled.floating)(ex->disc->data);
1314 v.string = (*expr->compiled.string)(ex->disc->data);
1317 v.integer = (*expr->compiled.integer)(ex->disc->data);
1323 v = eval(ex, expr, env);