NAME ^

compilers/imcc/parser_util.c

DESCRIPTION ^

ParserUtil - Parser support functions.

Functions ^

PARROT_WARN_UNUSED_RESULT PARROT_CAN_RETURN_NULL Instruction *iNEW(PARROT_INTERP, NOTNULL(IMC_Unit *unit), NOTNULL(SymReg *r0), NOTNULL(char *type), NULLOK(SymReg *init), int emit)

 * P = new type, [init]
 * PASM like:
 *   new P, .SomeThing
 * is done in the lexer, this is a mess
 * best would be to have a flag in core.ops, where a PMC type is expected
void op_fullname(NOTNULL(char *dest), ARGIN(const char *name), NOTNULL(SymReg *args[]), int narg, int keyvec)

Lookup the full opcode given the short name

   set I0, 5  -> set_i_ic
   set I0, I1 -> set_i_i
Obviously the registers must be examined before returning the correct opcode.

NOTE: All this nasty IMC_TRACE is for tracking down equally nasty bugs, so if you don't like the looks of it, stay out, but please don't remove it. :) -Mel

PARROT_WARN_UNUSED_RESULT int check_op(PARROT_INTERP, NOTNULL(char *fullname), ARGIN(const char *name), NOTNULL(SymReg *r[]), int narg, int keyvec)

Return opcode value for op name

PARROT_WARN_UNUSED_RESULT PARROT_CAN_RETURN_NULL static Instruction *maybe_builtin(PARROT_INTERP, ARGIN(const char *name), NOTNULL(SymReg **r), int n)

TODO: Needs to be documented!!!

PARROT_WARN_UNUSED_RESULT int is_op(PARROT_INTERP, ARGIN(const char *name))

Is instruction a parrot opcode?

PARROT_WARN_UNUSED_RESULT PARROT_CANNOT_RETURN_NULL static const char *to_infix(PARROT_INTERP, ARGIN(const char *name), NOTNULL(SymReg **r), NOTNULL(int *n), int mmd_op)

sub x, y, z => infix .MMD_SUBTRACT, x, y, z

PARROT_WARN_UNUSED_RESULT static int is_infix(ARGIN(const char *name), int n, NOTNULL(SymReg **r))

TODO: Needs to be documented!!!

PARROT_MALLOC PARROT_CANNOT_RETURN_NULL PARROT_WARN_UNUSED_RESULT static Instruction *var_arg_ins(PARROT_INTERP, NOTNULL(IMC_Unit *unit), ARGIN(const char *name), NOTNULL(SymReg **r), int n, int emit)

TODO: Needs to be documented!!!

PARROT_CAN_RETURN_NULL Instruction *INS(PARROT_INTERP, NOTNULL(IMC_Unit *unit), ARGIN(const char *name), ARGIN_NULLOK(const char *fmt), NOTNULL(SymReg **r), int n, int keyvec, int emit)

Make an instruction.

name ... op name fmt ... optional format regs ... SymReg ** n ... # of params keyvec ... s. KEY_BIT() emit ... if true, append to instructions

s. e.g. imc.c for usage

PARROT_API int do_yylex_init(PARROT_INTERP, NOTNULL(yyscan_t *yyscanner))

TODO: Needs to be documented!!!

PARROT_WARN_UNUSED_RESULT PARROT_CANNOT_RETURN_NULL PMC *imcc_compile(PARROT_INTERP, ARGIN(const char *s), int pasm_file, NOTNULL(STRING **error_message))

Compile a pasm or imcc string

FIXME as we have separate constants, the old constants in ghash must be deleted.

PARROT_WARN_UNUSED_RESULT PARROT_CANNOT_RETURN_NULL PMC *imcc_compile_pasm(PARROT_INTERP, ARGIN(const char *s))

TODO: Needs to be documented!!!

 * Note: This function is provided for backward compatibility. This
 * function can go away in future.
PARROT_WARN_UNUSED_RESULT PARROT_CANNOT_RETURN_NULL PMC *imcc_compile_pir(PARROT_INTERP, ARGIN(const char *s))

