BAM
Abstract Machine for Bottom-Up Evaluation with the Push Method
Public Member Functions | List of all members
bam_c Class Reference

#include <bam.h>

Public Member Functions

 bam_c (str_t name)
 
bool error ()
 
void vars (int num_vars)
 
int string (str_t str)
 
int list_2 (list_2_t list)
 
int set_2 (set_2_t set)
 
int set_2b (set_tt_t set)
 
int mmap_1_1 (rel_n_n_t mmap)
 
int cur_2 (int list_id)
 
int cur_1_1 (int mmap_id)
 
int next_code_addr ()
 
void null ()
 
void halt ()
 
void call (int addr)
 
void call_forward ()
 
void call_patch (int inst_addr, int proc_addr)
 
void ret ()
 
void dupcheck_2 (int set_id, int var_id)
 
void dupcheck_2b (int set_id, int var1_id, int var2_id)
 
void save_var (int var_id)
 
void restore_var (int var_id)
 
void save_mmap_1_1_cur (int cur_id)
 
void restore_mmap_1_1_cur (int cur_id)
 
void loop_list_2 (int cur_id)
 
void loop_patch (int inst_addr, int loop_done_addr)
 
void loop_mmap_1_1 (int cur_id, int loop_done_addr, int var_id)
 
void get_list_2_col_1 (int cur_id, int var_id)
 
void get_list_2_col_2 (int cur_id, int var_id)
 
void get_mmap_1_1_out_1 (int cur_id, int var_id)
 
void end_loop_list_2 (int cur_id, int loop_body_addr)
 
void end_loop_mmap_1_1 (int cur_id, int loop_body_addr)
 
void insert_list_2 (int rel_id, int var1_id, int var2_id)
 
void insert_list_2_v (int rel_id, int var_id)
 
void insert_mmap_1_1 (int set_id, int var1_id, int var2_id)
 
void trace_call_2 (int str_id, int var1_id, int var2_id)
 
bool run (int start_addr)
 
void dump (str_t headline=STR_NULL) const
 

Detailed Description

Interpreter for bottom-up abstract machine.

This is an interpreter for the BAM (bottom-up abstract machine).

Constructor & Destructor Documentation

bam_c::bam_c ( str_t  name)
explicit

Constructor (with name parameter)

Parameters
nameName of this abstract machine

Member Function Documentation

void bam_c::call ( int  addr)
inline

Store a CALL instruction.

void bam_c::call_forward ( )
inline

Store a CALL instruction with still unknown address.

void bam_c::call_patch ( int  inst_addr,
int  proc_addr 
)
inline

Set the address in a CALL instruction.

int bam_c::cur_1_1 ( int  mmap_id)

Create a cursor over a multimap from one column to one column.

Returns
An ID is returned that can be used to refer to this cursor. -1 is returned in case of an error (e.g. insufficient memory).
int bam_c::cur_2 ( int  list_id)

Create a cursor over a list with two columns.

Returns
An ID is returned that can be used to refer to this cursor. -1 is returned in case of an error (e.g. insufficient memory).
void bam_c::dump ( str_t  headline = STR_NULL) const

Show data structure.

void bam_c::dupcheck_2 ( int  set_id,
int  var_id 
)
inline

Store a DUPCHECK_2 instruction.

Parameters
set_idID of the set data structure used for the duplicate check.
var_idVariable that contains first column value, next variable must contain second column value.
void bam_c::dupcheck_2b ( int  set_id,
int  var1_id,
int  var2_id 
)
inline

Store a DUPCHECK_2B instruction.

Parameters
set_idID of the set data structure used for the duplicate check.
var1_idVariable that contains the first column value.
var2_idVariable that contains the second column value.
void bam_c::end_loop_list_2 ( int  cur_id,
int  loop_body_addr 
)
inline

Store an END_LOOP_LIST_2 instruction.

This causes the specified list cursor to fetch the next tuple. If this fails, the cursor is closed, and control passes to the following instruction (no jump is done in this case). If, however, the fetch operation was successful, control jumps to to the specified address.

Parameters
cur_idID of the cursor to switch to the next tuple.
loop_body_addraddress of the first instruction in the loop body.
void bam_c::end_loop_mmap_1_1 ( int  cur_id,
int  loop_body_addr 
)
inline

Store an END_LOOP_MMAP_1_1 instruction.

This causes the specified list cursor to fetch the next tuple. If this fails, the cursor is closed, and control passes to the following instruction (no jump is done in this case). If, however, the fetch operation was successful, control jumps to to the specified address.

Parameters
cur_idID of the cursor to switch to the next tuple.
loop_body_addraddress of the first instruction in the loop body.
bool bam_c::error ( )
inline

Did an error occur (e.g. storage area was too small)?

