_slang_gen_operation(slang_assemble_ctx * A, slang_operation *oper);
+/**
+ * Retrieves type information about an operation.
+ * Returns GL_TRUE on success.
+ * Returns GL_FALSE otherwise.
+ */
+static GLboolean
+_slang_typeof_operation(const struct slang_assemble_ctx_ * A,
+ slang_operation * op,
+ slang_typeinfo * ti)
+{
+ return _slang_typeof_operation_(op, &A->space, ti, A->atoms, A->log);
+}
+
+
static GLboolean
is_sampler_type(const slang_fully_specified_type *t)
{
#include "slang_compile.h"
+typedef struct slang_assemble_ctx_
+{
+ slang_atom_pool *atoms;
+ slang_name_space space;
+ struct gl_program *program;
+ slang_var_table *vartable;
+ slang_info_log *log;
+ struct slang_label_ *curFuncEndLabel;
+ struct slang_ir_node_ *CurLoop;
+ struct slang_function_ *CurFunction;
+} slang_assemble_ctx;
+
+
extern GLuint
_slang_sizeof_type_specifier(const slang_type_specifier *spec);
#include "slang_mem.h"
-typedef struct
-{
- const char *name;
- slang_type_specifier_type type;
-} type_specifier_type_name;
-
-static const type_specifier_type_name type_specifier_type_names[] = {
- {"void", SLANG_SPEC_VOID},
- {"bool", SLANG_SPEC_BOOL},
- {"bvec2", SLANG_SPEC_BVEC2},
- {"bvec3", SLANG_SPEC_BVEC3},
- {"bvec4", SLANG_SPEC_BVEC4},
- {"int", SLANG_SPEC_INT},
- {"ivec2", SLANG_SPEC_IVEC2},
- {"ivec3", SLANG_SPEC_IVEC3},
- {"ivec4", SLANG_SPEC_IVEC4},
- {"float", SLANG_SPEC_FLOAT},
- {"vec2", SLANG_SPEC_VEC2},
- {"vec3", SLANG_SPEC_VEC3},
- {"vec4", SLANG_SPEC_VEC4},
- {"mat2", SLANG_SPEC_MAT2},
- {"mat3", SLANG_SPEC_MAT3},
- {"mat4", SLANG_SPEC_MAT4},
- {"mat2x3", SLANG_SPEC_MAT23},
- {"mat3x2", SLANG_SPEC_MAT32},
- {"mat2x4", SLANG_SPEC_MAT24},
- {"mat4x2", SLANG_SPEC_MAT42},
- {"mat3x4", SLANG_SPEC_MAT34},
- {"mat4x3", SLANG_SPEC_MAT43},
- {"sampler1D", SLANG_SPEC_SAMPLER1D},
- {"sampler2D", SLANG_SPEC_SAMPLER2D},
- {"sampler3D", SLANG_SPEC_SAMPLER3D},
- {"samplerCube", SLANG_SPEC_SAMPLERCUBE},
- {"sampler1DShadow", SLANG_SPEC_SAMPLER1DSHADOW},
- {"sampler2DShadow", SLANG_SPEC_SAMPLER2DSHADOW},
- {"sampler2DRect", SLANG_SPEC_SAMPLER2DRECT},
- {"sampler2DRectShadow", SLANG_SPEC_SAMPLER2DRECTSHADOW},
- {NULL, SLANG_SPEC_VOID}
-};
-
-slang_type_specifier_type
-slang_type_specifier_type_from_string(const char *name)
-{
- const type_specifier_type_name *p = type_specifier_type_names;
- while (p->name != NULL) {
- if (slang_string_compare(p->name, name) == 0)
- break;
- p++;
- }
- return p->type;
-}
-
-const char *
-slang_type_specifier_type_to_string(slang_type_specifier_type type)
-{
- const type_specifier_type_name *p = type_specifier_type_names;
- while (p->name != NULL) {
- if (p->type == type)
- break;
- p++;
- }
- return p->name;
-}
-
-/* slang_fully_specified_type */
-
-int
-slang_fully_specified_type_construct(slang_fully_specified_type * type)
-{
- type->qualifier = SLANG_QUAL_NONE;
- slang_type_specifier_ctr(&type->specifier);
- return 1;
-}
-
-void
-slang_fully_specified_type_destruct(slang_fully_specified_type * type)
-{
- slang_type_specifier_dtr(&type->specifier);
-}
-
-int
-slang_fully_specified_type_copy(slang_fully_specified_type * x,
- const slang_fully_specified_type * y)
-{
- slang_fully_specified_type z;
-
- if (!slang_fully_specified_type_construct(&z))
- return 0;
- z.qualifier = y->qualifier;
- z.precision = y->precision;
- z.variant = y->variant;
- z.centroid = y->centroid;
- if (!slang_type_specifier_copy(&z.specifier, &y->specifier)) {
- slang_fully_specified_type_destruct(&z);
- return 0;
- }
- slang_fully_specified_type_destruct(x);
- *x = z;
- return 1;
-}
-
-
static slang_variable *
slang_variable_new(void)
{
struct slang_ir_storage_;
-typedef enum slang_type_variant_
-{
- SLANG_VARIANT, /* the default */
- SLANG_INVARIANT /* indicates the "invariant" keyword */
-} slang_type_variant;
-
-
-typedef enum slang_type_centroid_
-{
- SLANG_CENTER, /* the default */
- SLANG_CENTROID /* indicates the "centroid" keyword */
-} slang_type_centroid;
-
-
-typedef enum slang_type_qualifier_
-{
- SLANG_QUAL_NONE,
- SLANG_QUAL_CONST,
- SLANG_QUAL_ATTRIBUTE,
- SLANG_QUAL_VARYING,
- SLANG_QUAL_UNIFORM,
- SLANG_QUAL_OUT,
- SLANG_QUAL_INOUT,
- SLANG_QUAL_FIXEDOUTPUT, /* internal */
- SLANG_QUAL_FIXEDINPUT /* internal */
-} slang_type_qualifier;
-
-extern slang_type_specifier_type
-slang_type_specifier_type_from_string(const char *);
-
-extern const char *
-slang_type_specifier_type_to_string(slang_type_specifier_type);
-
-
-
-typedef enum slang_type_precision_
-{
- SLANG_PREC_DEFAULT,
- SLANG_PREC_LOW,
- SLANG_PREC_MEDIUM,
- SLANG_PREC_HIGH
-} slang_type_precision;
-
-
-typedef struct slang_fully_specified_type_
-{
- slang_type_qualifier qualifier;
- slang_type_specifier specifier;
- slang_type_precision precision;
- slang_type_variant variant;
- slang_type_centroid centroid;
- GLint array_len; /**< -1 if not an array type */
-} slang_fully_specified_type;
-
-extern int
-slang_fully_specified_type_construct(slang_fully_specified_type *);
-
-extern void
-slang_fully_specified_type_destruct(slang_fully_specified_type *);
-
-extern int
-slang_fully_specified_type_copy(slang_fully_specified_type *,
- const slang_fully_specified_type *);
-
-
/**
* A shading language program variable.
*/
}
+typedef struct
+{
+ const char *name;
+ slang_type_specifier_type type;
+} type_specifier_type_name;
+
+static const type_specifier_type_name type_specifier_type_names[] = {
+ {"void", SLANG_SPEC_VOID},
+ {"bool", SLANG_SPEC_BOOL},
+ {"bvec2", SLANG_SPEC_BVEC2},
+ {"bvec3", SLANG_SPEC_BVEC3},
+ {"bvec4", SLANG_SPEC_BVEC4},
+ {"int", SLANG_SPEC_INT},
+ {"ivec2", SLANG_SPEC_IVEC2},
+ {"ivec3", SLANG_SPEC_IVEC3},
+ {"ivec4", SLANG_SPEC_IVEC4},
+ {"float", SLANG_SPEC_FLOAT},
+ {"vec2", SLANG_SPEC_VEC2},
+ {"vec3", SLANG_SPEC_VEC3},
+ {"vec4", SLANG_SPEC_VEC4},
+ {"mat2", SLANG_SPEC_MAT2},
+ {"mat3", SLANG_SPEC_MAT3},
+ {"mat4", SLANG_SPEC_MAT4},
+ {"mat2x3", SLANG_SPEC_MAT23},
+ {"mat3x2", SLANG_SPEC_MAT32},
+ {"mat2x4", SLANG_SPEC_MAT24},
+ {"mat4x2", SLANG_SPEC_MAT42},
+ {"mat3x4", SLANG_SPEC_MAT34},
+ {"mat4x3", SLANG_SPEC_MAT43},
+ {"sampler1D", SLANG_SPEC_SAMPLER1D},
+ {"sampler2D", SLANG_SPEC_SAMPLER2D},
+ {"sampler3D", SLANG_SPEC_SAMPLER3D},
+ {"samplerCube", SLANG_SPEC_SAMPLERCUBE},
+ {"sampler1DShadow", SLANG_SPEC_SAMPLER1DSHADOW},
+ {"sampler2DShadow", SLANG_SPEC_SAMPLER2DSHADOW},
+ {"sampler2DRect", SLANG_SPEC_SAMPLER2DRECT},
+ {"sampler2DRectShadow", SLANG_SPEC_SAMPLER2DRECTSHADOW},
+ {NULL, SLANG_SPEC_VOID}
+};
+
+slang_type_specifier_type
+slang_type_specifier_type_from_string(const char *name)
+{
+ const type_specifier_type_name *p = type_specifier_type_names;
+ while (p->name != NULL) {
+ if (slang_string_compare(p->name, name) == 0)
+ break;
+ p++;
+ }
+ return p->type;
+}
+
+const char *
+slang_type_specifier_type_to_string(slang_type_specifier_type type)
+{
+ const type_specifier_type_name *p = type_specifier_type_names;
+ while (p->name != NULL) {
+ if (p->type == type)
+ break;
+ p++;
+ }
+ return p->name;
+}
+
+/* slang_fully_specified_type */
+
+int
+slang_fully_specified_type_construct(slang_fully_specified_type * type)
+{
+ type->qualifier = SLANG_QUAL_NONE;
+ slang_type_specifier_ctr(&type->specifier);
+ return 1;
+}
+
+void
+slang_fully_specified_type_destruct(slang_fully_specified_type * type)
+{
+ slang_type_specifier_dtr(&type->specifier);
+}
+
+int
+slang_fully_specified_type_copy(slang_fully_specified_type * x,
+ const slang_fully_specified_type * y)
+{
+ slang_fully_specified_type z;
+
+ if (!slang_fully_specified_type_construct(&z))
+ return 0;
+ z.qualifier = y->qualifier;
+ z.precision = y->precision;
+ z.variant = y->variant;
+ z.centroid = y->centroid;
+ if (!slang_type_specifier_copy(&z.specifier, &y->specifier)) {
+ slang_fully_specified_type_destruct(&z);
+ return 0;
+ }
+ slang_fully_specified_type_destruct(x);
+ *x = z;
+ return 1;
+}
+
+
+
GLvoid
slang_type_specifier_ctr(slang_type_specifier * self)
{
}
}
-GLboolean
-_slang_typeof_operation(const slang_assemble_ctx * A,
- slang_operation * op,
- slang_typeinfo * ti)
-{
- return _slang_typeof_operation_(op, &A->space, ti, A->atoms, A->log);
-}
-
/**
* Determine the return type of an operation.
} slang_name_space;
-typedef struct slang_assemble_ctx_
-{
- slang_atom_pool *atoms;
- slang_name_space space;
- struct gl_program *program;
- slang_var_table *vartable;
- slang_info_log *log;
- struct slang_label_ *curFuncEndLabel;
- struct slang_ir_node_ *CurLoop;
- struct slang_function_ *CurFunction;
-} slang_assemble_ctx;
+struct slang_assemble_ctx_;
extern GLboolean
const slang_swizzle *);
+typedef enum slang_type_variant_
+{
+ SLANG_VARIANT, /* the default */
+ SLANG_INVARIANT /* indicates the "invariant" keyword */
+} slang_type_variant;
+
+
+typedef enum slang_type_centroid_
+{
+ SLANG_CENTER, /* the default */
+ SLANG_CENTROID /* indicates the "centroid" keyword */
+} slang_type_centroid;
+
+
+typedef enum slang_type_qualifier_
+{
+ SLANG_QUAL_NONE,
+ SLANG_QUAL_CONST,
+ SLANG_QUAL_ATTRIBUTE,
+ SLANG_QUAL_VARYING,
+ SLANG_QUAL_UNIFORM,
+ SLANG_QUAL_OUT,
+ SLANG_QUAL_INOUT,
+ SLANG_QUAL_FIXEDOUTPUT, /* internal */
+ SLANG_QUAL_FIXEDINPUT /* internal */
+} slang_type_qualifier;
+
+
+typedef enum slang_type_precision_
+{
+ SLANG_PREC_DEFAULT,
+ SLANG_PREC_LOW,
+ SLANG_PREC_MEDIUM,
+ SLANG_PREC_HIGH
+} slang_type_precision;
+
+
/**
* The basic shading language types (float, vec4, mat3, etc)
*/
} slang_type_specifier_type;
+extern slang_type_specifier_type
+slang_type_specifier_type_from_string(const char *);
+
+extern const char *
+slang_type_specifier_type_to_string(slang_type_specifier_type);
+
+
/**
* Describes more sophisticated types, like structs and arrays.
*/
const slang_type_specifier * y);
+typedef struct slang_fully_specified_type_
+{
+ slang_type_qualifier qualifier;
+ slang_type_specifier specifier;
+ slang_type_precision precision;
+ slang_type_variant variant;
+ slang_type_centroid centroid;
+ GLint array_len; /**< -1 if not an array type */
+} slang_fully_specified_type;
+
+extern int
+slang_fully_specified_type_construct(slang_fully_specified_type *);
+
+extern void
+slang_fully_specified_type_destruct(slang_fully_specified_type *);
+
+extern int
+slang_fully_specified_type_copy(slang_fully_specified_type *,
+ const slang_fully_specified_type *);
+
+
+
typedef struct slang_typeinfo_
{
GLboolean can_be_referenced;
slang_typeinfo_destruct(slang_typeinfo *);
-/**
- * Retrieves type information about an operation.
- * Returns GL_TRUE on success.
- * Returns GL_FALSE otherwise.
- */
-extern GLboolean
-_slang_typeof_operation(const slang_assemble_ctx *,
- struct slang_operation_ *,
- slang_typeinfo *);
-
extern GLboolean
_slang_typeof_operation_(struct slang_operation_ *,
const slang_name_space *,