}
}
+slang_type_specifier *
+slang_type_specifier_new(slang_type_specifier_type type,
+ struct slang_struct_ *_struct,
+ struct slang_type_specifier_ *_array)
+{
+ slang_type_specifier *spec =
+ (slang_type_specifier *) _mesa_malloc(sizeof(slang_type_specifier));
+ if (spec) {
+ spec->type = type;
+ spec->_struct = _struct;
+ spec->_array = _array;
+ }
+ return spec;
+}
+
GLboolean
slang_type_specifier_copy(slang_type_specifier * x,
const slang_type_specifier * y)
/**
* As above, but allow float/int casting.
*/
-static GLboolean
+GLboolean
slang_type_specifier_compatible(const slang_type_specifier * x,
const slang_type_specifier * y)
{
GLboolean
slang_typeinfo_construct(slang_typeinfo * ti)
{
+ _mesa_bzero(ti, sizeof(*ti));
slang_type_specifier_ctr(&ti->spec);
ti->array_len = 0;
return GL_TRUE;
slang_function **funFound,
slang_atom_pool *atoms, slang_info_log *log)
{
+ GLboolean error;
+
*funFound = _slang_locate_function(space->funcs, a_name, params,
- num_params, space, atoms, log);
+ num_params, space, atoms, log, &error);
+ if (error)
+ return GL_FALSE;
+
if (!*funFound)
return GL_TRUE; /* yes, not false */
+
return slang_type_specifier_copy(spec, &(*funFound)->header.type.specifier);
}
switch (op->type) {
case SLANG_OPER_BLOCK_NO_NEW_SCOPE:
case SLANG_OPER_BLOCK_NEW_SCOPE:
- case SLANG_OPER_VARIABLE_DECL:
case SLANG_OPER_ASM:
case SLANG_OPER_BREAK:
case SLANG_OPER_CONTINUE:
}
break;
case SLANG_OPER_IDENTIFIER:
+ case SLANG_OPER_VARIABLE_DECL:
{
slang_variable *var;
var = _slang_locate_variable(op->locals, op->a_id, GL_TRUE);
}
break;
case SLANG_OPER_CALL:
- if (op->fun) {
+ if (op->array_constructor) {
+ /* build array typeinfo */
+ ti->spec.type = SLANG_SPEC_ARRAY;
+ ti->spec._array = (slang_type_specifier *)
+ _slang_alloc(sizeof(slang_type_specifier));
+ slang_type_specifier_ctr(ti->spec._array);
+
+ ti->spec._array->type =
+ slang_type_specifier_type_from_string((char *) op->a_id);
+ ti->array_len = op->num_children;
+ }
+ else if (op->fun) {
/* we've resolved this call before */
slang_type_specifier_copy(&ti->spec, &op->fun->header.type.specifier);
}
}
}
break;
+ case SLANG_OPER_METHOD:
+ /* at this time, GLSL 1.20 only has one method: array.length()
+ * which returns an integer.
+ */
+ ti->spec.type = SLANG_SPEC_INT;
+ break;
case SLANG_OPER_FIELD:
{
slang_typeinfo _ti;
}
-/**
- * Lookup a function according to name and parameter count/types.
- */
-slang_function *
-_slang_locate_function(const slang_function_scope * funcs, slang_atom a_name,
- slang_operation * args, GLuint num_args,
- const slang_name_space * space, slang_atom_pool * atoms,
- slang_info_log *log)
-{
- GLuint i;
-
- for (i = 0; i < funcs->num_functions; i++) {
- slang_function *f = &funcs->functions[i];
- const GLuint haveRetValue = _slang_function_has_return_value(f);
- GLuint j;
-
- if (a_name != f->header.a_name)
- continue;
- if (f->param_count - haveRetValue != num_args)
- continue;
-
- /* compare parameter / argument types */
- for (j = 0; j < num_args; j++) {
- slang_typeinfo ti;
-
- if (!slang_typeinfo_construct(&ti))
- return NULL;
- if (!_slang_typeof_operation_(&args[j], space, &ti, atoms, log)) {
- slang_typeinfo_destruct(&ti);
- return NULL;
- }
- if (!slang_type_specifier_compatible(&ti.spec,
- &f->parameters->variables[j]->type.specifier)) {
- slang_typeinfo_destruct(&ti);
- break;
- }
- slang_typeinfo_destruct(&ti);
-
- /* "out" and "inout" formal parameter requires the actual
- * parameter to be l-value.
- */
- if (!ti.can_be_referenced &&
- (f->parameters->variables[j]->type.qualifier == SLANG_QUAL_OUT ||
- f->parameters->variables[j]->type.qualifier == SLANG_QUAL_INOUT))
- break;
- }
- if (j == num_args)
- return f;
- }
- if (funcs->outer_scope != NULL)
- return _slang_locate_function(funcs->outer_scope, a_name, args,
- num_args, space, atoms, log);
- return NULL;
-}
-
-
/**
* Determine if a type is a matrix.
* \return GL_TRUE if is a matrix, GL_FALSE otherwise.
}
+/**
+ * Determine if a type is a float, float vector or float matrix.
+ * \return GL_TRUE if so, GL_FALSE otherwise
+ */
+GLboolean
+_slang_type_is_float_vec_mat(slang_type_specifier_type ty)
+{
+ switch (ty) {
+ case SLANG_SPEC_FLOAT:
+ case SLANG_SPEC_VEC2:
+ case SLANG_SPEC_VEC3:
+ case SLANG_SPEC_VEC4:
+ case SLANG_SPEC_MAT2:
+ case SLANG_SPEC_MAT3:
+ case SLANG_SPEC_MAT4:
+ case SLANG_SPEC_MAT23:
+ case SLANG_SPEC_MAT32:
+ case SLANG_SPEC_MAT24:
+ case SLANG_SPEC_MAT42:
+ case SLANG_SPEC_MAT34:
+ case SLANG_SPEC_MAT43:
+ return GL_TRUE;
+ default:
+ return GL_FALSE;
+ }
+}
+
+
/**
* Given a vector type, return the type of the vector's elements.
* For a matrix, return the type of the columns.