NAME ^

compilers/imcc/symreg.c

DESCRIPTION ^

imcc symbol handling

XXX: SymReg stuff has become overused. SymReg should be for symbolic registers, reg allocation, etc. but we are now using it for extensive symbol table management. Need to convert much of this over the use Symbol and SymbolTable (see symbol.h and symbol.c)

Functions ^

void push_namespace(char *name)

TODO: Not yet documented!!!

void pop_namespace(NULLOK(char *name))

TODO: Not yet documented!!!

static SymReg *_get_sym_typed(NOTNULL(const SymHash *hsh), NOTNULL(const char *name), int t)

Gets a symbol from the hash

SymReg *_mk_symreg(NOTNULL(SymHash *hsh), NOTNULL(char *name), int t)

Makes a new SymReg from its varname and type

char * name is a malloced string that will be used if the symbol needs to be created, or freed if an old symbol is found. This is a potentially dangerous semantic that should be changed.

SymReg *mk_symreg(PARROT_INTERP, NOTNULL(char *name), int t)

TODO: Not yet documented!!!

PARROT_MALLOC char *symreg_to_str(NOTNULL(const SymReg *s))

Dump a SymReg to a printable format.

SymReg *mk_temp_reg(PARROT_INTERP, int t)

TODO: Not yet documented!!!

SymReg *mk_pcc_sub(PARROT_INTERP, NOTNULL(char *name), int proto)

TODO: Not yet documented!!!

void add_namespace(PARROT_INTERP, NOTNULL(struct _IMC_Unit *unit))

add current namespace to sub decl

void add_pcc_arg(NOTNULL(SymReg *r), NOTNULL(SymReg *arg))

Add a register or constant to the function arg list

void add_pcc_param(NOTNULL(SymReg *r), NOTNULL(SymReg *arg))

TODO: Not yet documented!!!

void add_pcc_result(NOTNULL(SymReg *r), NOTNULL(SymReg *arg))

TODO: Not yet documented!!!

void add_pcc_multi(NOTNULL(SymReg *r), SymReg *arg)

TODO: Not yet documented!!!

void add_pcc_return(NOTNULL(SymReg *r), NOTNULL(SymReg *arg))

TODO: Not yet documented!!!

void add_pcc_sub(NOTNULL(SymReg *r), SymReg *arg)

TODO: Not yet documented!!!

void add_pcc_cc(NOTNULL(SymReg *r), SymReg *arg)

TODO: Not yet documented!!!

SymReg *mk_pasm_reg(PARROT_INTERP, char *name)

TODO: Not yet documented!!!

char *_mk_fullname(NULLOK(const Namespace *ns), NOTNULL(const char *name))

TODO: Not yet documented!!!

char *mk_fullname(NOTNULL(const char *name))

TODO: Not yet documented!!!

PARROT_CANNOT_RETURN_NULL PARROT_WARN_UNUSED_RESULT SymReg *mk_ident(PARROT_INTERP, NOTNULL(char *name), int t)

Makes a new identifier

PARROT_CANNOT_RETURN_NULL PARROT_WARN_UNUSED_RESULT SymReg *mk_ident_ur(PARROT_INTERP, NOTNULL(char *name), int t)

TODO: Not yet documented!!!

PARROT_CANNOT_RETURN_NULL PARROT_WARN_UNUSED_RESULT static SymReg *mk_pmc_const_2(PARROT_INTERP, NOTNULL(IMC_Unit *unit), NOTNULL(SymReg *left), NOTNULL(SymReg *rhs))

TODO: Not yet documented!!!

SymReg *mk_const_ident(PARROT_INTERP, NOTNULL(char *name), int t, NOTNULL(SymReg *val), int global)

Makes a new identifier constant with value val

SymReg *_mk_const(NOTNULL(SymHash *hsh), NOTNULL(const char *name), int t)

Makes a new constant

SymReg *mk_const(PARROT_INTERP, NOTNULL(const char *name), int t)

TODO: Not yet documented!!!

static char *add_ns(PARROT_INTERP, NOTNULL(char *name))

add namespace to sub if any

