Lines Matching defs:parseState
164 record_error(struct parse_state *parseState, const char *msg, int lineNo)
169 lineStr = _mesa_find_line_column(parseState->start,
170 parseState->pos, &line, &column);
171 _mesa_debug(parseState->ctx,
180 if (parseState->ctx->Program.ErrorString[0] == 0) {
181 _mesa_set_program_error(parseState->ctx,
182 parseState->pos - parseState->start,
190 record_error(parseState, "Unexpected end of input.", __LINE__); \
196 record_error(parseState, msg, __LINE__); \
204 record_error(parseState, err, __LINE__); \
293 GetToken(struct parse_state *parseState, GLubyte *token)
295 const GLubyte *str = parseState->pos;
308 parseState->curLine = str + i + 1;
313 parseState->curLine = str + i + 1;
356 Parse_Token(struct parse_state *parseState, GLubyte *token)
359 i = GetToken(parseState, token);
361 parseState->pos += (-i);
364 parseState->pos += i;
373 Peek_Token(struct parse_state *parseState, GLubyte *token)
376 i = GetToken(parseState, token);
378 parseState->pos += (-i);
382 parseState->pos += (i - len);
402 Parse_String(struct parse_state *parseState, const char *pattern)
408 while (IsWhitespace(*parseState->pos) || *parseState->pos == '#') {
409 if (*parseState->pos == '#') {
410 while (*parseState->pos && (*parseState->pos != '\n' && *parseState->pos != '\r')) {
411 parseState->pos += 1;
413 if (*parseState->pos == '\n' || *parseState->pos == '\r')
414 parseState->curLine = parseState->pos + 1;
418 if (*parseState->pos == '\n' || *parseState->pos == '\r')
419 parseState->curLine = parseState->pos + 1;
420 parseState->pos += 1;
425 m = parseState->pos;
431 parseState->pos = m;
438 Parse_Identifier(struct parse_state *parseState, GLubyte *ident)
440 if (!Parse_Token(parseState, ident))
455 Parse_ScalarConstant(struct parse_state *parseState, GLfloat *number)
459 *number = (GLfloat) _mesa_strtof((const char *) parseState->pos, &end);
461 if (end && end > (char *) parseState->pos) {
463 parseState->pos = (GLubyte *) end;
473 if (!Parse_Identifier(parseState, ident))
475 constant = (GLfloat *)_mesa_lookup_parameter_value(parseState->parameters,
499 Parse_VectorConstant(struct parse_state *parseState, GLfloat *vec)
505 if (!Parse_ScalarConstant(parseState, vec+0)) /* X */
508 if (Parse_String(parseState, "}")) {
512 if (!Parse_String(parseState, ","))
515 if (!Parse_ScalarConstant(parseState, vec+1)) /* Y */
518 if (Parse_String(parseState, "}")) {
522 if (!Parse_String(parseState, ","))
525 if (!Parse_ScalarConstant(parseState, vec+2)) /* Z */
528 if (Parse_String(parseState, "}")) {
532 if (!Parse_String(parseState, ","))
535 if (!Parse_ScalarConstant(parseState, vec+3)) /* W */
538 if (!Parse_String(parseState, "}"))
550 Parse_VectorOrScalarConstant(struct parse_state *parseState, GLfloat *vec)
552 if (Parse_String(parseState, "{")) {
553 return Parse_VectorConstant(parseState, vec);
556 GLboolean b = Parse_ScalarConstant(parseState, vec);
570 Parse_TextureImageId(struct parse_state *parseState,
576 if (!Parse_Token(parseState, imageSrc))
591 if (!Parse_String(parseState, ","))
594 if (Parse_String(parseState, "1D")) {
597 else if (Parse_String(parseState, "2D")) {
600 else if (Parse_String(parseState, "3D")) {
603 else if (Parse_String(parseState, "CUBE")) {
606 else if (Parse_String(parseState, "RECT")) {
614 parseState->texturesUsed[*texUnit] |= (1 << *texTarget);
615 if (_mesa_bitcount(parseState->texturesUsed[*texUnit]) > 1) {
666 Parse_CondCodeMask(struct parse_state *parseState,
669 if (Parse_String(parseState, "EQ"))
671 else if (Parse_String(parseState, "GE"))
673 else if (Parse_String(parseState, "GT"))
675 else if (Parse_String(parseState, "LE"))
677 else if (Parse_String(parseState, "LT"))
679 else if (Parse_String(parseState, "NE"))
681 else if (Parse_String(parseState, "TR"))
683 else if (Parse_String(parseState, "FL"))
689 if (Parse_String(parseState, ".")) {
693 if (!Parse_Token(parseState, token)) /* get xyzw suffix */
710 Parse_TempReg(struct parse_state *parseState, GLint *tempRegNum)
715 if (!Parse_Token(parseState, token))
740 Parse_DummyReg(struct parse_state *parseState, GLint *regNum)
742 if (Parse_String(parseState, "RC")) {
745 else if (Parse_String(parseState, "HC")) {
760 Parse_ProgramParamReg(struct parse_state *parseState, GLint *regNum)
764 if (!Parse_String(parseState, "p["))
767 if (!Parse_Token(parseState, token))
781 if (!Parse_String(parseState, "]"))
792 Parse_FragReg(struct parse_state *parseState, GLint *tempRegNum)
798 if (!Parse_String(parseState, "f["))
802 if (!Parse_Token(parseState, token)) {
808 parseState->inputsRead |= (1 << j);
818 if (!Parse_String(parseState, "]"))
826 Parse_OutputReg(struct parse_state *parseState, GLint *outputRegNum)
831 if (!Parse_String(parseState, "o["))
835 if (!Parse_Token(parseState, token))
843 parseState->outputsWritten |= (1 << FRAG_RESULT_COLOR);
847 parseState->outputsWritten |= (1 << FRAG_RESULT_DEPTH);
854 if (!Parse_String(parseState, "]"))
862 Parse_MaskedDstReg(struct parse_state *parseState,
869 if (!Peek_Token(parseState, token))
876 if (!Parse_DummyReg(parseState, &idx))
883 if (!Parse_TempReg(parseState, &idx))
890 if (!Parse_OutputReg(parseState, &idx))
899 if (Parse_String(parseState, ".")) {
903 if (!Parse_Token(parseState, token)) /* get xyzw writemask */
934 if (Parse_String(parseState, "(")) {
937 if (!Parse_CondCodeMask(parseState, dstReg))
940 if (!Parse_String(parseState, ")")) /* consume ")" */
961 Parse_VectorSrc(struct parse_state *parseState,
972 if (Parse_String(parseState, "-"))
974 else if (Parse_String(parseState, "+"))
977 if (Parse_String(parseState, "|")) {
981 if (Parse_String(parseState, "-"))
983 else if (Parse_String(parseState, "+"))
997 if (!Peek_Token(parseState, token))
1005 if (!Parse_TempReg(parseState, &idx))
1012 if (!Parse_FragReg(parseState, &idx))
1019 if (!Parse_ProgramParamReg(parseState, &idx))
1026 if (!Parse_Identifier(parseState, ident))
1028 paramIndex = _mesa_lookup_parameter_index(parseState->parameters,
1040 if (!Parse_ScalarConstant(parseState, values))
1042 paramIndex = _mesa_add_unnamed_constant(parseState->parameters,
1052 (void) Parse_String(parseState, "{");
1053 if (!Parse_VectorConstant(parseState, values))
1055 paramIndex = _mesa_add_unnamed_constant(parseState->parameters,
1069 if (Parse_String(parseState, ".")) {
1072 if (!Parse_Token(parseState, token))
1082 if (srcReg->Abs && !Parse_String(parseState, "|")) {
1091 Parse_ScalarSrcReg(struct parse_state *parseState,
1103 if (Parse_String(parseState, "-"))
1105 else if (Parse_String(parseState, "+"))
1108 if (Parse_String(parseState, "|")) {
1112 if (Parse_String(parseState, "-"))
1114 else if (Parse_String(parseState, "+"))
1127 if (!Peek_Token(parseState, token))
1133 if (!Parse_TempReg(parseState, &idx))
1139 if (!Parse_FragReg(parseState, &idx))
1147 (void) Parse_String(parseState, "{");
1148 if (!Parse_VectorConstant(parseState, values))
1150 paramIndex = _mesa_add_unnamed_constant(parseState->parameters,
1160 if (!Parse_Identifier(parseState, ident))
1162 parseState->parameters,
1174 if (!Parse_ScalarConstant(parseState, values))
1176 paramIndex = _mesa_add_unnamed_constant(parseState->parameters,
1190 if (!Parse_String(parseState, "."))
1193 if (!Parse_Token(parseState, token))
1214 if (srcReg->Abs && !Parse_String(parseState, "|")) {
1223 Parse_PrintInstruction(struct parse_state *parseState,
1232 if (!Parse_String(parseState, "'"))
1235 str = parseState->pos;
1238 parseState->pos += len + 1;
1245 if (Parse_String(parseState, ",")) {
1248 GetToken(parseState, token);
1251 if (!Parse_OutputReg(parseState, &idx))
1258 if (!Parse_VectorSrc(parseState, &inst->SrcReg[0]))
1275 Parse_InstructionSequence(struct parse_state *parseState,
1279 struct prog_instruction *inst = program + parseState->numInst;
1287 if (Parse_String(parseState, "DEFINE")) {
1290 if (!Parse_Identifier(parseState, id))
1293 if (!Parse_String(parseState, "="))
1295 if (!Parse_VectorOrScalarConstant(parseState, value))
1297 if (!Parse_String(parseState, ";"))
1299 if (_mesa_lookup_parameter_index(parseState->parameters,
1303 _mesa_add_named_parameter(parseState->parameters,
1307 else if (Parse_String(parseState, "DECLARE")) {
1310 if (!Parse_Identifier(parseState, id))
1313 if (Parse_String(parseState, "=")) {
1314 if (!Parse_VectorOrScalarConstant(parseState, value))
1317 if (!Parse_String(parseState, ";"))
1319 if (_mesa_lookup_parameter_index(parseState->parameters,
1323 _mesa_add_named_parameter(parseState->parameters,
1327 else if (Parse_String(parseState, "END")) {
1329 parseState->numInst++;
1330 if (Parse_Token(parseState, token)) {
1339 if (!Parse_Token(parseState, token)) {
1360 if (!Parse_MaskedDstReg(parseState, &inst->DstReg))
1362 if (!Parse_String(parseState, ","))
1370 if (!Parse_CondCodeMask(parseState, &inst->DstReg))
1379 if (!Parse_VectorSrc(parseState, &inst->SrcReg[0]))
1383 if (!Parse_VectorSrc(parseState, &inst->SrcReg[0]))
1385 if (!Parse_String(parseState, ","))
1387 if (!Parse_VectorSrc(parseState, &inst->SrcReg[1]))
1391 if (!Parse_VectorSrc(parseState, &inst->SrcReg[0]))
1393 if (!Parse_String(parseState, ","))
1395 if (!Parse_VectorSrc(parseState, &inst->SrcReg[1]))
1397 if (!Parse_String(parseState, ","))
1399 if (!Parse_VectorSrc(parseState, &inst->SrcReg[2]))
1403 if (!Parse_ScalarSrcReg(parseState, &inst->SrcReg[0]))
1407 if (!Parse_ScalarSrcReg(parseState, &inst->SrcReg[0]))
1409 if (!Parse_String(parseState, ","))
1411 if (!Parse_ScalarSrcReg(parseState, &inst->SrcReg[1]))
1419 if (!Parse_VectorSrc(parseState, &inst->SrcReg[0]))
1421 if (!Parse_String(parseState, ","))
1423 if (!Parse_TextureImageId(parseState, &unit, &idx))
1430 if (!Parse_VectorSrc(parseState, &inst->SrcReg[0]))
1432 if (!Parse_String(parseState, ","))
1434 if (!Parse_VectorSrc(parseState, &inst->SrcReg[1]))
1436 if (!Parse_String(parseState, ","))
1438 if (!Parse_VectorSrc(parseState, &inst->SrcReg[2]))
1440 if (!Parse_String(parseState, ","))
1442 if (!Parse_TextureImageId(parseState, &unit, &idx))
1448 if (!Parse_PrintInstruction(parseState, inst))
1453 if (!Parse_String(parseState, ";"))
1456 parseState->numInst++;
1458 if (parseState->numInst >= MAX_NV_FRAGMENT_PROGRAM_INSTRUCTIONS)
1477 struct parse_state parseState;
1493 memset(&parseState, 0, sizeof(struct parse_state));
1494 parseState.ctx = ctx;
1495 parseState.start = programString;
1496 parseState.program = program;
1497 parseState.numInst = 0;
1498 parseState.curLine = programString;
1499 parseState.parameters = _mesa_new_parameter_list();
1507 parseState.pos = programString + 7;
1530 if (Parse_InstructionSequence(&parseState, instBuffer)) {
1534 if (parseState.outputsWritten == 0) {
1542 assert(parseState.numInst <= MAX_NV_FRAGMENT_PROGRAM_INSTRUCTIONS);
1543 newInst = _mesa_alloc_instructions(parseState.numInst);
1548 _mesa_copy_instructions(newInst, instBuffer, parseState.numInst);
1561 program->Base.NumInstructions = parseState.numInst;
1562 program->Base.InputsRead = parseState.inputsRead;
1563 program->Base.OutputsWritten = parseState.outputsWritten;
1565 program->Base.TexturesUsed[u] = parseState.texturesUsed[u];
1568 program->Base.Parameters = parseState.parameters;