Skip to content

Commit

Permalink
Merge branch tt761_keys_revamp into trunk.
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.parrot.org/parrot/trunk@40100 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information
bacek committed Jul 15, 2009
1 parent 21c30ce commit 53fc3e4
Show file tree
Hide file tree
Showing 42 changed files with 2,878 additions and 1,335 deletions.
1 change: 1 addition & 0 deletions config/gen/parrot_include.pm
Expand Up @@ -33,6 +33,7 @@ sub _init {
include/parrot/events.h include/parrot/events.h
include/parrot/scheduler.h include/parrot/scheduler.h
include/parrot/exceptions.h include/parrot/exceptions.h
include/parrot/hash.h
include/parrot/interpreter.h include/parrot/interpreter.h
include/parrot/io.h include/parrot/io.h
include/parrot/longopt.h include/parrot/longopt.h
Expand Down
24 changes: 11 additions & 13 deletions include/parrot/hash.h
Expand Up @@ -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 void (*hash_mark_key_fn)(PARROT_INTERP, PObj *);
typedef size_t (*hash_hash_key_fn)(PARROT_INTERP, ARGIN(const void *), size_t seed); typedef size_t (*hash_hash_key_fn)(PARROT_INTERP, ARGIN(const void *), size_t seed);


/* &gen_from_enum(hash_key_type.pasm) */
typedef enum { typedef enum {
Hash_key_type_int, Hash_key_type_int,
Hash_key_type_cstring, Hash_key_type_cstring,
Hash_key_type_STRING, Hash_key_type_STRING,
Hash_key_type_PMC, Hash_key_type_PMC,
Hash_key_type_ptr Hash_key_type_ptr
} Hash_key_type; } Hash_key_type;
/* &end_gen */


typedef struct _hashbucket { typedef struct _hashbucket {
struct _hashbucket *next; struct _hashbucket *next;
Expand Down Expand Up @@ -128,10 +130,9 @@ PARROT_WARN_UNUSED_RESULT
PARROT_CAN_RETURN_NULL PARROT_CAN_RETURN_NULL
HashBucket * parrot_hash_get_bucket(PARROT_INTERP, HashBucket * parrot_hash_get_bucket(PARROT_INTERP,
ARGIN(const Hash *hash), ARGIN(const Hash *hash),
ARGIN(const void *key)) ARGIN_NULLOK(const void *key))
__attribute__nonnull__(1) __attribute__nonnull__(1)
__attribute__nonnull__(2) __attribute__nonnull__(2);
__attribute__nonnull__(3);


PARROT_EXPORT PARROT_EXPORT
PARROT_WARN_UNUSED_RESULT PARROT_WARN_UNUSED_RESULT
Expand All @@ -149,11 +150,10 @@ PARROT_IGNORABLE_RESULT
PARROT_CANNOT_RETURN_NULL PARROT_CANNOT_RETURN_NULL
HashBucket* parrot_hash_put(PARROT_INTERP, HashBucket* parrot_hash_put(PARROT_INTERP,
ARGMOD(Hash *hash), ARGMOD(Hash *hash),
ARGIN(void *key), ARGIN_NULLOK(void *key),
ARGIN_NULLOK(void *value)) ARGIN_NULLOK(void *value))
__attribute__nonnull__(1) __attribute__nonnull__(1)
__attribute__nonnull__(2) __attribute__nonnull__(2)
__attribute__nonnull__(3)
FUNC_MODIFIES(*hash); FUNC_MODIFIES(*hash);


PARROT_EXPORT PARROT_EXPORT
Expand Down Expand Up @@ -212,8 +212,9 @@ int int_compare(SHIM_INTERP,


PARROT_WARN_UNUSED_RESULT PARROT_WARN_UNUSED_RESULT
PARROT_PURE_FUNCTION PARROT_PURE_FUNCTION
size_t key_hash_int(SHIM_INTERP, ARGIN(const void *value), size_t seed) size_t key_hash_int(SHIM_INTERP,
__attribute__nonnull__(2); ARGIN_NULLOK(const void *value),
size_t seed);


void parrot_chash_destroy(PARROT_INTERP, ARGMOD(Hash *hash)) void parrot_chash_destroy(PARROT_INTERP, ARGMOD(Hash *hash))
__attribute__nonnull__(1) __attribute__nonnull__(1)
Expand Down Expand Up @@ -261,16 +262,14 @@ Hash * parrot_create_hash(PARROT_INTERP,
|| PARROT_ASSERT_ARG(key) || PARROT_ASSERT_ARG(key)
#define ASSERT_ARGS_parrot_hash_get_bucket __attribute__unused__ int _ASSERT_ARGS_CHECK = \ #define ASSERT_ARGS_parrot_hash_get_bucket __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \ PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(hash) \ || PARROT_ASSERT_ARG(hash)
|| PARROT_ASSERT_ARG(key)
#define ASSERT_ARGS_parrot_hash_get_idx __attribute__unused__ int _ASSERT_ARGS_CHECK = \ #define ASSERT_ARGS_parrot_hash_get_idx __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \ PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(hash) \ || PARROT_ASSERT_ARG(hash) \
|| PARROT_ASSERT_ARG(key) || PARROT_ASSERT_ARG(key)
#define ASSERT_ARGS_parrot_hash_put __attribute__unused__ int _ASSERT_ARGS_CHECK = \ #define ASSERT_ARGS_parrot_hash_put __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \ PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(hash) \ || PARROT_ASSERT_ARG(hash)
|| PARROT_ASSERT_ARG(key)
#define ASSERT_ARGS_parrot_hash_size __attribute__unused__ int _ASSERT_ARGS_CHECK = \ #define ASSERT_ARGS_parrot_hash_size __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(hash) PARROT_ASSERT_ARG(hash)
#define ASSERT_ARGS_parrot_hash_visit __attribute__unused__ int _ASSERT_ARGS_CHECK = \ #define ASSERT_ARGS_parrot_hash_visit __attribute__unused__ int _ASSERT_ARGS_CHECK = \
Expand All @@ -292,8 +291,7 @@ Hash * parrot_create_hash(PARROT_INTERP,
#define ASSERT_ARGS_parrot_new_pointer_hash __attribute__unused__ int _ASSERT_ARGS_CHECK = \ #define ASSERT_ARGS_parrot_new_pointer_hash __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) PARROT_ASSERT_ARG(interp)
#define ASSERT_ARGS_int_compare __attribute__unused__ int _ASSERT_ARGS_CHECK = 0 #define ASSERT_ARGS_int_compare __attribute__unused__ int _ASSERT_ARGS_CHECK = 0
#define ASSERT_ARGS_key_hash_int __attribute__unused__ int _ASSERT_ARGS_CHECK = \ #define ASSERT_ARGS_key_hash_int __attribute__unused__ int _ASSERT_ARGS_CHECK = 0
PARROT_ASSERT_ARG(value)
#define ASSERT_ARGS_parrot_chash_destroy __attribute__unused__ int _ASSERT_ARGS_CHECK = \ #define ASSERT_ARGS_parrot_chash_destroy __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \ PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(hash) || PARROT_ASSERT_ARG(hash)
Expand Down
18 changes: 17 additions & 1 deletion include/parrot/pmc.h
Expand Up @@ -85,7 +85,7 @@ PARROT_IGNORABLE_RESULT
PMC * pmc_reuse(PARROT_INTERP, PMC * pmc_reuse(PARROT_INTERP,
ARGIN(PMC *pmc), ARGIN(PMC *pmc),
INTVAL new_type, INTVAL new_type,
NULLOK(UINTVAL flags)) UINTVAL flags)
__attribute__nonnull__(1) __attribute__nonnull__(1)
__attribute__nonnull__(2); __attribute__nonnull__(2);


Expand All @@ -101,6 +101,18 @@ PMC * pmc_reuse_by_class(PARROT_INTERP,
__attribute__nonnull__(3) __attribute__nonnull__(3)
FUNC_MODIFIES(*pmc); 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_EXPORT
PARROT_WARN_UNUSED_RESULT PARROT_WARN_UNUSED_RESULT
INTVAL pmc_type(PARROT_INTERP, ARGIN_NULLOK(STRING *name)) INTVAL pmc_type(PARROT_INTERP, ARGIN_NULLOK(STRING *name))
Expand Down Expand Up @@ -155,6 +167,10 @@ PMC * temporary_pmc_new(PARROT_INTERP, INTVAL base_type)
PARROT_ASSERT_ARG(interp) \ PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(pmc) \ || PARROT_ASSERT_ARG(pmc) \
|| PARROT_ASSERT_ARG(class_) || 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 = \ #define ASSERT_ARGS_pmc_type __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) PARROT_ASSERT_ARG(interp)
#define ASSERT_ARGS_pmc_type_p __attribute__unused__ int _ASSERT_ARGS_CHECK = \ #define ASSERT_ARGS_pmc_type_p __attribute__unused__ int _ASSERT_ARGS_CHECK = \
Expand Down
2 changes: 1 addition & 1 deletion lib/Parrot/Pmc2c/Method.pm
Expand Up @@ -104,8 +104,8 @@ sub trans {


return $1 if $char =~ /([ISP])/; return $1 if $char =~ /([ISP])/;
return 'N' if $char eq 'F'; 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 'v' if $type =~ /void\s*$/;
return 'P' if $type =~ /opcode_t\*/; return 'P' if $type =~ /opcode_t\*/;
return 'I' if $type =~ /int(val)?/i; return 'I' if $type =~ /int(val)?/i;
return '?'; return '?';
Expand Down
24 changes: 17 additions & 7 deletions lib/Parrot/Pmc2c/PMCEmitter.pm
Expand Up @@ -1002,12 +1002,15 @@ sub gen_switch_vtable {


my $multis = $multi_methods{$vt_method_name}; 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 :" # 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 $cases = join "\n", @cases;


my $body = <<"BODY"; my $body = <<"BODY";
INTVAL type = VTABLE_type(INTERP, value); INTVAL type = VTABLE_type(INTERP, $parameters[0]);
/* For dynpmc fallback to MMD */ /* For dynpmc fallback to MMD */
if ((type >= enum_class_core_max) || (SELF.type() >= enum_class_core_max)) if ((type >= enum_class_core_max) || (SELF.type() >= enum_class_core_max))
type = enum_class_core_max; type = enum_class_core_max;
Expand All @@ -1027,13 +1030,12 @@ BODY


# Generate single case for switch VTABLE # Generate single case for switch VTABLE
sub generate_single_case { 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 ($type, $ssig, $fsig, $ns, $func, $impl) = @$multi;
my $case; my $case;


# Gather parameters names # Gather parameters names
my @parameters = map { s/\s*PMC\s*\*\s*//; $_ } split (/,/, $impl->parameters);
my $parameters = join ', ', @parameters; my $parameters = join ', ', @parameters;
# ISO C forbids return with expression from void functions. # ISO C forbids return with expression from void functions.
my $return = $impl->return_type =~ /^void\s*$/ my $return = $impl->return_type =~ /^void\s*$/
Expand Down Expand Up @@ -1082,12 +1084,20 @@ sub gen_defaul_case_wrapping {
'return retval;', 'return retval;',
); );
} }
elsif ($letter eq 'S') {
return (
"PP->" . $letter,
"STRING *retval;",
', &retval',
'return retval;',
);
}
elsif ($letter eq 'P') { elsif ($letter eq 'P') {
return ( return (
'PPP->P', 'PPP->P',
'', 'PMC *retval;',
", &$parameters[1]", ", &retval",
"return $parameters[1];", "return retval;",
); );
} }
elsif ($letter eq 'v') { elsif ($letter eq 'v') {
Expand Down

0 comments on commit 53fc3e4

Please sign in to comment.