SymReg *_mk_address(PARROT_INTERP, NOTNULL(SymHash *hsh), NOTNULL(char *name), int uniq)

Makes a new address

SymReg *mk_address(PARROT_INTERP, char *name, int uniq)

Eventually make mk_address static

SymReg *mk_sub_label(PARROT_INTERP, NOTNULL(char *name))

Make and store a new address label for a sub. Label gets a fixup entry.

SymReg *mk_sub_address(PARROT_INTERP, NOTNULL(char *name))

Make a symbol for a label, symbol gets a fixup entry.

SymReg *mk_local_label(PARROT_INTERP, NOTNULL(char *name))

Make a local symbol, no fixup entry.

SymReg *mk_label_address(PARROT_INTERP, NOTNULL(char *name))

TODO: Not yet documented!!!

PARROT_MALLOC SymReg *dup_sym(NOTNULL(const SymReg *r))

link keys to a keys structure = SymReg

we might have

what op type pbc.c:build_key() -------------------------------------------------- int const _kic VTCONST no int reg _ki VTREG no str const _kc VTCONST yes str reg _kc VTREG yes

 "key" ';' "key" _kc           -> (list of above)   yes
 "key" ';' $I0   _kc  VTREGKEY -> (list of above)   yes

 The information about which reg should be passed to build_key() is
 in the instruction.

 A key containing a variable has a special flag VTREGKEY
 because this key must be considered for life analysis for
 all the chain members, that are variables.

 An instruction with a keychain looks like this

 e.h. set I0, P["abc";0;I1]

 ins->r[2]  = keychain  'K'
 keychain->nextkey = SymReg(VTCONST) "abc"
             ->nextkey = SymReg(VTCONST) 0
                ->nextkey = SymReg(VTREG), ...->reg = VTVAR I1
                   ->nextkey = 0

 We can't use the consts or keys in the chain directly,
 because a different usage would destroy the ->nextkey pointers
 so these are all copies.
 XXX and currently not freed
SymReg *link_keys(PARROT_INTERP, int nargs, NOTNULL(SymReg *keys[]), int force)

TODO: Not yet documented!!!

void free_sym(NOTNULL(SymReg *r))

TODO: Not yet documented!!!

void create_symhash(NOTNULL(SymHash *hash))

TODO: Not yet documented!!!

static void resize_symhash(NOTNULL(SymHash *hsh))

TODO: Not yet documented!!!

void _store_symreg(NOTNULL(SymHash *hsh), NOTNULL(SymReg *r))

Stores a symbol into the hash

void store_symreg(PARROT_INTERP, NOTNULL(SymReg *r))

TODO: Not yet documented!!!

PARROT_CAN_RETURN_NULL PARROT_WARN_UNUSED_RESULT SymReg *_get_sym(NOTNULL(SymHash *hsh), NOTNULL(const char *name))

Gets a symbol from the hash

PARROT_CAN_RETURN_NULL PARROT_WARN_UNUSED_RESULT SymReg *get_sym(PARROT_INTERP, NOTNULL(const char *name))

Gets a symbol from the current unit symbol table

PARROT_CAN_RETURN_NULL PARROT_WARN_UNUSED_RESULT SymReg *_find_sym(PARROT_INTERP, NULLOK(const Namespace *nspace), NOTNULL(SymHash *hsh), NOTNULL(const char *name))

find a symbol hash or ghash

PARROT_CAN_RETURN_NULL PARROT_WARN_UNUSED_RESULT SymReg *find_sym(PARROT_INTERP, NOTNULL(const char *name))

TODO: Not yet documented!!!

void clear_sym_hash(NOTNULL(SymHash *hsh))

TODO: Not yet documented!!!

void debug_dump_sym_hash(NOTNULL(SymHash *hsh))

TODO: Not yet documented!!!

void clear_locals(NULLOK(struct _IMC_Unit *unit))

Deletes all local symbols and clears life info

void clear_globals(PARROT_INTERP)

Clear global symbols

PARROT_PURE_FUNCTION unsigned int hash_str(NOTNULL(const char *str))

TODO: Not yet documented!!!


parrot