Go to the previous, next section.
var_syms. A
builder block can be created for a var_sym to use that
variable in the builder system.
See section Using Variables for more details.
var_sym * var = (variable in SUIF)
block v(var);
field() function by either
specifying the name of the field or the field id.
type_node * tn = block::parse_type("struct { int a; int b }");
block var(block::new_sym(tn, "var");
block body(block(var.field("a") = block(0)),
block(var.field("b") = block(0)));
The builder code will create a structure variable and
initialize the fields to zero.
Note: In the current builder implementation, accessing a structure field is limited to simple fields of structure variables. Composite operators such as accessing structures within structures or dereferencing a pointer to access a field in a structure are not implemented in the current version.
dref()
function. The address of a variable can be taken using the addr()
operator.
The only operator that is not overloaded in block is
the dereference operator * (see section Creating Expressions and Statements).
type_node * tn = (any type)
type_node * ptn = block::parse_type("* %%", tn);
block val(block::new_sym(tn, "val"));
block ptr(block::new_sym(ptn, "prt_val"));
block body(block(ptr = val.addr()),
block(ptr.dref() = block(0)));
The above code will create a variable of a given type and a pointer
variable to that type. It will also assign the pointer to the data and
initialize the data to zero using the pointer.
ARRAY() function.
The first argument to the function is the block representing the
array variable. The block structures representing the access
functions are given as subsequent arguments.
var_sym * vs_i = (index variable from SUIF)
type_node * tn = block::parse_type("int [100][100]");
block A(tn, "A");
block i(vs_i);
block body(A[i][block(0)] = A[block(i+block(1))][block(0)]);
Go to the previous, next section.