NAME ^

bcg.c Byte Code Generator (BCG) Public API implementation.

DESCRIPTION ^

The functions in this file implement the API defined in bcg.h, the public API for BCG.

Methods ^

List of methods implemented in this file.

BCG_info *BCG_create(void)

This function create an instance of Byte Code Generator.

void BCG_destroy(BCG_info *bcg_info)

This methods destroys the specified instance of Byte Code Generator.

void BCG_start_code_gen(BCG_info *bcg_info)

Sets the state of BCG to the CODEGEN state. If BCG is not able to switch to this state reasonably, an exception is thrown.

void BCG_end_code_gen(BCG_info *bcg_info)

Moves BCG back out of the CODEGEN state. If BCG is not in the CODEGEN state, an exception is thrown.

void BCG_start_sub(BCG_info *bcg_info, char *sub_name, char *pragma)

Starts the code generation for a new subroutine object, and adds the subroutine to the BCG symbol table. If BCG is not in the CODEGEN state, an exception is thrown. Moves BCG into the SUB state.

void BCG_end_sub(BCG_info *bcg_info)

Moves BCG out of the SUB state and runs the vanilla register allocator on the current subroutine unit. If BCG is not in the SUB state, an exceptio is thrown.

void BCG_start_call(BCG_info *bcg_info, char *sub_name)

Moves BCG into the CALL state. If BCG is not in the SUB state initially, an exception is thrown.

void BCG_end_call(BCG_info *bcg_info)

Moves BCG out of the CALL state. If BCG is not initially in the call state, an exception is thrown.

void BCG_start_op(BCG_info *bcg_info, char *op_name)

Moves BCG into the OP state. Adds the current op op_name into the current unit. If BCG is not in the SUB state initially, an exception is thrown.

void BCG_end_op(BCG_info *bcg_info)

Moves BCG out of the OP state. If BCG is not in the OP state initially, an exception is thrown. Resolves the full name of the current op.

void BCG_var(BCG_info *bcg_info, char *var_name, char var_type)

Adds the variable given by var_name with type var_type to the current op. Makes sure the variable is located in the current unit's symbol table. If BCG is not in the OP state to begin with, an exception is thrown.

void BCG_val(BCG_info *bcg_info, char *val, char val_type)

Adds a constant value val of type val_type to the current op. If BCG is not in the OP state, an exception is thrown.

void BCG_label(BCG_info *bcg_info, char *label)

Adds a label label to the current unit. If BCG is not in the SUB state, an exception is thrown.

void BCG_print_pasm(BCG_info *bcg_info)

This is the implementation for the op printPASM(), which decompiles the bytecode to PASM.

bcg_info_private *bcg_info_private_create(BCG_info *bcg_info)

Allocates space for bcg_info's private data structure. This structure is allocated from the system and needs to be freed.

void bcg_info_private_destroy(BCG_info *bcg_info, bcg_info_private *bcg_info_priv)

Destroys bcg_info's private data structure bcg_info_priv. Destroy's all units in the private structure.

void bcg_info_add_unit(BCG_info *bcg_info, bcg_unit *unit)

Adds unit to the double-linked list in bcg_info.

static void set_state(BCG_info *bcg_info, bcg_state state)

Set's BCG's internal state field to include state.

static void unset_state(BCG_info *bcg_info, bcg_state state)

Sets BCG's internal state field to exclude state.

static int in_state(BCG_info *bcg_info, bcg_state state)

Determines if BCG is currently in state. Returns 1 if true, 0 otherwise.

LICENSE ^

Copyright (C) 2006, The Perl Foundation.

This is free software; you may redistribute it and/or modify it under the same terms as Parrot.

AUTHOR ^

Vishal Soni <vishalrsoni@gmail.com>


parrot