Main Page   Compound List   File List   Compound Members   File Members  

ecl.h File Reference

Go to the source code of this file.

Compounds

struct  extern_entry
struct  _ecl_code_struct

Typedefs

typedef parse_struct * ecl_parse_context
typedef sm_struct * sm_ref
typedef extern_entry ecl_extern_entry
typedef ecl_extern_entryecl_extern_list
typedef _ecl_code_structecl_code
typedef void(* err_out_func_t )(void *client_data, char *string)

Functions

ecl_parse_context new_ecl_parse_context ()
void ecl_free_parse_context (ecl_parse_context context)
void ecl_assoc_externs (ecl_parse_context context, ecl_extern_list externs)
void ecl_add_decl_to_parse_context (const char *id, sm_ref node, ecl_parse_context context)
 This is used to make a semantic reference to a structured type available in a particular context. More...

void ecl_add_struct_type (const char *name, IOFieldList field_list, ecl_parse_context context)
 Make a structured type, represented by a PBIO-style IOFieldList, available in a particular context. More...

sm_ref ecl_build_type_node (const char *name, IOFieldList field_list)
 This is used to create a semantic reference to a structured type directly from a PBIO-style IOFieldList. More...

sm_ref ecl_build_param_node (const char *id, sm_ref typ, int param_num)
 This is used to declare a parameter to the routine to be generated. More...

void ecl_add_param (const char *id, const char *typ, int param_num, ecl_parse_context context)
 Declare a parameter to the generated function. More...

void ecl_set_return_type (char *typ, ecl_parse_context context)
 This establishes the return type for the generated function. More...

ecl_code ecl_code_gen (char *code, ecl_parse_context context)
int ecl_code_verify (char *code, ecl_parse_context context)
void ecl_code_free (ecl_code code)
int ecl_parse_for_context (char *code, ecl_parse_context context)
 This parses a string to determine what external functions and variables are visible during code generation. More...

ecl_parse_context ecl_copy_context (ecl_parse_context context)
void ecl_set_error_func (ecl_parse_context context, err_out_func_t err_func)
void ecl_dump (ecl_code code)


Detailed Description


Typedef Documentation

typedef struct parse_struct* ecl_parse_context
 

ecl_parse_context is the basic handle controlling generation of subroutines and functions. It is used in nearly all calls to setup parameter profiles and other information and to generate the code. Using a separate handle rather than static variables to store this information over the multiple calls needed for code generation ensures thread safety.

typedef struct sm_struct* sm_ref
 

sm_ref is a pointer to an internal ECL data structure representing a semantic element of a program fragment (E.G. a parameter definition).

typedef struct extern_entry ecl_extern_entry
 

A structure to hold external entries.

This is used to associate textual names with addresses.

typedef ecl_extern_entry* ecl_extern_list
 

A list of ecl_extern_entry structures. This is used to specify the addresses of external functions or variables that a function may access.

typedef struct _ecl_code_struct * ecl_code
 

ecl_code is a handle to the generated code. In addition to the generated code block, it holds external data pointers and supplemental information.

typedef void(* err_out_func_t)(void *client_data, char *string)
 

err_out_func_t is a function pointer type. Functions matching this profile can be used as call-out handlers for ECL errors.

Parameters:
client_data  an uninspected value passed in from ecl_set_error_func()
string  the textual representation of the error.


Function Documentation

ecl_parse_context new_ecl_parse_context  
 

Create a handle to a new ecl_parse_context.

This is generally the first call in dynamically generating a subroutine/function. The ecl_parse_context created here is used in all future calls, setting up the parameter profile and generating the code.

Returns:
Will return a new initialized ecl_parse_context unless there is no available memory.

void ecl_free_parse_context ecl_parse_context    context
 

Free a handle to an ecl_parse_context.

Parameters:
context  the ecl_parse_context to be free'd. Calling this routine frees all memory associated with the parse context, but not that of code that has been generated from this context.

void ecl_assoc_externs ecl_parse_context    context,
ecl_extern_list    externs
 

Associate a set of "name, external address" pairs with a parse context

These names and addresses are used to resolve (external references in generated code). In addition to associating the addresses, the full prototypes of the functions or variables must be added to the parse context, usually with ecl_parse_for_context().

