/* compare parameter / argument types */
for (j = 0; j < num_args; j++) {
- slang_assembly_typeinfo ti;
+ slang_typeinfo ti;
- if (!slang_assembly_typeinfo_construct(&ti))
+ if (!slang_typeinfo_construct(&ti))
return NULL;
if (!_slang_typeof_operation_(&args[j], space, &ti, atoms)) {
- slang_assembly_typeinfo_destruct(&ti);
+ slang_typeinfo_destruct(&ti);
return NULL;
}
if (!slang_type_specifier_equal(&ti.spec,
&f->parameters->variables[j/* + haveRetValue*/]->type.specifier)) {
- slang_assembly_typeinfo_destruct(&ti);
+ slang_typeinfo_destruct(&ti);
break;
}
- slang_assembly_typeinfo_destruct(&ti);
+ slang_typeinfo_destruct(&ti);
/* "out" and "inout" formal parameter requires the actual parameter to be l-value */
if (!ti.can_be_referenced &&
slang_ir_node *altLab, *endLab;
slang_ir_node *tree, *tmpDecl, *tmpVar, *cond, *cjump, *jump;
slang_ir_node *bodx, *body, *assignx, *assigny;
- slang_assembly_typeinfo type;
+ slang_typeinfo type;
int size;
assert(oper->type == slang_oper_select);
assert(oper->num_children == 3);
/* size of x or y's type */
- slang_assembly_typeinfo_construct(&type);
+ slang_typeinfo_construct(&type);
_slang_typeof_operation(A, &oper->children[1], &type);
size = _slang_sizeof_type_specifier(&type.spec);
assert(size > 0);
static slang_ir_node *
_slang_gen_field(slang_assemble_ctx * A, slang_operation *oper)
{
- slang_assembly_typeinfo ti;
+ slang_typeinfo ti;
- slang_assembly_typeinfo_construct(&ti);
+ slang_typeinfo_construct(&ti);
_slang_typeof_operation(A, &oper->children[0], &ti);
if (_slang_type_is_vector(ti.spec.type)) {
static slang_ir_node *
_slang_gen_subscript(slang_assemble_ctx * A, slang_operation *oper)
{
- slang_assembly_typeinfo array_ti;
+ slang_typeinfo array_ti;
/* get array's type info */
- slang_assembly_typeinfo_construct(&array_ti);
+ slang_typeinfo_construct(&array_ti);
_slang_typeof_operation(A, &oper->children[0], &array_ti);
if (_slang_type_is_vector(array_ti.spec.type)) {
}
else {
/* conventional array */
- slang_assembly_typeinfo elem_ti;
+ slang_typeinfo elem_ti;
slang_ir_node *elem, *array, *index;
GLint elemSize;
/* size of array element */
- slang_assembly_typeinfo_construct(&elem_ti);
+ slang_typeinfo_construct(&elem_ti);
_slang_typeof_operation(A, oper, &elem_ti);
elemSize = _slang_sizeof_type_specifier(&elem_ti.spec);
assert(elemSize >= 1);
struct slang_function_ *fun; /**< If type == slang_oper_call */
struct slang_variable_ *var; /**< If type == slang_oper_identier */
slang_fully_specified_type *datatype; /**< Type of this operation */
- slang_assembly_typeinfo ti;
+ slang_typeinfo ti;
} slang_operation;
* into individual floats/ints and try to match the function params.
*/
for (i = 0; i < numParams; i++) {
- slang_assembly_typeinfo argType;
+ slang_typeinfo argType;
GLint argSz, j;
/* Get type of arg[i] */
- if (!slang_assembly_typeinfo_construct(&argType))
+ if (!slang_typeinfo_construct(&argType))
return GL_FALSE;
if (!_slang_typeof_operation_(&callOper->children[i], space,
&argType, atoms)) {
- slang_assembly_typeinfo_destruct(&argType);
+ slang_typeinfo_destruct(&argType);
return GL_FALSE;
}
* x = foo(int(3.15), bool(9))
*/
for (i = 0; i < numParams; i++) {
- slang_assembly_typeinfo argType;
+ slang_typeinfo argType;
slang_variable *paramVar = fun->parameters->variables[i];
/* Get type of arg[i] */
- if (!slang_assembly_typeinfo_construct(&argType))
+ if (!slang_typeinfo_construct(&argType))
return GL_FALSE;
if (!_slang_typeof_operation_(&callOper->children[i], space,
&argType, atoms)) {
- slang_assembly_typeinfo_destruct(&argType);
+ slang_typeinfo_destruct(&argType);
return GL_FALSE;
}
callOper->children[i].children = child;
}
- slang_assembly_typeinfo_destruct(&argType);
+ slang_typeinfo_destruct(&argType);
}
if (dbg) {
GLboolean
-slang_assembly_typeinfo_construct(slang_assembly_typeinfo * ti)
+slang_typeinfo_construct(slang_typeinfo * ti)
{
slang_type_specifier_ctr(&ti->spec);
ti->array_len = 0;
}
GLvoid
-slang_assembly_typeinfo_destruct(slang_assembly_typeinfo * ti)
+slang_typeinfo_destruct(slang_typeinfo * ti)
{
slang_type_specifier_dtr(&ti->spec);
}
GLboolean
_slang_typeof_operation(const slang_assemble_ctx * A,
const slang_operation * op,
- slang_assembly_typeinfo * ti)
+ slang_typeinfo * ti)
{
return _slang_typeof_operation_(op, &A->space, ti, A->atoms);
}
GLboolean
_slang_typeof_operation_(const slang_operation * op,
const slang_name_space * space,
- slang_assembly_typeinfo * ti,
+ slang_typeinfo * ti,
slang_atom_pool * atoms)
{
ti->can_be_referenced = GL_FALSE;
/*case slang_oper_complement: */
case slang_oper_subscript:
{
- slang_assembly_typeinfo _ti;
+ slang_typeinfo _ti;
- if (!slang_assembly_typeinfo_construct(&_ti))
+ if (!slang_typeinfo_construct(&_ti))
RETURN_NIL();
if (!_slang_typeof_operation_(op->children, space, &_ti, atoms)) {
- slang_assembly_typeinfo_destruct(&_ti);
+ slang_typeinfo_destruct(&_ti);
RETURN_NIL();
}
ti->can_be_referenced = _ti.can_be_referenced;
if (_ti.spec.type == slang_spec_array) {
if (!slang_type_specifier_copy(&ti->spec, _ti.spec._array)) {
- slang_assembly_typeinfo_destruct(&_ti);
+ slang_typeinfo_destruct(&_ti);
RETURN_NIL();
}
}
else {
if (!_slang_type_is_vector(_ti.spec.type)
&& !_slang_type_is_matrix(_ti.spec.type)) {
- slang_assembly_typeinfo_destruct(&_ti);
+ slang_typeinfo_destruct(&_ti);
RETURN_ERROR("cannot index a non-array type", 0);
}
ti->spec.type = _slang_type_base(_ti.spec.type);
}
- slang_assembly_typeinfo_destruct(&_ti);
+ slang_typeinfo_destruct(&_ti);
}
break;
case slang_oper_call:
break;
case slang_oper_field:
{
- slang_assembly_typeinfo _ti;
+ slang_typeinfo _ti;
- if (!slang_assembly_typeinfo_construct(&_ti))
+ if (!slang_typeinfo_construct(&_ti))
RETURN_NIL();
if (!_slang_typeof_operation_(op->children, space, &_ti, atoms)) {
- slang_assembly_typeinfo_destruct(&_ti);
+ slang_typeinfo_destruct(&_ti);
RETURN_NIL();
}
if (_ti.spec.type == slang_spec_struct) {
field = _slang_locate_variable(_ti.spec._struct->fields, op->a_id,
GL_FALSE);
if (field == NULL) {
- slang_assembly_typeinfo_destruct(&_ti);
+ slang_typeinfo_destruct(&_ti);
RETURN_NIL();
}
if (!slang_type_specifier_copy(&ti->spec, &field->type.specifier)) {
- slang_assembly_typeinfo_destruct(&_ti);
+ slang_typeinfo_destruct(&_ti);
RETURN_NIL();
}
ti->can_be_referenced = _ti.can_be_referenced;
/* determine the swizzle of the field expression */
#if 000
if (!_slang_type_is_vector(_ti.spec.type)) {
- slang_assembly_typeinfo_destruct(&_ti);
+ slang_typeinfo_destruct(&_ti);
RETURN_ERROR("Can't swizzle scalar expression", 0);
}
#endif
rows = _slang_type_dim(_ti.spec.type);
swizzle = slang_atom_pool_id(atoms, op->a_id);
if (!_slang_is_swizzle(swizzle, rows, &ti->swz)) {
- slang_assembly_typeinfo_destruct(&_ti);
+ slang_typeinfo_destruct(&_ti);
RETURN_ERROR("Bad swizzle", 0);
}
ti->is_swizzled = GL_TRUE;
break;
}
}
- slang_assembly_typeinfo_destruct(&_ti);
+ slang_typeinfo_destruct(&_ti);
}
break;
case slang_oper_postincrement:
const slang_type_specifier *);
-typedef struct slang_assembly_typeinfo_
+typedef struct slang_typeinfo_
{
GLboolean can_be_referenced;
GLboolean is_swizzled;
slang_swizzle swz;
slang_type_specifier spec;
GLuint array_len;
-} slang_assembly_typeinfo;
+} slang_typeinfo;
extern GLboolean
-slang_assembly_typeinfo_construct(slang_assembly_typeinfo *);
+slang_typeinfo_construct(slang_typeinfo *);
extern GLvoid
-slang_assembly_typeinfo_destruct(slang_assembly_typeinfo *);
+slang_typeinfo_destruct(slang_typeinfo *);
/**
extern GLboolean
_slang_typeof_operation(const slang_assemble_ctx *,
const struct slang_operation_ *,
- slang_assembly_typeinfo *);
+ slang_typeinfo *);
extern GLboolean
_slang_typeof_operation_(const struct slang_operation_ *,
const slang_name_space *,
- slang_assembly_typeinfo *, slang_atom_pool *);
+ slang_typeinfo *, slang_atom_pool *);
/**
* Retrieves type of a function prototype, if one exists.