1 # Copyright (C) 2004-2008, Parrot Foundation.
3 package Parrot
::Pmc2c
::VTable
;
9 use Parrot
::Pmc2c
::Method
();
14 my ( $class, $filename ) = @_;
17 $self->build($filename) if $filename;
22 my ( $self, $filename ) = @_;
23 my $vtable_table = parse_vtable
($filename);
25 my ( %method_lookup, @methods, @method_names );
27 foreach my $entry (@
$vtable_table) {
28 $method_lookup{ $entry->[1] } = scalar @methods;
30 Parrot
::Pmc2c
::Method
->new(
32 return_type
=> $entry->[0],
34 parameters
=> $entry->[2],
35 section
=> $entry->[3],
36 mmd_name
=> $entry->[4] eq -1 ?
"" : $entry->[4],
37 right
=> right_type
( $entry->[4] ),
38 mmd_prefix
=> prefix
( $entry->[4] ),
40 type
=> Parrot
::Pmc2c
::Method
::VTABLE_ENTRY
,
43 push @method_names, $entry->[1];
46 $self->filename($filename);
47 $self->{'has_method'} = \
%method_lookup;
48 $self->{'methods'} = \
@methods;
49 $self->{'names'} = \
@method_names;
56 return '' if $mmd_name eq -1;
57 return 'enum_type_INTVAL' if ( $mmd_name =~ s/_INT$// );
58 return 'enum_type_FLOATVAL' if ( $mmd_name =~ s/_FLOAT$// );
59 return 'enum_type_STRING' if ( $mmd_name =~ s/_STR$// );
60 return 'enum_type_PMC';
65 return '' if $mmd_name eq -1;
66 $mmd_name =~ s/_INT$//;
67 $mmd_name =~ s/_FLOAT$//;
68 $mmd_name =~ s/_STR$//;
77 . basename
( Parrot
::Pmc2c
::UtilFunctions
::filename
( $self->filename, '.dump' ) );
78 Storable
::store
( $self, $dump_filename );
79 return $dump_filename;
83 my ( $self, $methodname ) = @_;
84 return $self->{'has_method'}->{$methodname};
88 my ( $self, $methodname ) = @_;
89 my $method = $self->get_method($methodname);
90 return ( defined $method and $method->is_mmd );
94 my ( $self, $methodname ) = @_;
95 my $method_index = $self->has_method($methodname);
96 return unless defined $method_index;
97 return $self->{methods
}->[$method_index];
101 my ( $self, $value ) = @_;
102 $self->{names
} = $value if $value;
103 return $self->{names
};
107 my ( $self, $value ) = @_;
108 $self->{methods
} = $value if $value;
109 return $self->{methods
};
113 my ( $self, $value ) = @_;
114 $self->{filename
} = $value if $value;
115 return $self->{filename
};
119 my ( $self, $vt_meth ) = @_;
120 return $self->get_method($vt_meth)->attrs;
127 # cperl-indent-level: 4
130 # vim: expandtab shiftwidth=4: