BAM
Abstract Machine for Bottom-Up Evaluation with the Push Method
|
#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 |
Interpreter for bottom-up abstract machine.
This is an interpreter for the BAM (bottom-up abstract machine).
|
explicit |
Constructor (with name parameter)
name | Name of this abstract machine |
|
inline |
Store a CALL instruction.
|
inline |
Store a CALL instruction with still unknown address.
|
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.
int bam_c::cur_2 | ( | int | list_id | ) |
Create a cursor over a list with two columns.
|
inline |
Store a DUPCHECK_2 instruction.
set_id | ID of the set data structure used for the duplicate check. |
var_id | Variable that contains first column value, next variable must contain second column value. |
|
inline |
Store a DUPCHECK_2B instruction.
set_id | ID of the set data structure used for the duplicate check. |
var1_id | Variable that contains the first column value. |
var2_id | Variable that contains the second column value. |
|
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.
cur_id | ID of the cursor to switch to the next tuple. |
loop_body_addr | address of the first instruction in the loop body. |
|
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.
cur_id | ID of the cursor to switch to the next tuple. |
loop_body_addr | address of the first instruction in the loop body. |
|
inline |
Did an error occur (e.g. storage area was too small)?
|
inline |
Store a GET_LIST_2_COL_1 instruction.
|
inline |
Store a GET_LIST_2_COL_2 instruction.
|
inline |
Store a GET_MMAP_1_1_OUT_1 instruction.
|
inline |
Store a HALT instruction.
|
inline |
Store an INSERT_LIST_2 instruction.
set_id | ID of the list data structure into which the tuple should be inserted. |
var1_id | Variable that contains the first column value. |
var2_id | Variable that contains the second column value. |
|
inline |
Store an INSERT_LIST_2 instruction (old vector version).
|
inline |
Store a INSERT_MMAP_1_1 instruction.
set_id | ID of the multi-map data structure into which the tuple should be inserted. |
var1_id | Variable that contains the first column value. |
var2_id | Variable 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.
|
inline |
Store a LOOP_LIST_2 instruction (for looping over a list with 2 columns).
|
inline |
Store a LOOP_MMAP_1_1 instruction (for looping over the result of a 1-to-1-column multimap lookup).
cur_id | ID of a multimap-1-1 cursor. |
loop_done_addr | Address 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_id | ID of the variable that contains the input value for the multimap lookup. |
|
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.
|
inline |
Return the address where the next instruction will be placed.
|
inline |
Store a NULL instruction.
|
inline |
Store a RESTORE_MMAP_1_1_CUR instruction.
|
inline |
Store a RESTORE_VAR instruction.
var_id | Variable that must be restored from the stack. |
|
inline |
Store a RETURN instruction.
bool bam_c::run | ( | int | start_addr | ) |
Execute a BAM program.
|
inline |
Store a SAVE_MMAP_1_1_CUR instruction.
|
inline |
Store a SAVE_VAR instruction.
var_id | Variable 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.
int bam_c::set_2b | ( | set_tt_t | set | ) |
Create a set storage structure for a relation with two columns (bitmap version).
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.
|
inline |
Store a INSERT_MMAP_1_1 instruction.
set_id | ID of the multi-map data structure into which the tuple should be inserted. |
var1_id | Variable that contains the first column value. |
var2_id | Variable that contains the second column value. |
void bam_c::vars | ( | int | num_vars | ) |
Set number of variables to be used.