Permalink
Browse files

Merge branch tt761_keys_revamp into trunk.

git-svn-id: https://svn.parrot.org/parrot/trunk@40100 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information...
1 parent 21c30ce commit 53fc3e4e9d82f02214761f63b2a12d35a7b7f777 @bacek bacek committed Jul 15, 2009
@@ -33,6 +33,7 @@ sub _init {
include/parrot/events.h
include/parrot/scheduler.h
include/parrot/exceptions.h
+ include/parrot/hash.h
include/parrot/interpreter.h
include/parrot/io.h
include/parrot/longopt.h
View
@@ -46,13 +46,15 @@ typedef int (*hash_comp_fn)(PARROT_INTERP, const void*const, const void*const);
typedef void (*hash_mark_key_fn)(PARROT_INTERP, PObj *);
typedef size_t (*hash_hash_key_fn)(PARROT_INTERP, ARGIN(const void *), size_t seed);
+/* &gen_from_enum(hash_key_type.pasm) */
typedef enum {
Hash_key_type_int,
Hash_key_type_cstring,
Hash_key_type_STRING,
Hash_key_type_PMC,
Hash_key_type_ptr
} Hash_key_type;
+/* &end_gen */
typedef struct _hashbucket {
struct _hashbucket *next;
@@ -128,10 +130,9 @@ PARROT_WARN_UNUSED_RESULT
PARROT_CAN_RETURN_NULL
HashBucket * parrot_hash_get_bucket(PARROT_INTERP,
ARGIN(const Hash *hash),
- ARGIN(const void *key))
+ ARGIN_NULLOK(const void *key))
__attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(3);
+ __attribute__nonnull__(2);
PARROT_EXPORT
PARROT_WARN_UNUSED_RESULT
@@ -149,11 +150,10 @@ PARROT_IGNORABLE_RESULT
PARROT_CANNOT_RETURN_NULL
HashBucket* parrot_hash_put(PARROT_INTERP,
ARGMOD(Hash *hash),
- ARGIN(void *key),
+ ARGIN_NULLOK(void *key),
ARGIN_NULLOK(void *value))
__attribute__nonnull__(1)
__attribute__nonnull__(2)
- __attribute__nonnull__(3)
FUNC_MODIFIES(*hash);
PARROT_EXPORT
@@ -212,8 +212,9 @@ int int_compare(SHIM_INTERP,
PARROT_WARN_UNUSED_RESULT
PARROT_PURE_FUNCTION
-size_t key_hash_int(SHIM_INTERP, ARGIN(const void *value), size_t seed)
- __attribute__nonnull__(2);
+size_t key_hash_int(SHIM_INTERP,
+ ARGIN_NULLOK(const void *value),
+ size_t seed);
void parrot_chash_destroy(PARROT_INTERP, ARGMOD(Hash *hash))
__attribute__nonnull__(1)
@@ -261,16 +262,14 @@ Hash * parrot_create_hash(PARROT_INTERP,
|| PARROT_ASSERT_ARG(key)
#define ASSERT_ARGS_parrot_hash_get_bucket __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(hash) \
- || PARROT_ASSERT_ARG(key)
+ || PARROT_ASSERT_ARG(hash)
#define ASSERT_ARGS_parrot_hash_get_idx __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(hash) \
|| PARROT_ASSERT_ARG(key)
#define ASSERT_ARGS_parrot_hash_put __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(hash) \
- || PARROT_ASSERT_ARG(key)
+ || PARROT_ASSERT_ARG(hash)
#define ASSERT_ARGS_parrot_hash_size __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(hash)
#define ASSERT_ARGS_parrot_hash_visit __attribute__unused__ int _ASSERT_ARGS_CHECK = \
@@ -292,8 +291,7 @@ Hash * parrot_create_hash(PARROT_INTERP,
#define ASSERT_ARGS_parrot_new_pointer_hash __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp)
#define ASSERT_ARGS_int_compare __attribute__unused__ int _ASSERT_ARGS_CHECK = 0
-#define ASSERT_ARGS_key_hash_int __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(value)
+#define ASSERT_ARGS_key_hash_int __attribute__unused__ int _ASSERT_ARGS_CHECK = 0
#define ASSERT_ARGS_parrot_chash_destroy __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(hash)
View
@@ -85,7 +85,7 @@ PARROT_IGNORABLE_RESULT
PMC * pmc_reuse(PARROT_INTERP,
ARGIN(PMC *pmc),
INTVAL new_type,
- NULLOK(UINTVAL flags))
+ UINTVAL flags)
__attribute__nonnull__(1)
__attribute__nonnull__(2);
@@ -102,6 +102,18 @@ PMC * pmc_reuse_by_class(PARROT_INTERP,
FUNC_MODIFIES(*pmc);
PARROT_EXPORT
+PARROT_CANNOT_RETURN_NULL
+PARROT_IGNORABLE_RESULT
+PMC * pmc_reuse_init(PARROT_INTERP,
+ ARGIN(PMC *pmc),
+ INTVAL new_type,
+ ARGIN(PMC *init),
+ UINTVAL flags)
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2)
+ __attribute__nonnull__(4);
+
+PARROT_EXPORT
PARROT_WARN_UNUSED_RESULT
INTVAL pmc_type(PARROT_INTERP, ARGIN_NULLOK(STRING *name))
__attribute__nonnull__(1);
@@ -155,6 +167,10 @@ PMC * temporary_pmc_new(PARROT_INTERP, INTVAL base_type)
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(pmc) \
|| PARROT_ASSERT_ARG(class_)
+#define ASSERT_ARGS_pmc_reuse_init __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+ PARROT_ASSERT_ARG(interp) \
+ || PARROT_ASSERT_ARG(pmc) \
+ || PARROT_ASSERT_ARG(init)
#define ASSERT_ARGS_pmc_type __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp)
#define ASSERT_ARGS_pmc_type_p __attribute__unused__ int _ASSERT_ARGS_CHECK = \
@@ -104,8 +104,8 @@ sub trans {
return $1 if $char =~ /([ISP])/;
return 'N' if $char eq 'F';
- return 'v' if $type eq 'void';
return 'V' if $type =~ /void\s*\*/;
+ return 'v' if $type =~ /void\s*$/;
return 'P' if $type =~ /opcode_t\*/;
return 'I' if $type =~ /int(val)?/i;
return '?';
@@ -1002,12 +1002,15 @@ sub gen_switch_vtable {
my $multis = $multi_methods{$vt_method_name};
+ # Get parameters. strip type from param
+ my @parameters = map { s/(\s*\S+\s*\*?\s*)//; $_ } split (/,/, $method->parameters);
+
# Gather "case :"
- my @cases = map { $self->generate_single_case($vt_method_name, $_) } @$multis;
+ my @cases = map { $self->generate_single_case($vt_method_name, $_, @parameters) } @$multis;
my $cases = join "\n", @cases;
my $body = <<"BODY";
- INTVAL type = VTABLE_type(INTERP, value);
+ INTVAL type = VTABLE_type(INTERP, $parameters[0]);
/* For dynpmc fallback to MMD */
if ((type >= enum_class_core_max) || (SELF.type() >= enum_class_core_max))
type = enum_class_core_max;
@@ -1027,13 +1030,12 @@ BODY
# Generate single case for switch VTABLE
sub generate_single_case {
- my ($self, $vt_method_name, $multi) = @_;
+ my ($self, $vt_method_name, $multi, @parameters) = @_;
my ($type, $ssig, $fsig, $ns, $func, $impl) = @$multi;
my $case;
# Gather parameters names
- my @parameters = map { s/\s*PMC\s*\*\s*//; $_ } split (/,/, $impl->parameters);
my $parameters = join ', ', @parameters;
# ISO C forbids return with expression from void functions.
my $return = $impl->return_type =~ /^void\s*$/
@@ -1082,12 +1084,20 @@ sub gen_defaul_case_wrapping {
'return retval;',
);
}
+ elsif ($letter eq 'S') {
+ return (
+ "PP->" . $letter,
+ "STRING *retval;",
+ ', &retval',
+ 'return retval;',
+ );
+ }
elsif ($letter eq 'P') {
return (
'PPP->P',
- '',
- ", &$parameters[1]",
- "return $parameters[1];",
+ 'PMC *retval;',
+ ", &retval",
+ "return retval;",
);
}
elsif ($letter eq 'v') {
Oops, something went wrong.

0 comments on commit 53fc3e4

Please sign in to comment.