We reuse the existing code for parsing the vm_method->type string.
Signed-off-by: Eduard - Gabriel Munteanu <[email protected]>
---
arch/x86/args.c | 22 +++++++++++++++++++---
include/vm/types.h | 1 +
vm/types.c | 2 +-
3 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/arch/x86/args.c b/arch/x86/args.c
index 5b5a740..715b38d 100644
--- a/arch/x86/args.c
+++ b/arch/x86/args.c
@@ -25,6 +25,7 @@
*/
#include <assert.h>
+#include <stdio.h>
#include "arch/args.h"
@@ -32,6 +33,7 @@
#include "jit/expression.h"
#include "vm/method.h"
+#include "vm/types.h"
#ifdef CONFIG_X86_64
@@ -39,11 +41,25 @@ int args_init(unsigned long *state,
struct vm_method *method,
unsigned long nr_args)
{
- char *type;
-
- for (type = method->type; *type != ')'; type++) {
- if (*type == 'I' || *type == 'L' || *type == 'J')
+ const char *type;
+ enum vm_type vm_type;
+
+ for (type = method->type + 1; *type != ')'; skip_type(&type)) {
+ vm_type = str_to_type(type);
+ switch (vm_type) {
+ case J_BYTE:
+ case J_CHAR:
+ case J_INT:
+ case J_LONG:
+ case J_SHORT:
+ case J_BOOLEAN:
+ case J_REFERENCE:
method->reg_args_count++;
+ break;
+ default:
+ NOT_IMPLEMENTED;
+ break;
+ }
if (method->reg_args_count == 6)
break;
diff --git a/include/vm/types.h b/include/vm/types.h
index 34cdda4..e97bfbd 100644
--- a/include/vm/types.h
+++ b/include/vm/types.h
@@ -19,6 +19,7 @@ enum vm_type {
extern enum vm_type str_to_type(const char *);
extern enum vm_type get_method_return_type(char *);
+int skip_type(const char **type);
int count_arguments(const char *);
enum vm_type bytecode_type_to_vmtype(int);
int vmtype_to_bytecode_type(enum vm_type);
diff --git a/vm/types.c b/vm/types.c
index a1d8c64..778375a 100644
--- a/vm/types.c
+++ b/vm/types.c
@@ -46,7 +46,7 @@ enum vm_type get_method_return_type(char *type)
static int count_skip_arguments(const char **type);
-static int skip_type(const char **type)
+int skip_type(const char **type)
{
const char *ptr = *type;
int ret = 1;
--
1.6.0.6
------------------------------------------------------------------------------
_______________________________________________
Jatovm-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jatovm-devel