cvsuser 02/11/21 08:51:48
Modified: . nci.c
Log:
Added another call type
Revision Changes Path
1.4 +31 -1 parrot/nci.c
Index: nci.c
===================================================================
RCS file: /cvs/public/parrot/nci.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -w -r1.3 -r1.4
--- nci.c 21 Nov 2002 02:00:23 -0000 1.3
+++ nci.c 21 Nov 2002 16:51:48 -0000 1.4
@@ -1,7 +1,7 @@
/* nci.c
* Copyright: 2001, 2002 Yet Another Society
* CVS Info
- * $Id: nci.c,v 1.3 2002/11/21 02:00:23 dan Exp $
+ * $Id: nci.c,v 1.4 2002/11/21 16:51:48 dan Exp $
* Overview:
* Native Call Interface routines. The code needed to build a
* parrot to C call frame is in here
@@ -13,6 +13,19 @@
#include "parrot/parrot.h"
+#if !defined(INT_REG)
+#define INT_REG(x) interpreter->ctx.int_reg.registers[x]
+#endif
+#if !defined(NUM_REG)
+#define NUM_REG(x) interpreter->ctx.num_reg.registers[x]
+#endif
+#if !defined(STR_REG)
+#define STR_REG(x) interpreter->ctx.string_reg.registers[x]
+#endif
+#if !defined(PMC_REG)
+#define PMC_REG(x) interpreter->ctx.pmc_reg.registers[x]
+#endif
+
#if !defined(CAN_BUILD_CALL_FRAMES)
/* All our static functions that call in various ways. Yes, terribly
hackish, but that's just fine */
@@ -45,6 +58,21 @@
return;
}
+/* Return int, take nothing */
+static void pcf_i_i(struct Parrot_Interp *interpreter, PMC *self) {
+ int (*pointer)();
+ int return_data;
+ pointer = self->cache.struct_val;
+ return_data = (int)(*pointer)(INT_REG(5));
+ interpreter->ctx.int_reg.registers[5] = return_data;
+ interpreter->ctx.int_reg.registers[0] = 0;
+ interpreter->ctx.int_reg.registers[1] = 1;
+ interpreter->ctx.int_reg.registers[2] = 0;
+ interpreter->ctx.int_reg.registers[3] = 0;
+ interpreter->ctx.int_reg.registers[4] = 0;
+ return;
+}
+
/* Return double, take nothing */
static void pcf_d_v(struct Parrot_Interp *interpreter, PMC *self) {
double (*pointer)();
@@ -94,6 +122,8 @@
if (0 == string_length(signature)) return pcf_v_v;
if (!string_compare(interpreter, signature, string_from_c_string(interpreter,
"i", 1)))
return pcf_i_v;
+ if (!string_compare(interpreter, signature, string_from_c_string(interpreter,
"ii", 1)))
+ return pcf_i_i;
if (!string_compare(interpreter, signature, string_from_c_string(interpreter,
"d", 1)))
return pcf_d_v;
if (!string_compare(interpreter, signature, string_from_c_string(interpreter,
"dd", 2)))