コード例 #1
0
ファイル: args.c プロジェクト: siam/jato
struct expression *convert_args(struct stack *mimic_stack,
				unsigned long nr_args,
				struct vm_method *method)
{
	struct expression *args_list = NULL;
	unsigned long i;

	if (nr_args == 0) {
		args_list = no_args_expr();
		goto out;
	}

	/*
	 * We scan the args map in reverse order,
	 * since the order of arguments is already reversed.
	 */
	for (i = 0; i < nr_args; i++) {
		struct expression *expr = stack_pop(mimic_stack);
		args_list = insert_arg(args_list, expr,
				       method, nr_args - i - 1);
	}

  out:
	return args_list;
}
コード例 #2
0
ファイル: args.c プロジェクト: code-in-the-shell/jato
struct expression *
convert_args(struct stack *mimic_stack, unsigned long nr_args, struct vm_method *method)
{
	struct expression *args_list = NULL;
	unsigned long nr_total_args;
	unsigned long i;

	nr_total_args = nr_args;

	if (vm_method_is_jni(method)) {
		if (vm_method_is_static(method))
			nr_total_args++;

		nr_total_args++;
	}

	if (nr_total_args == 0) {
		args_list = no_args_expr();
		goto out;
	}

	/*
	 * We scan the args map in reverse order, since the order of arguments
	 * is already reversed.
	 */
	for (i = 0; i < nr_args; i++) {
		struct expression *expr = stack_pop(mimic_stack);

		if (vm_type_is_pair(expr->vm_type))
			i++;

		if (i >= nr_args)
			break;

		args_list = insert_arg(args_list, expr, method, nr_total_args - i - 1);
	}

	if (vm_method_is_jni(method)) {
		struct expression *expr;

		if (vm_method_is_static(method)) {
			expr = value_expr(J_REFERENCE, (unsigned long) method->class->object);
			if (!expr)
				goto error;

			args_list = insert_arg(args_list, expr, method, 1);
		}

		/*
		 * JNI methods also need a pointer to JNI environment. That's
		 * done in jni_trampoline automagically which is why we never
		 * use method index zero here for JNI methods.
		 */
	}
  out:
	return args_list;
  error:
	expr_put(args_list);
	return NULL;
}
コード例 #3
0
ファイル: args.c プロジェクト: siam/jato
/**
 * This function prepares argument list that will be used
 * with the native VM call. All arguments are passed on stack.
 */
struct expression *
convert_native_args(struct stack *mimic_stack, unsigned long nr_args)
{
	struct expression *args_list = NULL;
	unsigned long i;

	if (nr_args == 0) {
		args_list = no_args_expr();
		goto out;
	}

	for (i = 0; i < nr_args; i++) {
		struct expression *expr = stack_pop(mimic_stack);
		args_list = insert_native_arg(args_list, expr);
	}

  out:
	return args_list;
}