void bam_c::get_list_2_col_1 ( int  cur_id,
int  var_id 
)
inline

Store a GET_LIST_2_COL_1 instruction.

void bam_c::get_list_2_col_2 ( int  cur_id,
int  var_id 
)
inline

Store a GET_LIST_2_COL_2 instruction.

void bam_c::get_mmap_1_1_out_1 ( int  cur_id,
int  var_id 
)
inline

Store a GET_MMAP_1_1_OUT_1 instruction.

void bam_c::halt ( )
inline

Store a HALT instruction.

void bam_c::insert_list_2 ( int  rel_id,
int  var1_id,
int  var2_id 
)
inline

Store an INSERT_LIST_2 instruction.

Parameters
set_idID of the list data structure into which the tuple should be inserted.
var1_idVariable that contains the first column value.
var2_idVariable that contains the second column value.
void bam_c::insert_list_2_v ( int  rel_id,
int  var_id 
)
inline

Store an INSERT_LIST_2 instruction (old vector version).

void bam_c::insert_mmap_1_1 ( int  set_id,
int  var1_id,
int  var2_id 
)
inline

Store a INSERT_MMAP_1_1 instruction.

Parameters
set_idID of the multi-map data structure into which the tuple should be inserted.
var1_idVariable that contains the first column value.
var2_idVariable that contains the second column value.
int bam_c::list_2 ( list_2_t  list)

Create a list storage structure for a relation with two columns.

Returns
An ID is returned that can be used to refer to this list. -1 is returned in case of an error (e.g. insufficient memory).
void bam_c::loop_list_2 ( int  cur_id)
inline

Store a LOOP_LIST_2 instruction (for looping over a list with 2 columns).

void bam_c::loop_mmap_1_1 ( int  cur_id,
int  loop_done_addr,
int  var_id 
)
inline

Store a LOOP_MMAP_1_1 instruction (for looping over the result of a 1-to-1-column multimap lookup).

Parameters
cur_idID of a multimap-1-1 cursor.
loop_done_addrAddress to jump to when the lookup result is empty (typically just after the loop). This can be BAM_NULL_ADDR when the address is not yet known.
var_idID of the variable that contains the input value for the multimap lookup.
void bam_c::loop_patch ( int  inst_addr,
int  loop_done_addr 
)
inline

Set the "not found" address in a LOOP instruction.

int bam_c::mmap_1_1 ( rel_n_n_t  mmap)

Create a multimap storage structure for a relation with two columns.

Returns
An ID is returned that can be used to refer to this mmap. -1 is returned in case of an error (e.g. insufficient memory).
int bam_c::next_code_addr ( )
inline

Return the address where the next instruction will be placed.

void bam_c::null ( )
inline

Store a NULL instruction.

void bam_c::restore_mmap_1_1_cur ( int  cur_id)
inline

Store a RESTORE_MMAP_1_1_CUR instruction.

void bam_c::restore_var ( int  var_id)
inline

Store a RESTORE_VAR instruction.

Parameters
var_idVariable that must be restored from the stack.
void bam_c::ret ( )
inline

Store a RETURN instruction.

bool bam_c::run ( int  start_addr)

Execute a BAM program.

void bam_c::save_mmap_1_1_cur ( int  cur_id)
inline

Store a SAVE_MMAP_1_1_CUR instruction.

void bam_c::save_var ( int  var_id)
inline

Store a SAVE_VAR instruction.

Parameters
var_idVariable that must be saved on the stack.
int bam_c::set_2 ( set_2_t  set)

Create a set storage structure for a relation with two columns.

Returns
An ID is returned that can be used to refer to this set. -1 is returned in case of an error (e.g. insufficient memory).
int bam_c::set_2b ( set_tt_t  set)

Create a set storage structure for a relation with two columns (bitmap version).

Returns
An ID is returned that can be used to refer to this set. -1 is returned in case of an error (e.g. insufficient memory).
int bam_c::string ( str_t  str)

Store a string in the abstract machine string pool.

The string is copied. Note that this method does not eliminate duplicates: If the method is called twice with the same string, it will be stored twice, and get two distinct IDs. -1 is returned if there was not sufficient memory. It is guaranteed that error() will return true in this case.

Returns
Integer that permits to lookup the string (string ID). -1 is returned in case of an error (e.g. insufficient memory).
void bam_c::trace_call_2 ( int  str_id,
int  var1_id,
int  var2_id 
)
inline

Store a INSERT_MMAP_1_1 instruction.

Parameters
set_idID of the multi-map data structure into which the tuple should be inserted.
var1_idVariable that contains the first column value.
var2_idVariable that contains the second column value.
void bam_c::vars ( int  num_vars)

Set number of variables to be used.


The documentation for this class was generated from the following files: