/* IScanner */ static inline int ParseSection(struct IParse *parse, struct ISettings *settings) { ParseComment(parse); ParseSkip(parse); int code = ParsePeek(parse, 0); if (!(code == '[')) { return 0; } ParseRead(parse); /* [ */ ParseSkip(parse); /* Section Name */ char name[MAX_NAME]; if (!ParseName(parse, name, MAX_NAME)) { return 0; } ParseSkip(parse); code = ParsePeek(parse, 0); if (!(code == ']')) { return 0; } ParseRead(parse); /* "]" */ HSECTION section = NULL; if (!(section = CreateSection(settings, name))) { return 0; } while (ParseValue(parse, section)); return 1; }
HRESULT Vc4Disasm::ParseMulOp(VC4_QPU_INSTRUCTION Instruction) { this->xprintf(TEXT("%s%s%s "), (VC4_QPU_IS_OPCODE_MUL_MOV(Instruction) ? VC4_QPU_Name_Op_Move : VC4_QPU_LOOKUP_STRING(OPCODE_MUL, VC4_QPU_GET_OPCODE_MUL(Instruction))), (VC4_QPU_IS_SETFLAGS_SET(Instruction) ? VC4_QPU_Name_SetFlag : VC4_QPU_Name_Empty), (VC4_QPU_IS_OPCODE_MUL_NOP(Instruction) ? VC4_QPU_Name_Empty : VC4_QPU_LOOKUP_STRING(COND, VC4_QPU_GET_COND_MUL(Instruction)))); if (!VC4_QPU_IS_OPCODE_MUL_NOP(Instruction)) { ParseWrite(Instruction, false); this->xprintf(TEXT(", ")); if (!VC4_QPU_IS_OPCODE_MUL_MOV(Instruction)) { ParseRead(Instruction, VC4_QPU_GET_MUL_A(Instruction)); this->xprintf(TEXT(", ")); } if (VC4_QPU_IS_OPCODE_LOAD_SM(Instruction) && (VC4_QPU_GET_MUL_B(Instruction) == VC4_QPU_ALU_REG_B)) { ParseSmallImmediate(Instruction); } else { ParseRead(Instruction, VC4_QPU_GET_MUL_B(Instruction)); } } return S_OK; }
/* IScanner */ static inline int ParseValue(struct IParse *parse, struct ISection *section) { ParseComment(parse); ParseSkip(parse); /* Value Name */ char name[MAX_NAME]; if (!ParseName(parse, name, MAX_NAME)) { return 0; } ParseSkip(parse); int code = ParsePeek(parse, 0); if (!(code == '=')) { return 0; } ParseRead(parse); /* = */ ParseSkip(parse); /* Value Data */ char data[MAX_VALUE]; if (!ParseData(parse, data, MAX_VALUE)) { return 0; } AddSectionString(section, name, data); return 1; }
/* IScanner */ static inline int ParseSkip(struct IParse *parse) { int code = 0; while ((code = ParsePeek(parse, 0)) != -1) { switch (code) { case TOKEN_TAB: case TOKEN_SPACE: ParseRead(parse); continue; case TOKEN_CR: case TOKEN_LF: ParseRead(parse); parse->col = 1; parse->line++; continue; default: return 1; } } return 0; }
/* IScanner */ static inline int ParseData(struct IParse *parse, char *string, unsigned int length) { int index = 0; memset(string, 0, length); while (IsDataValid(ParsePeek(parse, 0))) { if (index >= length) { string[length-1] = '\0'; break; } string[index] = (char)ParseRead(parse); index++; } return 1; }
/* IScanner */ static inline int ParseCommentLine(struct IParse *parse) { ParseSkip(parse); if (!IsComment(parse)) { return 0; } int code = 0; while ((code = ParseRead(parse)) != -1) { if (IsNewline(code)) { return 1; } } return 1; }
uint64_t ParseRead( const hash_event::HasherStateData & state, const uint64_t previous_total_bytes_read, const uint64_t bytes_read, const char * const buffer ) { if (bytes_read == 0) return previous_total_bytes_read; auto & hasher = state->primary_hasher; auto & chunk_hasher = state->chunk_hasher; auto & chunk_hashes = state->chunk_hashes; const auto & chunk_ranges = state->chunk_ranges; const auto current_chunk_num = chunk_hashes.size(); const auto read_start = previous_total_bytes_read; const auto read_end = read_start + bytes_read; const auto chunk_range = chunk_ranges.at(current_chunk_num); hasher.Update(bytes_read, buffer); // New range must occur when read_end == chunk range end, not on start. assert (read_start < chunk_range.second); if (read_end < chunk_range.second) { // Current read is completely in current range chunk_hasher.Update(bytes_read, buffer); return previous_total_bytes_read + bytes_read; } else { // If read : 2 3 | 4 5 6 7 // Chunk span first: 2,4 // Chunk span second: 4,8 // Bytes remaining in current chunk: 2 ( 4 - 2 ) // Bytes remaining in next chunk: 4 ( 6 - current chunk bytes ) const auto bytes_to_first_chunk = chunk_range.second - read_start; const auto unparsed_bytes = bytes_read - bytes_to_first_chunk; // Complete this chunk chunk_hasher.Update(bytes_to_first_chunk, buffer); chunk_hashes.push_back( chunk_hasher.Digest() ); chunk_hasher = ::mf::utils::Sha256Hasher(); // Bytes are now processed, increment read position const auto new_total_bytes_read = previous_total_bytes_read + bytes_to_first_chunk; // Process remaining read data recursively if any left if (unparsed_bytes > 0) { return ParseRead( state, new_total_bytes_read, unparsed_bytes, buffer + bytes_to_first_chunk); } else { return new_total_bytes_read; } } }