Lines Matching defs:parseState
76 record_error(struct parse_state *parseState, const char *msg, int lineNo)
81 lineStr = _mesa_find_line_column(parseState->start,
82 parseState->pos, &line, &column);
83 _mesa_debug(parseState->ctx,
92 if (parseState->ctx->Program.ErrorString[0] == 0) {
93 _mesa_set_program_error(parseState->ctx,
94 parseState->pos - parseState->start,
102 record_error(parseState, "Unexpected end of input.", __LINE__); \
108 record_error(parseState, msg, __LINE__); \
116 record_error(parseState, err, __LINE__); \
148 GetToken(struct parse_state *parseState, GLubyte *token)
150 const GLubyte *str = parseState->pos;
163 parseState->curLine = str + i + 1;
168 parseState->curLine = str + i + 1;
211 Parse_Token(struct parse_state *parseState, GLubyte *token)
214 i = GetToken(parseState, token);
216 parseState->pos += (-i);
219 parseState->pos += i;
228 Peek_Token(struct parse_state *parseState, GLubyte *token)
231 i = GetToken(parseState, token);
233 parseState->pos += (-i);
237 parseState->pos += (i - len);
248 Parse_String(struct parse_state *parseState, const char *pattern)
254 while (IsWhitespace(*parseState->pos) || *parseState->pos == '#') {
255 if (*parseState->pos == '#') {
256 while (*parseState->pos && (*parseState->pos != '\n' && *parseState->pos != '\r')) {
257 parseState->pos += 1;
259 if (*parseState->pos == '\n' || *parseState->pos == '\r')
260 parseState->curLine = parseState->pos + 1;
264 if (*parseState->pos == '\n' || *parseState->pos == '\r')
265 parseState->curLine = parseState->pos + 1;
266 parseState->pos += 1;
271 m = parseState->pos;
277 parseState->pos = m;
302 Parse_TempReg(struct parse_state *parseState, GLint *tempRegNum)
307 if (!Parse_Token(parseState, token))
330 Parse_AddrReg(struct parse_state *parseState)
333 if (!Parse_String(parseState, "A0"))
337 if (!Parse_String(parseState, "."))
341 if (!Parse_String(parseState, "x"))
352 Parse_AbsParamReg(struct parse_state *parseState, GLint *regNum)
356 if (!Parse_String(parseState, "c"))
359 if (!Parse_String(parseState, "["))
362 if (!Parse_Token(parseState, token))
376 if (!Parse_String(parseState, "]"))
384 Parse_ParamReg(struct parse_state *parseState, struct prog_src_register *srcReg)
388 if (!Parse_String(parseState, "c"))
391 if (!Parse_String(parseState, "["))
394 if (!Peek_Token(parseState, token))
400 (void) Parse_Token(parseState, token);
409 if (!Parse_AddrReg(parseState))
414 parseState->indirectRegisterFiles |= (1 << srcReg->File);
416 if (!Peek_Token(parseState, token))
421 (void) Parse_Token(parseState, token); /* consume +/- */
424 if (!Parse_Token(parseState, token))
453 if (!Parse_String(parseState, "]"))
464 Parse_AttribReg(struct parse_state *parseState, GLint *tempRegNum)
470 if (!Parse_String(parseState, "v"))
474 if (!Parse_String(parseState, "["))
478 if (!Parse_Token(parseState, token))
481 if (parseState->isStateProgram && token[0] != '0')
504 if (!Parse_String(parseState, "]"))
512 Parse_OutputReg(struct parse_state *parseState, GLint *outputRegNum)
518 if (!Parse_String(parseState, "o"))
522 if (!Parse_String(parseState, "["))
526 if (!Parse_Token(parseState, token))
529 if (parseState->isPositionInvariant)
545 if (!Parse_String(parseState, "]"))
553 Parse_MaskedDstReg(struct parse_state *parseState, struct prog_dst_register *dstReg)
559 if (!Peek_Token(parseState, token))
565 if (!Parse_TempReg(parseState, &idx))
569 else if (!parseState->isStateProgram && token[0] == 'o') {
572 if (!Parse_OutputReg(parseState, &idx))
576 else if (parseState->isStateProgram && token[0] == 'c' &&
577 parseState->isStateProgram) {
581 if (!Parse_AbsParamReg(parseState, &idx))
590 if (!Peek_Token(parseState, token))
597 if (!Parse_String(parseState, "."))
600 if (!Parse_Token(parseState, token))
634 Parse_SwizzleSrcReg(struct parse_state *parseState, struct prog_src_register *srcReg)
642 if (!Peek_Token(parseState, token))
645 (void) Parse_String(parseState, "-");
647 if (!Peek_Token(parseState, token))
657 if (!Parse_TempReg(parseState, &idx))
662 if (!Parse_ParamReg(parseState, srcReg))
667 if (!Parse_AttribReg(parseState, &idx))
679 if (!Peek_Token(parseState, token))
682 (void) Parse_String(parseState, "."); /* consume . */
684 if (!Parse_Token(parseState, token))
728 Parse_ScalarSrcReg(struct parse_state *parseState, struct prog_src_register *srcReg)
736 if (!Peek_Token(parseState, token))
740 (void) Parse_String(parseState, "-"); /* consume '-' */
741 if (!Peek_Token(parseState, token))
751 if (!Parse_TempReg(parseState, &idx))
756 if (!Parse_ParamReg(parseState, srcReg))
761 if (!Parse_AttribReg(parseState, &idx))
770 if (!Parse_String(parseState, "."))
773 if (!Parse_Token(parseState, token))
797 Parse_UnaryOpInstruction(struct parse_state *parseState,
801 if (opcode == OPCODE_ABS && !parseState->isVersion1_1)
807 if (!Parse_MaskedDstReg(parseState, &inst->DstReg))
811 if (!Parse_String(parseState, ","))
815 if (!Parse_SwizzleSrcReg(parseState, &inst->SrcReg[0]))
819 if (!Parse_String(parseState, ";"))
827 Parse_BiOpInstruction(struct parse_state *parseState,
831 if (opcode == OPCODE_DPH && !parseState->isVersion1_1)
833 if (opcode == OPCODE_SUB && !parseState->isVersion1_1)
839 if (!Parse_MaskedDstReg(parseState, &inst->DstReg))
843 if (!Parse_String(parseState, ","))
847 if (!Parse_SwizzleSrcReg(parseState, &inst->SrcReg[0]))
851 if (!Parse_String(parseState, ","))
855 if (!Parse_SwizzleSrcReg(parseState, &inst->SrcReg[1]))
859 if (!Parse_String(parseState, ";"))
879 Parse_TriOpInstruction(struct parse_state *parseState,
886 if (!Parse_MaskedDstReg(parseState, &inst->DstReg))
890 if (!Parse_String(parseState, ","))
894 if (!Parse_SwizzleSrcReg(parseState, &inst->SrcReg[0]))
898 if (!Parse_String(parseState, ","))
902 if (!Parse_SwizzleSrcReg(parseState, &inst->SrcReg[1]))
906 if (!Parse_String(parseState, ","))
910 if (!Parse_SwizzleSrcReg(parseState, &inst->SrcReg[2]))
914 if (!Parse_String(parseState, ";"))
946 Parse_ScalarInstruction(struct parse_state *parseState,
950 if (opcode == OPCODE_RCC && !parseState->isVersion1_1)
956 if (!Parse_MaskedDstReg(parseState, &inst->DstReg))
960 if (!Parse_String(parseState, ","))
964 if (!Parse_ScalarSrcReg(parseState, &inst->SrcReg[0]))
968 if (!Parse_String(parseState, ";"))
976 Parse_AddressInstruction(struct parse_state *parseState, struct prog_instruction *inst)
986 if (!Parse_AddrReg(parseState))
990 if (!Parse_String(parseState, ","))
994 if (!Parse_ScalarSrcReg(parseState, &inst->SrcReg[0]))
998 if (!Parse_String(parseState, ";"))
1006 Parse_EndInstruction(struct parse_state *parseState, struct prog_instruction *inst)
1013 if (Parse_Token(parseState, token))
1034 Parse_PrintInstruction(struct parse_state *parseState, struct prog_instruction *inst)
1046 if (!Parse_String(parseState, "'"))
1049 str = parseState->pos;
1052 parseState->pos += len + 1;
1060 if (Parse_String(parseState, ",")) {
1063 if (!Peek_Token(parseState, token))
1075 if (!Parse_TempReg(parseState, &idx))
1081 if (!Parse_ParamReg(parseState, srcReg))
1086 if (!Parse_AttribReg(parseState, &idx))
1092 if (!Parse_OutputReg(parseState, &idx))
1105 if (!Parse_String(parseState, ";"))
1113 Parse_OptionSequence(struct parse_state *parseState,
1118 if (!Parse_String(parseState, "OPTION"))
1120 if (Parse_String(parseState, "NV_position_invariant")) {
1121 parseState->isPositionInvariant = GL_TRUE;
1126 if (!Parse_String(parseState, ";"))
1133 Parse_InstructionSequence(struct parse_state *parseState,
1137 struct prog_instruction *inst = program + parseState->numInst;
1142 if (Parse_String(parseState, "MOV")) {
1143 if (!Parse_UnaryOpInstruction(parseState, inst, OPCODE_MOV))
1146 else if (Parse_String(parseState, "LIT")) {
1147 if (!Parse_UnaryOpInstruction(parseState, inst, OPCODE_LIT))
1150 else if (Parse_String(parseState, "ABS")) {
1151 if (!Parse_UnaryOpInstruction(parseState, inst, OPCODE_ABS))
1154 else if (Parse_String(parseState, "MUL")) {
1155 if (!Parse_BiOpInstruction(parseState, inst, OPCODE_MUL))
1158 else if (Parse_String(parseState, "ADD")) {
1159 if (!Parse_BiOpInstruction(parseState, inst, OPCODE_ADD))
1162 else if (Parse_String(parseState, "DP3")) {
1163 if (!Parse_BiOpInstruction(parseState, inst, OPCODE_DP3))
1166 else if (Parse_String(parseState, "DP4")) {
1167 if (!Parse_BiOpInstruction(parseState, inst, OPCODE_DP4))
1170 else if (Parse_String(parseState, "DST")) {
1171 if (!Parse_BiOpInstruction(parseState, inst, OPCODE_DST))
1174 else if (Parse_String(parseState, "MIN")) {
1175 if (!Parse_BiOpInstruction(parseState, inst, OPCODE_MIN))
1178 else if (Parse_String(parseState, "MAX")) {
1179 if (!Parse_BiOpInstruction(parseState, inst, OPCODE_MAX))
1182 else if (Parse_String(parseState, "SLT")) {
1183 if (!Parse_BiOpInstruction(parseState, inst, OPCODE_SLT))
1186 else if (Parse_String(parseState, "SGE")) {
1187 if (!Parse_BiOpInstruction(parseState, inst, OPCODE_SGE))
1190 else if (Parse_String(parseState, "DPH")) {
1191 if (!Parse_BiOpInstruction(parseState, inst, OPCODE_DPH))
1194 else if (Parse_String(parseState, "SUB")) {
1195 if (!Parse_BiOpInstruction(parseState, inst, OPCODE_SUB))
1198 else if (Parse_String(parseState, "MAD")) {
1199 if (!Parse_TriOpInstruction(parseState, inst, OPCODE_MAD))
1202 else if (Parse_String(parseState, "RCP")) {
1203 if (!Parse_ScalarInstruction(parseState, inst, OPCODE_RCP))
1206 else if (Parse_String(parseState, "RSQ")) {
1207 if (!Parse_ScalarInstruction(parseState, inst, OPCODE_RSQ))
1210 else if (Parse_String(parseState, "EXP")) {
1211 if (!Parse_ScalarInstruction(parseState, inst, OPCODE_EXP))
1214 else if (Parse_String(parseState, "LOG")) {
1215 if (!Parse_ScalarInstruction(parseState, inst, OPCODE_LOG))
1218 else if (Parse_String(parseState, "RCC")) {
1219 if (!Parse_ScalarInstruction(parseState, inst, OPCODE_RCC))
1222 else if (Parse_String(parseState, "ARL")) {
1223 if (!Parse_AddressInstruction(parseState, inst))
1226 else if (Parse_String(parseState, "PRINT")) {
1227 if (!Parse_PrintInstruction(parseState, inst))
1230 else if (Parse_String(parseState, "END")) {
1231 if (!Parse_EndInstruction(parseState, inst))
1234 parseState
1245 parseState->outputsWritten |= (1 << inst->DstReg.Index);
1247 parseState->anyProgRegsWritten = GL_TRUE;
1250 parseState->inputsRead |= (1 << inst->SrcReg[0].Index);
1252 parseState->inputsRead |= (1 << inst->SrcReg[1].Index);
1254 parseState->inputsRead |= (1 << inst->SrcReg[2].Index);
1256 parseState->numInst++;
1258 if (parseState->numInst >= MAX_NV_VERTEX_PROGRAM_INSTRUCTIONS)
1267 Parse_Program(struct parse_state *parseState,
1270 if (parseState->isVersion1_1) {
1271 if (!Parse_OptionSequence(parseState, instBuffer)) {
1275 return Parse_InstructionSequence(parseState, instBuffer);
1289 struct parse_state parseState;
1305 parseState.ctx = ctx;
1306 parseState.start = programString;
1307 parseState.isPositionInvariant = GL_FALSE;
1308 parseState.isVersion1_1 = GL_FALSE;
1309 parseState.numInst = 0;
1310 parseState.inputsRead = 0;
1311 parseState.outputsWritten = 0;
1312 parseState.anyProgRegsWritten = GL_FALSE;
1313 parseState.indirectRegisterFiles = 0x0;
1321 parseState.pos = programString + 7;
1322 parseState.isStateProgram = GL_FALSE;
1326 parseState.pos = programString + 7;
1327 parseState.isStateProgram = GL_FALSE;
1328 parseState.isVersion1_1 = GL_TRUE;
1332 parseState.pos = programString + 8;
1333 parseState.isStateProgram = GL_TRUE;
1350 if (Parse_Program(&parseState, instBuffer)) {
1356 if (parseState.isStateProgram) {
1357 if (!parseState.anyProgRegsWritten) {
1364 if (!parseState.isPositionInvariant &&
1365 !(parseState.outputsWritten & (1 << VERT_RESULT_HPOS))) {
1374 assert(parseState.numInst <= MAX_NV_VERTEX_PROGRAM_INSTRUCTIONS);
1375 newInst = _mesa_alloc_instructions(parseState.numInst);
1381 _mesa_copy_instructions(newInst, instBuffer, parseState.numInst);
1394 program->Base.InputsRead = parseState.inputsRead;
1395 if (parseState.isPositionInvariant)
1397 program->Base.NumInstructions = parseState.numInst;
1398 program->Base.OutputsWritten = parseState.outputsWritten;
1399 program->IsPositionInvariant = parseState.isPositionInvariant;
1414 program->Base.IndirectRegisterFiles = parseState.indirectRegisterFiles;