TODO: Needs to be documented!!!

 * Note: This function is provided for backward compatibility. This
 * function can go away in future.
PARROT_WARN_UNUSED_RESULT PARROT_CANNOT_RETURN_NULL PMC *IMCC_compile_pir_s(PARROT_INTERP, ARGIN(const char *s), NOTNULL(STRING **error_message))

TODO: Needs to be documented!!!

PARROT_WARN_UNUSED_RESULT PARROT_CANNOT_RETURN_NULL PMC *IMCC_compile_pasm_s(PARROT_INTERP, ARGIN(const char *s), NOTNULL(STRING **error_message))

TODO: Needs to be documented!!!

PARROT_WARN_UNUSED_RESULT PARROT_CANNOT_RETURN_NULL PMC *imcc_compile_pasm_ex(PARROT_INTERP, ARGIN(const char *s))

TODO: Needs to be documented!!!

PARROT_WARN_UNUSED_RESULT PARROT_CANNOT_RETURN_NULL PMC *imcc_compile_pir_ex(PARROT_INTERP, ARGIN(const char *s))

TODO: Needs to be documented!!!

PARROT_CANNOT_RETURN_NULL static void *imcc_compile_file(PARROT_INTERP, ARGIN(const char *fullname), NOTNULL(STRING **error_message))

Compile a file by filename (can be either PASM or IMCC code)

PARROT_CANNOT_RETURN_NULL void *IMCC_compile_file(PARROT_INTERP, ARGIN(const char *s))

TODO: Needs to be documented!!!

 * Note: This function is provided for backward compatibility. This
 * function can go away in future.
PARROT_CANNOT_RETURN_NULL void *IMCC_compile_file_s(PARROT_INTERP, ARGIN(const char *s), NOTNULL(STRING **error_message))

TODO: Needs to be documented!!!

void register_compilers(PARROT_INTERP)

Register additional compilers with the interpreter

PARROT_WARN_UNUSED_RESULT static int change_op(PARROT_INTERP, NOTNULL(IMC_Unit *unit), NOTNULL(SymReg **r), int num, int emit)

TODO: Needs to be documented!!!

PARROT_WARN_UNUSED_RESULT int try_find_op(PARROT_INTERP, NOTNULL(IMC_Unit *unit), ARGIN(const char *name), NOTNULL(SymReg **r), int n, int keyvec, int emit)

Try to find valid op doing the same operation e.g.

   add_n_i_n => add_n_n_i
   div_n_ic_n => div_n_nc_n
   div_n_i_n => set_n_i ; div_n_n_n
   ge_n_ic_ic => ge_n_nc_ic
   acos_n_i   => acos_n_n
PARROT_WARN_UNUSED_RESULT PARROT_CAN_RETURN_NULL static const char *try_rev_cmp(ARGIN(const char *name), NOTNULL(SymReg **r))

TODO: Needs to be documented!!!

PARROT_CAN_RETURN_NULL Instruction *multi_keyed(PARROT_INTERP, NOTNULL(IMC_Unit *unit), NOTNULL(char *name), NOTNULL(SymReg **r), int nr, int keyvec, int emit)

TODO: Needs to be documented!!!

int imcc_fprintf(PARROT_INTERP, NOTNULL(FILE *fd), ARGIN(const char *fmt), ...)

TODO: Needs to be documented!!!

int imcc_vfprintf(PARROT_INTERP, NOTNULL(FILE *fd), ARGIN(const char *format), va_list ap)

TODO: Needs to be documented!!!

PARROT_MALLOC PARROT_WARN_UNUSED_RESULT PARROT_CANNOT_RETURN_NULL char *str_dup(ARGIN(const char *old))

TODO: Needs to be documented!!!

PARROT_API void imcc_init(PARROT_INTERP)

TODO: Needs to be documented!!!

PARROT_API void imcc_destroy(PARROT_INTERP)

TODO: Needs to be documented!!!


parrot