Permalink
Browse files

Borrow pushing of positional parameters

  • Loading branch information...
1 parent bd0312a commit 8e1c54f24e7a65a2bf6ec72a9f2f99f4cc4522a7 @bacek bacek committed Mar 27, 2012
Showing with 120 additions and 0 deletions.
  1. +39 −0 include/parrot/signature.h
  2. +81 −0 src/call/signature.c
View
39 include/parrot/signature.h
@@ -34,13 +34,52 @@ void Parrot_pcc_signature_reset(PARROT_INTERP,
__attribute__nonnull__(1)
__attribute__nonnull__(2);
+void Parrot_pcc_signature_push_float(PARROT_INTERP,
+ ARGIN(Parrot_Signature *self),
+ FLOATVAL value)
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2);
+
+void Parrot_pcc_signature_push_integer(PARROT_INTERP,
+ ARGIN(Parrot_Signature *self),
+ INTVAL value)
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2);
+
+void Parrot_pcc_signature_push_pmc(PARROT_INTERP,
+ ARGIN(Parrot_Signature *self),
+ ARGIN_NULLOK(PMC *value))
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2);
+
+void Parrot_pcc_signature_push_string(PARROT_INTERP,
+ ARGIN(Parrot_Signature *self),
+ ARGIN_NULLOK(STRING *value))
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2);
+
#define ASSERT_ARGS_Parrot_pcc_signature_free __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_Parrot_pcc_signature_new __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_Parrot_pcc_signature_reset __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(self))
+#define ASSERT_ARGS_Parrot_pcc_signature_push_float \
+ __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+ PARROT_ASSERT_ARG(interp) \
+ , PARROT_ASSERT_ARG(self))
+#define ASSERT_ARGS_Parrot_pcc_signature_push_integer \
+ __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+ PARROT_ASSERT_ARG(interp) \
+ , PARROT_ASSERT_ARG(self))
+#define ASSERT_ARGS_Parrot_pcc_signature_push_pmc __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+ PARROT_ASSERT_ARG(interp) \
+ , PARROT_ASSERT_ARG(self))
+#define ASSERT_ARGS_Parrot_pcc_signature_push_string \
+ __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+ PARROT_ASSERT_ARG(interp) \
+ , PARROT_ASSERT_ARG(self))
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
/* HEADERIZER END: src/call/signature.c */
View
81 src/call/signature.c
@@ -222,6 +222,87 @@ Parrot_pcc_signature_reset(PARROT_INTERP, ARGIN(Parrot_Signature *self))
}
}
+/*
+=back
+
+=head1 ACCESSOR FUNCTIONS
+
+=over 4
+*/
+
+/*
+=item C<Parrot_pcc_signature_push_interger>
+
+=item C<void Parrot_pcc_signature_push_float(PARROT_INTERP, Parrot_Signature
+*self, FLOATVAL value)>
+
+=item C<void Parrot_pcc_signature_push_string(PARROT_INTERP, Parrot_Signature
+*self, STRING *value)>
+
+=item C<void Parrot_pcc_signature_push_pmc(PARROT_INTERP, Parrot_Signature
+*self, PMC *value)>
+
+Append positional parameter to Signature.
+
+=cut
+*/
+
+
+void
+Parrot_pcc_signature_push_integer(PARROT_INTERP, ARGIN(Parrot_Signature *self),
+ INTVAL value)
+{
+ INTVAL num_pos = self->num_positionals;
+
+ ensure_positionals_storage(interp, self, num_pos + 1);
+
+ self->positionals[num_pos].u.i = value;
+ self->positionals[num_pos].type = INTCELL;
+ self->num_positionals++;
+}
+
+void
+Parrot_pcc_signature_push_float(PARROT_INTERP, ARGIN(Parrot_Signature *self),
+ FLOATVAL value)
+{
+ INTVAL num_pos = self->num_positionals;
+
+ ensure_positionals_storage(interp, self, num_pos + 1);
+
+ self->positionals[num_pos].u.n = value;
+ self->positionals[num_pos].type = FLOATCELL;
+ self->num_positionals++;
+}
+
+void
+Parrot_pcc_signature_push_string(PARROT_INTERP, ARGIN(Parrot_Signature *self),
+ ARGIN_NULLOK(STRING *value))
+{
+ INTVAL num_pos = self->num_positionals;
+
+ ensure_positionals_storage(interp, self, num_pos + 1);
+
+ self->positionals[num_pos].u.s = value;
+ self->positionals[num_pos].type = STRINGCELL;
+ self->num_positionals++;
+}
+
+void
+Parrot_pcc_signature_push_pmc(PARROT_INTERP, ARGIN(Parrot_Signature *self),
+ ARGIN_NULLOK(PMC *value))
+{
+ INTVAL num_pos = self->num_positionals;
+
+ PARROT_ASSERT(!PObj_on_free_list_TEST(value)
+ || !"Push dead object into CallContext!");
+
+
+ ensure_positionals_storage(interp, self, num_pos + 1);
+
+ self->positionals[num_pos].u.p = value;
+ self->positionals[num_pos].type = PMCCELL;
+ self->num_positionals++;
+}
/*

0 comments on commit 8e1c54f

Please sign in to comment.