Parameters:
context  the ecl_parse_context to which the externs are associated.
externs  the list of "name, external address" pairs to be associated. This list should be terminated with a {NULL, 0} pair.

void ecl_add_decl_to_parse_context const char *    id,
sm_ref    node,
ecl_parse_context    context
 

This is used to make a semantic reference to a structured type available in a particular context.

This is used with a sm_ref that is generated from ecl_build_type_node().

Parameters:
id  the name to be associated with the type.
node  the sm_ref from ecl_build_type_node().
context  the context in which the type is to be made available.
Deprecated:
Use ecl_add_struct_type()

void ecl_add_struct_type const char *    name,
IOFieldList    field_list,
ecl_parse_context    context
 

Make a structured type, represented by a PBIO-style IOFieldList, available in a particular context.

Parameters:
name  the name to be associated with the new structured type.
field_list  the PBIO-style IOFieldList that describes the layout of the structure.
context  the context in which the type is to be made available.

sm_ref ecl_build_type_node const char *    name,
IOFieldList    field_list
 

This is used to create a semantic reference to a structured type directly from a PBIO-style IOFieldList.

This is used to generate the sm_ref that is then used with ecl_add_decl_to_parse_context() or ecl_build_param_node();

Parameters:
name  the name to be associated with the structured type
field_list  the internal fields of the structured type, given as a PBIO IOFieldList
Deprecated:
Use ecl_add_struct_type()

sm_ref ecl_build_param_node const char *    id,
sm_ref    typ,
int    param_num
 

This is used to declare a parameter to the routine to be generated.

Parameters:
id  the name to be associated with the parameter.
typ  the sm_ref representing the structured type of the parameter.
param_num  the index of this parameter (starting at zero).
Deprecated:
Use ecl_add_param().

void ecl_add_param const char *    id,
const char *    typ,
int    param_num,
ecl_parse_context    context
 

Declare a parameter to the generated function.

The parameter declaration consist of a textual id that will be used to reference the parameter, a character type that is parsed to determine the semantic type of the parameter and a parameter number (starting at zero) that determines the position of the parameter.

Parameters:
id  the name associated with the parameter.
typ  the string that is parsed to specify the type of the parameter.
param_num  the zero-based index of the parameter.
context  the context in which the parameter will be available.

void ecl_set_return_type char *    typ,
ecl_parse_context    context
 

This establishes the return type for the generated function.

Parameters:
typ  A character string representing the return type. This string is parsed and all acceptable E-Code types are valid.
context  The parse context affected.

ecl_code ecl_code_gen char *    code,
ecl_parse_context    context
 

generate code for a function body in a given context

Parameters:
code  the string representing the function body.
context  the context in which the function body is to be generated.

int ecl_code_verify char *    code,
ecl_parse_context    context
 

perform syntactical and semantic checking of a function body without actually generating code.

Parameters:
code  the string representing the function body.
context  the context in which the function body is to be checked.

void ecl_code_free ecl_code    code
 

Free all resources associated with the generated code associated with the ecl_code handle.

Parameters:
code  the handle to the resources that will be free'd.

int ecl_parse_for_context char *    code,
ecl_parse_context    context
 

This parses a string to determine what external functions and variables are visible during code generation.

The input string is of standard C syntax for external variable and function declarations. All previously registered types are available.

Parameters:
code  The input string containing declarations.
context  The parse context in which the declarations should be visible.

ecl_parse_context ecl_copy_context ecl_parse_context    context
 

Duplicate a handle to an ecl_parse_context.

Parameters:
context  the ecl_parse_context to be duplicated.

void ecl_set_error_func ecl_parse_context    context,
err_out_func_t    err_func
 

ecl_set_error_func establishes a new error output routine for ECL.

By default, errors are sent to stdout. If the error output is set then errors can be captured for other disposition.

Parameters:
context  the context in which errors are to be captured
err_func  the function to be called when errors occur

void ecl_dump ecl_code    code
 

This will dump (to stdout) a disassembled version of the machine code that has been generated

Parameters:
code  the ecl_code handle containing the code to be dumped.


Generated on Mon Feb 10 15:50:33 2003 for E-Code Dynamic Code Generation by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002