Fix Shader Preprocessor line numbering when disabled
This commit is contained in:
parent
8f7b09916d
commit
34896d8e89
|
@ -54,9 +54,9 @@ int ShaderPreprocessor::Tokenizer::get_index() const {
|
|||
return index;
|
||||
}
|
||||
|
||||
void ShaderPreprocessor::Tokenizer::get_and_clear_generated(Vector<ShaderPreprocessor::Token> *r_out) {
|
||||
for (int i = 0; i < generated.size(); i++) {
|
||||
r_out->push_back(generated[i]);
|
||||
void ShaderPreprocessor::Tokenizer::get_and_clear_generated(LocalVector<char32_t> *r_out) {
|
||||
for (uint32_t i = 0; i < generated.size(); i++) {
|
||||
r_out->push_back(generated[i].text);
|
||||
}
|
||||
generated.clear();
|
||||
}
|
||||
|
@ -1206,18 +1206,14 @@ Error ShaderPreprocessor::preprocess(State *p_state, const String &p_code, Strin
|
|||
break;
|
||||
}
|
||||
|
||||
// Add autogenerated tokens if there are any.
|
||||
p_tokenizer.get_and_clear_generated(&output);
|
||||
|
||||
if (state->disabled) {
|
||||
// Preprocessor was disabled.
|
||||
// Read the rest of the file into the output.
|
||||
output.push_back(t.text);
|
||||
continue;
|
||||
} else {
|
||||
// Add autogenerated tokens.
|
||||
Vector<Token> generated;
|
||||
p_tokenizer.get_and_clear_generated(&generated);
|
||||
for (int i = 0; i < generated.size(); i++) {
|
||||
output.push_back(generated[i].text);
|
||||
}
|
||||
}
|
||||
|
||||
if (t.text == '#') {
|
||||
|
|
|
@ -83,7 +83,7 @@ private:
|
|||
int line;
|
||||
int index;
|
||||
int size;
|
||||
Vector<Token> generated;
|
||||
LocalVector<Token> generated;
|
||||
|
||||
private:
|
||||
void add_generated(const Token &p_t);
|
||||
|
@ -95,7 +95,7 @@ private:
|
|||
char32_t peek();
|
||||
int consume_line_continuations(int p_offset);
|
||||
|
||||
void get_and_clear_generated(Vector<Token> *r_out);
|
||||
void get_and_clear_generated(LocalVector<char32_t> *r_out);
|
||||
void backtrack(char32_t p_what);
|
||||
LocalVector<Token> advance(char32_t p_what);
|
||||
void skip_whitespace();
|
||||
|
|
Loading…
Reference in New Issue