* - XXX: need to recognize "1" as a valid float ?
*/
-typedef unsigned char byte;
-typedef byte *production;
+typedef GLubyte *production;
/*-----------------------------------------------------------------------
* From here on down is the syntax checking portion
static GLvoid *mem_alloc (GLsizei);
static GLvoid mem_free (GLvoid **);
static GLvoid *mem_realloc (GLvoid *, GLsizei, GLsizei);
-static byte *str_duplicate (const byte *);
+static GLubyte *str_duplicate (const GLubyte *);
/*
internal error messages
*/
-static const byte *OUT_OF_MEMORY =
- (byte *) "internal error 1001: out of physical memory";
-static const byte *UNRESOLVED_REFERENCE =
- (byte *) "internal error 1002: unresolved reference '$'";
+static const GLubyte *OUT_OF_MEMORY =
+ (GLubyte *) "internal error 1001: out of physical memory";
+static const GLubyte *UNRESOLVED_REFERENCE =
+ (GLubyte *) "internal error 1002: unresolved reference '$'";
/*
-static const byte *INVALID_PARAMETER =
- (byte *) "internal error 1003: invalid parameter";
+static const GLubyte *INVALID_PARAMETER =
+ (GLubyte *) "internal error 1003: invalid parameter";
*/
-static const byte *error_message = NULL;
-static byte *error_param = NULL; /* this is inserted into error_message in place of $ */
+static const GLubyte *error_message = NULL;
+static GLubyte *error_param = NULL; /* this is inserted into error_message in place of $ */
static GLint error_position = -1;
-static byte *unknown = (byte *) "???";
+static GLubyte *unknown = (GLubyte *) "???";
static GLvoid
clear_last_error ()
}
static GLvoid
-set_last_error (const byte * msg, byte * param, GLint pos)
+set_last_error (const GLubyte * msg, GLubyte * param, GLint pos)
{
if (error_message != NULL)
return;
return ptr2;
}
-static byte *
-str_duplicate (const byte * str)
+static GLubyte *
+str_duplicate (const GLubyte * str)
{
- return (byte *) _mesa_strdup ((const char *) str);
+ return (GLubyte *) _mesa_strdup ((const char *) str);
}
/*
typedef struct emit_
{
emit_type m_emit_type;
- byte m_byte; /* et_byte */
+ GLubyte m_byte; /* et_byte */
struct emit_ *m_next;
}
emit;
*/
typedef struct error_
{
- byte *m_text;
- byte *m_token_name;
+ GLubyte *m_text;
+ GLubyte *m_token_name;
struct defntn_ *m_token;
}
error;
}
struct dict_;
-static byte *error_get_token (error *, struct dict_ *, const byte *, GLuint);
+static GLubyte *error_get_token (error *, struct dict_ *, const GLubyte *, GLuint);
/*
* specifier type typedef
typedef struct spec_
{
spec_type m_spec_type;
- byte m_byte[2]; /* st_byte, st_byte_range */
- byte *m_string; /* st_string */
+ GLubyte m_byte[2]; /* st_byte, st_byte_range */
+ GLubyte *m_string; /* st_string */
struct defntn_ *m_defntn; /* st_identifier, st_identifier_loop */
emit *m_emits;
error *m_errtext;
}
/*
- * byte array typedef
+ * GLubyte array typedef
*/
typedef struct barray_
{
- byte *data;
+ GLubyte *data;
GLuint len;
} barray;
}
/*
- * reallocates byte array to requested size,
+ * reallocates GLubyte array to requested size,
* returns 0 on success,
* returns 1 otherwise
*/
static GLint
barray_resize (barray ** ba, GLuint nlen)
{
- byte *new_pointer;
+ GLubyte *new_pointer;
if (nlen == 0) {
mem_free ((void **) &(**ba).data);
}
else {
new_pointer =
- mem_realloc ((**ba).data, (**ba).len * sizeof (byte),
- nlen * sizeof (byte));
+ mem_realloc ((**ba).data, (**ba).len * sizeof (GLubyte),
+ nlen * sizeof (GLubyte));
if (new_pointer) {
(**ba).data = new_pointer;
(**ba).len = nlen;
}
/*
- * adds byte array pointed by *nb to the end of array pointed by *ba,
+ * adds GLubyte array pointed by *nb to the end of array pointed by *ba,
* returns 0 on success,
* returns 1 otherwise
*/
* \return 0 on success, 1 otherwise.
*/
static GLint
-barray_push (barray ** ba, emit * em, byte c, GLuint pos)
+barray_push (barray ** ba, emit * em, GLubyte c, GLuint pos)
{
emit *temp = em;
GLuint count = 0;
/* This is where the position is emitted into the stream */
else { /* em->type == et_position */
#if 0
- (**ba).data[(**ba).len - count--] = (byte) pos,
- (**ba).data[(**ba).len - count--] = (byte) (pos >> 8),
- (**ba).data[(**ba).len - count--] = (byte) (pos >> 16),
- (**ba).data[(**ba).len - count--] = (byte) (pos >> 24);
+ (**ba).data[(**ba).len - count--] = (GLubyte) pos,
+ (**ba).data[(**ba).len - count--] = (GLubyte) (pos >> 8),
+ (**ba).data[(**ba).len - count--] = (GLubyte) (pos >> 16),
+ (**ba).data[(**ba).len - count--] = (GLubyte) (pos >> 24);
#else
- (**ba).data[(**ba).len - count--] = (byte) pos;
- (**ba).data[(**ba).len - count--] = (byte) (pos / 0x100);
- (**ba).data[(**ba).len - count--] = (byte) (pos / 0x10000);
- (**ba).data[(**ba).len - count--] = (byte) (pos / 0x1000000);
+ (**ba).data[(**ba).len - count--] = (GLubyte) pos;
+ (**ba).data[(**ba).len - count--] = (GLubyte) (pos / 0x100);
+ (**ba).data[(**ba).len - count--] = (GLubyte) (pos / 0x10000);
+ (**ba).data[(**ba).len - count--] = (GLubyte) (pos / 0x1000000);
#endif
}
*/
typedef struct map_str_
{
- byte *key;
- byte *data;
+ GLubyte *key;
+ GLubyte *data;
struct map_str_ *next;
} map_str;
* \return 0 if the key is matched, 1 otherwise
*/
static GLint
-map_str_find (map_str ** ma, const byte * key, byte ** data)
+map_str_find (map_str ** ma, const GLubyte * key, GLubyte ** data)
{
while (*ma) {
if (strcmp ((const char *) (**ma).key, (const char *) key) == 0) {
}
/**
- * string to byte map typedef
+ * string to GLubyte map typedef
*/
typedef struct map_byte_
{
- byte *key;
- byte data;
+ GLubyte *key;
+ GLubyte data;
struct map_byte_ *next;
} map_byte;
* \return 0 if the is matched, 1 otherwise
*/
static GLint
-map_byte_find (map_byte ** ma, const byte * key, byte * data)
+map_byte_find (map_byte ** ma, const GLubyte * key, GLubyte * data)
{
while (*ma) {
if (strcmp ((const char *) (**ma).key, (const char *) key) == 0) {
*/
typedef struct map_def_
{
- byte *key;
+ GLubyte *key;
defntn *data;
struct map_def_ *next;
} map_def;
* \return 0 if the is matched, 1 otherwise
*/
static GLint
-map_def_find (map_def ** ma, const byte * key, defntn ** data)
+map_def_find (map_def ** ma, const GLubyte * key, defntn ** data)
{
while (*ma) {
if (_mesa_strcmp ((const char *) (**ma).key, (const char *) key) == 0) {
* returns 0 otherwise
*/
static GLint
-is_space (byte c)
+is_space (GLubyte c)
{
return c == ' ' || c == '\t' || c == '\n' || c == '\r';
}
* returns 0 otherwise
*/
static GLint
-eat_space (const byte ** text)
+eat_space (const GLubyte ** text)
{
if (is_space (**text)) {
(*text)++;
* returns 0 otherwise
*/
static GLint
-is_comment_start (const byte * text)
+is_comment_start (const GLubyte * text)
{
return text[0] == '/' && text[1] == '*';
}
* returns 0 otherwise
*/
static GLint
-eat_comment (const byte ** text)
+eat_comment (const GLubyte ** text)
{
if (is_comment_start (*text)) {
/* *text points to comment block - skip two characters to enter comment body */
* advances text pointer to first character that is neither space nor C-style comment block
*/
static GLvoid
-eat_spaces (const byte ** text)
+eat_spaces (const GLubyte ** text)
{
while (eat_space (text) || eat_comment (text));
}
* returns 1 otherwise
*/
static GLint
-string_grow (byte ** ptr, GLuint * len, byte c)
+string_grow (GLubyte ** ptr, GLuint * len, GLubyte c)
{
/* reallocate the string in 16-length increments */
if ((*len & 0x0F) == 0x0F || *ptr == NULL) {
- byte *tmp = mem_realloc (*ptr, (*len) * sizeof (byte),
+ GLubyte *tmp = mem_realloc (*ptr, (*len) * sizeof (GLubyte),
((*len + 1 + 1 +
- 0x0F) & ~0x0F) * sizeof (byte));
+ 0x0F) & ~0x0F) * sizeof (GLubyte));
if (tmp == NULL)
return 1;
* returns 0 otherwise
*/
static GLint
-is_identifier (byte c)
+is_identifier (GLubyte c)
{
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') ||
(c >= '0' && c <= '9') || c == '_';
* returns 1 otherwise
*/
static GLint
-get_identifier (const byte ** text, byte ** id)
+get_identifier (const GLubyte ** text, GLubyte ** id)
{
- const byte *t = *text;
- byte *p = NULL;
+ const GLubyte *t = *text;
+ GLubyte *p = NULL;
GLuint len = 0;
if (string_grow (&p, &len, '\0'))
* returns 0 otherwise
*/
static GLint
-is_hex (byte c)
+is_hex (GLubyte c)
{
return (c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a'
&& c <= 'f');
* returns value of passed character as if it was HEX digit
*/
static GLuint
-hex2dec (byte c)
+hex2dec (GLubyte c)
{
if (c >= '0' && c <= '9')
return c - '0';
* returns the converted value
*/
static GLuint
-hex_convert (const byte ** text)
+hex_convert (const GLubyte ** text)
{
GLuint value = 0;
* returns 0 otherwise
*/
static GLint
-is_oct (byte c)
+is_oct (GLubyte c)
{
return c >= '0' && c <= '7';
}
* returns value of passed character as if it was OCT digit
*/
static GLint
-oct2dec (byte c)
+oct2dec (GLubyte c)
{
return c - '0';
}
-static byte
-get_escape_sequence (const byte ** text)
+static GLubyte
+get_escape_sequence (const GLubyte ** text)
{
GLint value = 0;
case 'v':
return '\v';
case 'x':
- return (byte) hex_convert (text);
+ return (GLubyte) hex_convert (text);
}
(*text)--;
}
}
- return (byte) value;
+ return (GLubyte) value;
}
/*
* returns 1 otherwise
*/
static GLint
-get_string (const byte ** text, byte ** str)
+get_string (const GLubyte ** text, GLubyte ** str)
{
- const byte *t = *text;
- byte *p = NULL;
+ const GLubyte *t = *text;
+ GLubyte *p = NULL;
GLuint len = 0;
- byte term_char;
+ GLubyte term_char;
if (string_grow (&p, &len, '\0'))
return 1;
term_char = *t++;
/* while next character is not the terminating character */
while (*t && *t != term_char) {
- byte c;
+ GLubyte c;
if (*t == '\\')
c = get_escape_sequence (&t);
* returns 1 otherwise
*/
static GLint
-get_emtcode (const byte ** text, map_byte ** ma)
+get_emtcode (const GLubyte ** text, map_byte ** ma)
{
- const byte *t = *text;
+ const GLubyte *t = *text;
map_byte *m = NULL;
map_byte_create (&m);
eat_spaces (&t);
if (*t == '\'') {
- byte *c;
+ GLubyte *c;
if (get_string (&t, &c)) {
map_byte_destroy (&m);
return 1;
}
- m->data = (byte) c[0];
+ m->data = (GLubyte) c[0];
mem_free ((GLvoid **) & c);
}
else {
/* skip HEX "0x" or "0X" prefix */
t += 2;
- m->data = (byte) hex_convert (&t);
+ m->data = (GLubyte) hex_convert (&t);
}
eat_spaces (&t);
* returns 1 otherwise
*/
static GLint
-get_errtext (const byte ** text, map_str ** ma)
+get_errtext (const GLubyte ** text, map_str ** ma)
{
- const byte *t = *text;
+ const GLubyte *t = *text;
map_str *m = NULL;
map_str_create (&m);
* returns 1 otherwise,
*/
static GLint
-get_error (const byte ** text, error ** er, map_str * maps)
+get_error (const GLubyte ** text, error ** er, map_str * maps)
{
- const byte *t = *text;
- byte *temp = NULL;
+ const GLubyte *t = *text;
+ GLubyte *temp = NULL;
if (*t != '.')
return 0;
char *processed = NULL;
GLuint len = 0, i = 0;
- if (string_grow ((byte **) (&processed), &len, '\0')) {
+ if (string_grow ((GLubyte **) (&processed), &len, '\0')) {
error_destroy (er);
return 1;
}
while (i < _mesa_strlen ((char *) ((**er).m_text))) {
/* check if the dollar sign is repeated - if so skip it */
if ((**er).m_text[i] == '$' && (**er).m_text[i + 1] == '$') {
- if (string_grow ((byte **) (&processed), &len, '$')) {
+ if (string_grow ((GLubyte **) (&processed), &len, '$')) {
mem_free ((GLvoid **) & processed);
error_destroy (er);
return 1;
i += 2;
}
else if ((**er).m_text[i] != '$') {
- if (string_grow ((byte **) (&processed), &len, (**er).m_text[i])) {
+ if (string_grow ((GLubyte **) (&processed), &len, (**er).m_text[i])) {
mem_free ((GLvoid **) & processed);
error_destroy (er);
return 1;
i++;
}
else {
- if (string_grow ((byte **) (&processed), &len, '$')) {
+ if (string_grow ((GLubyte **) (&processed), &len, '$')) {
mem_free ((GLvoid **) & processed);
error_destroy (er);
return 1;
}
mem_free ((GLvoid **) & (**er).m_text);
- (**er).m_text = (byte *) processed;
+ (**er).m_text = (GLubyte *) processed;
}
*text = t;
* returns 1 otherwise,
*/
static GLint
-get_emits (const byte ** text, emit ** em, map_byte * mapb)
+get_emits (const GLubyte ** text, emit ** em, map_byte * mapb)
{
- const byte *t = *text;
- byte *temp = NULL;
+ const GLubyte *t = *text;
+ GLubyte *temp = NULL;
emit *e = NULL;
if (*t != '.')
/* 0xNN */
if (*t == '0') {
t += 2;
- e->m_byte = (byte) hex_convert (&t);
+ e->m_byte = (GLubyte) hex_convert (&t);
e->m_emit_type = et_byte;
}
emit_destroy (&e);
return 1;
}
- e->m_byte = (byte) temp[0];
+ e->m_byte = (GLubyte) temp[0];
mem_free ((GLvoid **) & temp);
* returns 1 otherwise,
*/
static GLint
-get_spec (const byte ** text, spec ** sp, map_str * maps, map_byte * mapb)
+get_spec (const GLubyte ** text, spec ** sp, map_str * maps, map_byte * mapb)
{
- const byte *t = *text;
+ const GLubyte *t = *text;
spec *s = NULL;
spec_create (&s);
return 1;
if (*t == '\'') {
- byte *temp = NULL;
+ GLubyte *temp = NULL;
if (get_string (&t, &temp)) {
spec_destroy (&s);
eat_spaces (&t);
if (*t == '-') {
- byte *temp2 = NULL;
+ GLubyte *temp2 = NULL;
/* skip the '-' character */
t++;
s->m_spec_type = st_string;
}
else if (*t == '.') {
- byte *keyword = NULL;
+ GLubyte *keyword = NULL;
/* skip the dot */
t++;
* returns 1 otherwise,
*/
static GLint
-get_definition (const byte ** text, defntn ** de, map_str * maps,
+get_definition (const GLubyte ** text, defntn ** de, map_str * maps,
map_byte * mapb)
{
- const byte *t = *text;
+ const GLubyte *t = *text;
defntn *d = NULL;
defntn_create (&d);
}
while (*t != ';') {
- byte *op = NULL;
+ GLubyte *op = NULL;
spec *sp = NULL;
/* skip the dot that precedes "and" or "or" */
* returns 1 otherwise,
*/
static GLint
-update_dependency (map_def * mapd, byte * symbol, defntn ** def)
+update_dependency (map_def * mapd, GLubyte * symbol, defntn ** def)
{
if (map_def_find (&mapd, symbol, def))
return 1;
* returns 1 otherwise,
*/
static GLint
-update_dependencies (dict * di, map_def * mapd, byte ** syntax_symbol,
- byte ** string_symbol)
+update_dependencies (dict * di, map_def * mapd, GLubyte ** syntax_symbol,
+ GLubyte ** string_symbol)
{
defntn *de = di->m_defntns;
} match_result;
static match_result
-match (dict * di, const byte * text, GLuint * index, defntn * de,
+match (dict * di, const GLubyte * text, GLuint * index, defntn * de,
barray ** ba, GLint filtering_string)
{
GLuint ind = *index;
return mr_not_matched;
}
-static byte *
-error_get_token (error * er, dict * di, const byte * text, unsigned int ind)
+static GLubyte *
+error_get_token (error * er, dict * di, const GLubyte * text, unsigned int ind)
{
- byte *str = NULL;
+ GLubyte *str = NULL;
if (er->m_token) {
barray *ba;
- unsigned int filter_index = 0;
+ GLuint filter_index = 0;
barray_create (&ba);
if (ba != NULL) {
typedef struct grammar_load_state_
{
dict *di;
- byte *syntax_symbol;
- byte *string_symbol;
+ GLubyte *syntax_symbol;
+ GLubyte *string_symbol;
map_str *maps;
map_byte *mapb;
map_def *mapd;
*/
static dict *
-grammar_load_from_text (const byte * text)
+grammar_load_from_text (const GLubyte * text)
{
dict *d = NULL;
grammar_load_state *g = NULL;
eat_spaces (&text);
while (*text) {
- byte *symbol = NULL;
+ GLubyte *symbol = NULL;
GLint is_dot = *text == '.';
if (is_dot)
* \return 1 on sucess, 0 on parser error
*/
static GLint
-grammar_check (dict * di, const byte * text, byte ** production,
+grammar_check (dict * di, const GLubyte * text, GLubyte ** production,
GLuint *size)
{
barray *ba = NULL;
return 0;
}
- *production = mem_alloc (ba->len * sizeof (byte));
+ *production = mem_alloc (ba->len * sizeof (GLubyte));
if (*production == NULL) {
barray_destroy (&ba);
return 0;
}
- memcpy (*production, ba->data, ba->len * sizeof (byte));
+ memcpy (*production, ba->data, ba->len * sizeof (GLubyte));
*size = ba->len;
barray_destroy (&ba);
}
static GLvoid
-grammar_get_last_error (byte * text, int size, int *pos)
+grammar_get_last_error (GLubyte * text, GLint size, GLint *pos)
{
GLint len = 0, dots_made = 0;
- const byte *p = error_message;
+ const GLubyte *p = error_message;
*text = '\0';
#define APPEND_CHARACTER(x) if (dots_made == 0) {\
if (len < size - 1) {\
text[len++] = (x); text[len] = '\0';\
} else {\
- int i;\
+ GLint i;\
for (i = 0; i < 3; i++)\
if (--len >= 0)\
text[len] = '.';\
if (p) {
while (*p) {
if (*p == '$') {
- const byte *r = error_param;
+ const GLubyte *r = error_param;
while (*r) {
APPEND_CHARACTER (*r)
*/
struct var_cache
{
- byte *name;
+ GLubyte *name;
var_type type;
GLuint address_binding; /* The index of the address register we should
* be using */
}
static struct var_cache *
-var_cache_find (struct var_cache *va, byte * name)
+var_cache_find (struct var_cache *va, GLubyte * name)
{
struct var_cache *first = va;
}
/**
- * constructs an integer from 4 bytes in LE format
+ * constructs an integer from 4 GLubytes in LE format
*/
static GLuint
-parse_position (byte ** inst)
+parse_position (GLubyte ** inst)
{
GLuint value;
* \return The location on the var_cache corresponding the the string starting at I
*/
static struct var_cache *
-parse_string (byte ** inst, struct var_cache **vc_head,
+parse_string (GLubyte ** inst, struct var_cache **vc_head,
struct arb_program *Program, GLuint * found)
{
- byte *i = *inst;
+ GLubyte *i = *inst;
struct var_cache *va = NULL;
*inst += _mesa_strlen ((char *) i) + 1;
}
static char *
-parse_string_without_adding (byte ** inst, struct arb_program *Program)
+parse_string_without_adding (GLubyte ** inst, struct arb_program *Program)
{
- byte *i = *inst;
+ GLubyte *i = *inst;
*inst += _mesa_strlen ((char *) i) + 1;
* \return 0 if sign is plus, 1 if sign is minus
*/
static GLuint
-parse_sign (byte ** inst)
+parse_sign (GLubyte ** inst)
{
/*return *(*inst)++ != '+'; */
* parses and returns signed integer
*/
static GLint
-parse_integer (byte ** inst, struct arb_program *Program)
+parse_integer (GLubyte ** inst, struct arb_program *Program)
{
GLint sign;
GLint value;
/**
*/
static GLfloat
-parse_float (byte ** inst, struct arb_program *Program)
+parse_float (GLubyte ** inst, struct arb_program *Program)
{
GLint tmp[5], denom;
GLfloat value = 0;
/**
*/
static GLfloat
-parse_signed_float (byte ** inst, struct arb_program *Program)
+parse_signed_float (GLubyte ** inst, struct arb_program *Program)
{
GLint negate;
GLfloat value;
* \param values - The 4 component vector with the constant value in it
*/
static GLvoid
-parse_constant (byte ** inst, GLfloat *values, struct arb_program *Program,
+parse_constant (GLubyte ** inst, GLfloat *values, struct arb_program *Program,
GLboolean use)
{
GLuint components, i;
* \return 0 on sucess, 1 on error
*/
static GLuint
-parse_color_type (GLcontext * ctx, byte ** inst, struct arb_program *Program,
+parse_color_type (GLcontext * ctx, GLubyte ** inst, struct arb_program *Program,
GLint * color)
{
*color = *(*inst)++ != COLOR_PRIMARY;
* \return 0 on sucess, 1 on error
*/
static GLuint
-parse_texcoord_num (GLcontext * ctx, byte ** inst,
+parse_texcoord_num (GLcontext * ctx, GLubyte ** inst,
struct arb_program *Program, GLuint * coord)
{
*coord = parse_integer (inst, Program);
* \return 0 on sucess, 1 on error
*/
static GLuint
-parse_weight_num (GLcontext * ctx, byte ** inst, struct arb_program *Program,
+parse_weight_num (GLcontext * ctx, GLubyte ** inst, struct arb_program *Program,
GLint * coord)
{
*coord = parse_integer (inst, Program);
* \return 0 on sucess, 1 on error
*/
static GLuint
-parse_clipplane_num (GLcontext * ctx, byte ** inst,
+parse_clipplane_num (GLcontext * ctx, GLubyte ** inst,
struct arb_program *Program, GLint * coord)
{
*coord = parse_integer (inst, Program);
* \return 0 on front face, 1 on back face
*/
static GLuint
-parse_face_type (byte ** inst)
+parse_face_type (GLubyte ** inst)
{
switch (*(*inst)++) {
case FACE_FRONT:
* \return 0 on sucess, 1 on failure
*/
static GLuint
-parse_matrix (GLcontext * ctx, byte ** inst, struct arb_program *Program,
+parse_matrix (GLcontext * ctx, GLubyte ** inst, struct arb_program *Program,
GLint * matrix, GLint * matrix_idx, GLint * matrix_modifier)
{
- byte mat = *(*inst)++;
+ GLubyte mat = *(*inst)++;
*matrix_idx = 0;
* \return - 0 on sucess, 1 on error
*/
static GLuint
-parse_state_single_item (GLcontext * ctx, byte ** inst,
+parse_state_single_item (GLcontext * ctx, GLubyte ** inst,
struct arb_program *Program, GLint * state_tokens)
{
switch (*(*inst)++) {
* \return - 0 on sucess, 1 on failure
*/
static GLuint
-parse_program_single_item (GLcontext * ctx, byte ** inst,
+parse_program_single_item (GLcontext * ctx, GLubyte ** inst,
struct arb_program *Program, GLint * state_tokens)
{
if (Program->type == GL_FRAGMENT_PROGRAM_ARB)
* See nvfragparse.c for attrib register file layout
*/
static GLuint
-parse_attrib_binding (GLcontext * ctx, byte ** inst,
+parse_attrib_binding (GLcontext * ctx, GLubyte ** inst,
struct arb_program *Program, GLuint * binding,
GLuint * binding_idx)
{
* See nvvertparse.c for the register file layout for vertex programs
*/
static GLuint
-parse_result_binding (GLcontext * ctx, byte ** inst, GLuint * binding,
+parse_result_binding (GLcontext * ctx, GLubyte ** inst, GLuint * binding,
GLuint * binding_idx, struct arb_program *Program)
{
GLuint b;
* \return 0 on sucess, 1 on error
*/
static GLint
-parse_attrib (GLcontext * ctx, byte ** inst, struct var_cache **vc_head,
+parse_attrib (GLcontext * ctx, GLubyte ** inst, struct var_cache **vc_head,
struct arb_program *Program)
{
GLuint found;
* if we get a signed or unsigned float for scalar constants
*/
static GLuint
-parse_param_elements (GLcontext * ctx, byte ** inst,
+parse_param_elements (GLcontext * ctx, GLubyte ** inst,
struct var_cache *param_var,
struct arb_program *Program, GLboolean use)
{
* \return 0 on sucess, 1 on error
*/
static GLuint
-parse_param (GLcontext * ctx, byte ** inst, struct var_cache **vc_head,
+parse_param (GLcontext * ctx, GLubyte ** inst, struct var_cache **vc_head,
struct arb_program *Program)
{
GLuint found, specified_length, err;
*
*/
static GLuint
-parse_param_use (GLcontext * ctx, byte ** inst, struct var_cache **vc_head,
+parse_param_use (GLcontext * ctx, GLubyte ** inst, struct var_cache **vc_head,
struct arb_program *Program, struct var_cache **new_var)
{
struct var_cache *param_var;
/* First, insert a dummy entry into the var_cache */
var_cache_create (¶m_var);
- param_var->name = (byte *) _mesa_strdup (" ");
+ param_var->name = (GLubyte *) _mesa_strdup (" ");
param_var->type = vt_param;
param_var->param_binding_length = 0;
* \return 0 on sucess, 1 on error
*/
static GLuint
-parse_temp (GLcontext * ctx, byte ** inst, struct var_cache **vc_head,
+parse_temp (GLcontext * ctx, GLubyte ** inst, struct var_cache **vc_head,
struct arb_program *Program)
{
GLuint found;
* \return 0 on sucess, 1 on error
*/
static GLuint
-parse_output (GLcontext * ctx, byte ** inst, struct var_cache **vc_head,
+parse_output (GLcontext * ctx, GLubyte ** inst, struct var_cache **vc_head,
struct arb_program *Program)
{
GLuint found;
* \return 0 on sucess, 1 on error
*/
static GLuint
-parse_alias (GLcontext * ctx, byte ** inst, struct var_cache **vc_head,
+parse_alias (GLcontext * ctx, GLubyte ** inst, struct var_cache **vc_head,
struct arb_program *Program)
{
GLuint found;
* \return 0 on sucess, 1 on error
*/
static GLuint
-parse_address (GLcontext * ctx, byte ** inst, struct var_cache **vc_head,
+parse_address (GLcontext * ctx, GLubyte ** inst, struct var_cache **vc_head,
struct arb_program *Program)
{
GLuint found;
* \return 0 on sucess, 1 on error
*/
static GLint
-parse_declaration (GLcontext * ctx, byte ** inst, struct var_cache **vc_head,
+parse_declaration (GLcontext * ctx, GLubyte ** inst, struct var_cache **vc_head,
struct arb_program *Program)
{
GLint err = 0;
* \return 0 on sucess, 1 on error
*/
static GLuint
-parse_masked_dst_reg (GLcontext * ctx, byte ** inst,
+parse_masked_dst_reg (GLcontext * ctx, GLubyte ** inst,
struct var_cache **vc_head, struct arb_program *Program,
GLint * File, GLint * Index, GLboolean * WriteMask)
{
GLuint result;
- byte mask;
+ GLubyte mask;
struct var_cache *dst;
/* We either have a result register specified, or a
* \return 0 on sucess, 1 on error
*/
static GLuint
-parse_masked_address_reg (GLcontext * ctx, byte ** inst,
+parse_masked_address_reg (GLcontext * ctx, GLubyte ** inst,
struct var_cache **vc_head,
struct arb_program *Program, GLint * Index,
GLboolean * WriteMask)
* swizzle, or just 1 component for a scalar src register selection
*/
static GLuint
-parse_swizzle_mask (byte ** inst, GLubyte * mask, GLint len)
+parse_swizzle_mask (GLubyte ** inst, GLubyte * mask, GLint len)
{
GLint a;
/**
*/
static GLuint
-parse_extended_swizzle_mask (byte ** inst, GLubyte * mask, GLboolean * Negate)
+parse_extended_swizzle_mask (GLubyte ** inst, GLubyte * mask, GLboolean * Negate)
{
GLint a;
- byte swz;
+ GLubyte swz;
*Negate = GL_FALSE;
for (a = 0; a < 4; a++) {
static GLuint
-parse_src_reg (GLcontext * ctx, byte ** inst, struct var_cache **vc_head,
+parse_src_reg (GLcontext * ctx, GLubyte ** inst, struct var_cache **vc_head,
struct arb_program *Program, GLint * File, GLint * Index)
{
struct var_cache *src;
/**
*/
static GLuint
-parse_vector_src_reg (GLcontext * ctx, byte ** inst,
+parse_vector_src_reg (GLcontext * ctx, GLubyte ** inst,
struct var_cache **vc_head, struct arb_program *Program,
GLint * File, GLint * Index, GLboolean * Negate,
GLubyte * Swizzle)
/**
*/
static GLuint
-parse_scalar_src_reg (GLcontext * ctx, byte ** inst,
+parse_scalar_src_reg (GLcontext * ctx, GLubyte ** inst,
struct var_cache **vc_head, struct arb_program *Program,
GLint * File, GLint * Index, GLboolean * Negate,
GLubyte * Swizzle)
* and handling the src & dst registers for fragment program instructions
*/
static GLuint
-parse_fp_instruction (GLcontext * ctx, byte ** inst,
+parse_fp_instruction (GLcontext * ctx, GLubyte ** inst,
struct var_cache **vc_head, struct arb_program *Program,
struct fp_instruction *fp)
{
GLint a, b;
GLubyte swz[4]; /* FP's swizzle mask is a GLubyte, while VP's is GLuint */
GLuint texcoord;
- byte class, type, code;
+ GLubyte class, type, code;
/* No condition codes in ARB_fp */
fp->UpdateCondRegister = 0;
* and handling the src & dst registers for vertex program instructions
*/
static GLuint
-parse_vp_instruction (GLcontext * ctx, byte ** inst,
+parse_vp_instruction (GLcontext * ctx, GLubyte ** inst,
struct var_cache **vc_head, struct arb_program *Program,
struct vp_instruction *vp)
{
GLint a;
- byte type, code;
+ GLubyte type, code;
/* V_GEN_{ARL, VECTOR, SCALAR, BINSC, BIN, TRI, SWZ} */
type = *(*inst)++;
}
-
-
static GLvoid
debug_variables (GLcontext * ctx, struct var_cache *vc_head,
struct arb_program *Program)
#endif
+
/**
* The main loop for parsing a fragment or vertex program
*
* \return 0 on sucess, 1 on error
*/
-
static GLint
-parse_arb_program (GLcontext * ctx, byte * inst, struct var_cache **vc_head,
+parse_arb_program (GLcontext * ctx, GLubyte * inst, struct var_cache **vc_head,
struct arb_program *Program)
{
GLint err = 0;
return err;
}
+
/**
* This kicks everything off.
*
*/
GLuint
_mesa_parse_arb_program (GLcontext * ctx, const GLubyte * str, GLsizei len,
- struct arb_program * Program)
+ struct arb_program * program)
{
GLint a, err, error_pos;
char error_msg[300];
GLuint parsed_len;
struct var_cache *vc_head;
dict *dt;
- byte *parsed, *inst;
+ GLubyte *parsed, *inst;
#if DEBUG_PARSING
fprintf (stderr, "Loading grammar text!\n");
#endif
- dt = grammar_load_from_text ((byte *) arb_grammar_text);
+ dt = grammar_load_from_text ((GLubyte *) arb_grammar_text);
if (!dt) {
- grammar_get_last_error ((byte *) error_msg, 300, &error_pos);
+ grammar_get_last_error ((GLubyte *) error_msg, 300, &error_pos);
_mesa_set_program_error (ctx, error_pos, error_msg);
_mesa_error (ctx, GL_INVALID_OPERATION,
"Error loading grammer rule set");
/* Syntax parse error */
if (err == 0) {
- grammar_get_last_error ((byte *) error_msg, 300, &error_pos);
+ grammar_get_last_error ((GLubyte *) error_msg, 300, &error_pos);
_mesa_set_program_error (ctx, error_pos, error_msg);
_mesa_error (ctx, GL_INVALID_OPERATION, "Parse Error");
dict_destroy (&dt);
/* Initialize the arb_program struct */
- Program->Base.NumInstructions =
- Program->Base.NumTemporaries =
- Program->Base.NumParameters =
- Program->Base.NumAttributes = Program->Base.NumAddressRegs = 0;
- Program->Parameters = _mesa_new_parameter_list ();
- Program->InputsRead = 0;
- Program->OutputsWritten = 0;
- Program->Position = 0;
- Program->MajorVersion = Program->MinorVersion = 0;
- Program->HintPrecisionFastest =
- Program->HintPrecisionNicest =
- Program->HintFogExp2 =
- Program->HintFogExp =
- Program->HintFogLinear = Program->HintPositionInvariant = 0;
+ program->Base.NumInstructions =
+ program->Base.NumTemporaries =
+ program->Base.NumParameters =
+ program->Base.NumAttributes = program->Base.NumAddressRegs = 0;
+ program->Parameters = _mesa_new_parameter_list ();
+ program->InputsRead = 0;
+ program->OutputsWritten = 0;
+ program->Position = 0;
+ program->MajorVersion = program->MinorVersion = 0;
+ program->HintPrecisionFastest =
+ program->HintPrecisionNicest =
+ program->HintFogExp2 =
+ program->HintFogExp =
+ program->HintFogLinear = program->HintPositionInvariant = 0;
for (a = 0; a < MAX_TEXTURE_IMAGE_UNITS; a++)
- Program->TexturesUsed[a] = 0;
- Program->NumAluInstructions =
- Program->NumTexInstructions =
- Program->NumTexIndirections = 0;
+ program->TexturesUsed[a] = 0;
+ program->NumAluInstructions =
+ program->NumTexInstructions =
+ program->NumTexIndirections = 0;
- Program->FPInstructions = NULL;
- Program->VPInstructions = NULL;
+ program->FPInstructions = NULL;
+ program->VPInstructions = NULL;
vc_head = NULL;
err = 0;
else {
switch (*inst++) {
case FRAGMENT_PROGRAM:
- Program->type = GL_FRAGMENT_PROGRAM_ARB;
+ program->type = GL_FRAGMENT_PROGRAM_ARB;
break;
case VERTEX_PROGRAM:
- Program->type = GL_VERTEX_PROGRAM_ARB;
+ program->type = GL_VERTEX_PROGRAM_ARB;
break;
}
- err = parse_arb_program (ctx, inst, &vc_head, Program);
+ err = parse_arb_program (ctx, inst, &vc_head, program);
#if DEBUG_PARSING
fprintf (stderr, "Symantic analysis returns %d [1 is bad!]\n", err);
#endif
}
- /*debug_variables(ctx, vc_head, Program); */
+ /*debug_variables(ctx, vc_head, program); */
/* We're done with the parsed binary array */
var_cache_destroy (&vc_head);