Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

122 lines (78 sloc) 2.432 kb
/*
Copyright (C) 2008-2014, Parrot Foundation.
=head1 NAME
src/pmc/lexinfo.pmc - LexInfo PMC
=head1 DESCRIPTION
These are the vtable functions for the lexinfo PMC.
=head2 Functions
=over 4
=cut
*/
#include "pmc/pmc_hash.h"
/* HEADERIZER HFILE: none */
/* HEADERIZER BEGIN: static */
/* HEADERIZER END: static */
/*
* LexInfo contains a constant Hash with constant string
* keys and integer indices
*/
pmclass LexInfo extends Hash provides hash no_ro auto_attrs {
/*
=item C<init_pmc(PMC *sub)>
Initialize the LexInfo PMC and remember the associate
subroutine.
The C<sub> argument is currently ignored.
=cut
*/
VTABLE void init() :manual_wb {
/* Set value type to INTVAL */
SELF.init_int((INTVAL)enum_type_INTVAL);
}
VTABLE void init_pmc(PMC *sub) :manual_wb {
UNUSED(sub)
/* Set value type to INTVAL */
SELF.init_int((INTVAL)enum_type_INTVAL);
}
/*
=item C<void declare_lex_preg(STRING *name, INTVAL preg)>
Declare a lexical variable that is an alias for a PMC register. This is
the dynamic version of a ".lex STRING, PREG" directive.
Note that the second argument is just an integer, i.e. C<0> for C<$P0>.
=cut
*/
METHOD declare_lex_preg(STRING *name, INTVAL preg) {
VTABLE_set_integer_keyed_str(INTERP, SELF, name,
(preg << 2) | REGNO_PMC);
}
/*
=item C<PMC *inspect_str(STRING *what)>
Introspects this LexInfo structure. The only valid introspection key is
C<symbols>, which gets an array of the names of the symbols in this lexpad.
=cut
*/
VTABLE PMC *inspect_str(STRING *what) :no_wb {
if (STRING_equal(INTERP, what, CONST_STRING(INTERP, "symbols"))) {
PMC * const result = Parrot_pmc_new(INTERP, enum_class_ResizableStringArray);
const Hash *hash = (Hash *)SELF.get_pointer();
parrot_hash_iterate(hash,
PARROT_ASSERT(_bucket->key);
VTABLE_push_string(INTERP, result, (STRING *)_bucket->key););
return result;
}
else
Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_INVALID_OPERATION,
"Unknown introspection value '%S'", what);
}
}
/*
=back
=head1 SEE ALSO
F<docs/pdds/pdd20_lexical_vars.pod>, F<src/classes/lexpad.pmc>.
=cut
*/
/*
* Local variables:
* c-file-style: "parrot"
* End:
* vim: expandtab shiftwidth=4 cinoptions='\:2=2' :
*/
Jump to Line
Something went wrong with that request. Please try again.