/* evaluate compile-time expression which is array size */
_slang_simplify(&array_size, &space, C->atoms);
- result = (array_size.type == SLANG_OPER_LITERAL_INT);
- *len = (GLint) array_size.literal[0];
+ if (array_size.type == SLANG_OPER_LITERAL_INT) {
+ result = GL_TRUE;
+ *len = (GLint) array_size.literal[0];
+ } else if (array_size.type == SLANG_OPER_IDENTIFIER) {
+ slang_variable *var = _slang_locate_variable(array_size.locals, array_size.a_id, GL_TRUE);
+ if (!var) {
+ slang_info_log_error(C->L, "undefined variable '%s'",
+ (char *) array_size.a_id);
+ result = GL_FALSE;
+ } else if (var->type.qualifier == SLANG_QUAL_CONST &&
+ var->type.specifier.type == SLANG_SPEC_INT) {
+ if (var->initializer &&
+ var->initializer->type == SLANG_OPER_LITERAL_INT) {
+ *len = (GLint) var->initializer->literal[0];
+ result = GL_TRUE;
+ } else {
+ slang_info_log_error(C->L, "unable to parse array size declaration");
+ result = GL_FALSE;
+ }
+ } else {
+ slang_info_log_error(C->L, "unable to parse array size declaration");
+ result = GL_FALSE;
+ }
+ } else {
+ result = GL_FALSE;
+ }
slang_operation_destruct(&array_size);
return result;