Skip to content

Commit

Permalink
Revert OP_CALL nargs incompatibility change
Browse files Browse the repository at this point in the history
It's too effected I guessed. :<
  • Loading branch information
kou committed Apr 25, 2017
1 parent beb1500 commit 85ea3bd
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 6 deletions.
17 changes: 16 additions & 1 deletion lib/expr.c
Original file line number Diff line number Diff line change
Expand Up @@ -903,6 +903,21 @@ grn_expr_append_obj(grn_ctx *ctx, grn_obj *expr, grn_obj *obj, grn_operator op,
case GRN_OP_CALL :
{
grn_obj *proc = NULL;
/*
* This is for keeping backward compatibility. We want to
* handle all "nargs" means that "N items on stack are used (N
* items are popped)" but "nargs" for OP_CALL is used as "N
* arguments" not "N items on stack are used" historically. It
* means that called function isn't included in "nargs".
*
* We adjust "nargs" here to handle "code->nargs" more easily.
* If we don't adjust "nargs" here, we need to care
* "code->nargs" at all locations that use "code->nargs". We
* need to use "code->nargs + 1" for OP_CALL and "code->nargs"
* for not OP_CALL to compute N items should be popped. It's
* wired. So we adjust "nargs" here.
*/
nargs++;
if (e->codes_curr - (nargs - 1) > 0) {
int i;
grn_expr_code *code;
Expand Down Expand Up @@ -7075,7 +7090,7 @@ parse_query(grn_ctx *ctx, efs_info *q)
/* dummy token */
PARSE(GRN_EXPR_TOKEN_QSTRING);
grn_expr_append_obj(ctx, q->e, all_records, GRN_OP_PUSH, 1);
grn_expr_append_op(ctx, q->e, GRN_OP_CALL, 1);
grn_expr_append_op(ctx, q->e, GRN_OP_CALL, 0);
}
}
op->op = GRN_OP_AND_NOT;
Expand Down
2 changes: 1 addition & 1 deletion lib/grn_ecmascript.c
Original file line number Diff line number Diff line change
Expand Up @@ -1946,7 +1946,7 @@ static void yy_reduce(
case 65: /* call_expression ::= member_expression arguments */
#line 371 "grn_ecmascript.lemon"
{
grn_expr_append_op(efsi->ctx, efsi->e, GRN_OP_CALL, 1 + yymsp[0].minor.yy0);
grn_expr_append_op(efsi->ctx, efsi->e, GRN_OP_CALL, yymsp[0].minor.yy0);
}
#line 1952 "grn_ecmascript.c"
break;
Expand Down
2 changes: 1 addition & 1 deletion lib/grn_ecmascript.lemon
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ lefthand_side_expression ::= call_expression.
lefthand_side_expression ::= member_expression.

call_expression ::= member_expression arguments(A). {
grn_expr_append_op(efsi->ctx, efsi->e, GRN_OP_CALL, 1 + A);
grn_expr_append_op(efsi->ctx, efsi->e, GRN_OP_CALL, A);
}

member_expression ::= primary_expression.
Expand Down
2 changes: 1 addition & 1 deletion lib/mrb/scripts/expression_tree/function_call.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def build(expression)
@arguments.each do |argument|
argument.build(expression)
end
expression.append_operator(Operator::CALL, 1 + @arguments.size)
expression.append_operator(Operator::CALL, @arguments.size)
end

def estimate_size(table)
Expand Down
2 changes: 1 addition & 1 deletion plugins/sharding/range_expression_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def build_partial_min_and_max(expression)
expression.append_constant(@target_range.max, Operator::PUSH, 1)
expression.append_constant(@target_range.max_border,
Operator::PUSH, 1)
expression.append_operator(Operator::CALL, 6)
expression.append_operator(Operator::CALL, 5)
build_condition(expression)
end

Expand Down
2 changes: 1 addition & 1 deletion plugins/suggest/suggest.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ correct(grn_ctx *ctx, grn_obj *items, grn_obj *items_boost,
key,
GRN_OP_GET_VALUE, 1);
grn_expr_append_const(ctx, expr, query, GRN_OP_PUSH, 1);
grn_expr_append_op(ctx, expr, GRN_OP_CALL, 3);
grn_expr_append_op(ctx, expr, GRN_OP_CALL, 2);
grn_expr_append_op(ctx, expr, GRN_OP_MINUS_ASSIGN, 2);

if ((tc = grn_table_cursor_open(ctx, res, NULL, 0, NULL, 0, 0, -1, 0))) {
Expand Down

0 comments on commit 85ea3bd

Please sign in to comment.