MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / parse_binary

Method parse_binary

modules/gdscript/gdscript_parser.cpp:447–480  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

445}
446
447Error GDScriptParser::parse_binary(const Vector<uint8_t> &p_binary, const String &p_script_path) {
448 GDScriptTokenizerBuffer *buffer_tokenizer = memnew(GDScriptTokenizerBuffer);
449 Error err = buffer_tokenizer->set_code_buffer(p_binary);
450
451 if (err) {
452 memdelete(buffer_tokenizer);
453 return err;
454 }
455
456 tokenizer = buffer_tokenizer;
457 script_path = p_script_path.simplify_path();
458 current = tokenizer->scan();
459 // Avoid error or newline as the first token.
460 // The latter can mess with the parser when opening files filled exclusively with comments and newlines.
461 while (current.type == GDScriptTokenizer::Token::ERROR || current.type == GDScriptTokenizer::Token::NEWLINE) {
462 if (current.type == GDScriptTokenizer::Token::ERROR) {
463 push_error(current.literal);
464 }
465 current = tokenizer->scan();
466 }
467
468 push_multiline(false); // Keep one for the whole parsing.
469 parse_program();
470 pop_multiline();
471
472 memdelete(buffer_tokenizer);
473 tokenizer = nullptr;
474
475 if (errors.is_empty()) {
476 return OK;
477 } else {
478 return ERR_PARSE_ERROR;
479 }
480}
481
482GDScriptTokenizer::Token GDScriptParser::advance() {
483 lambda_ended = false; // Empty marker since we're past the end in any case.

Callers 3

reloadMethod · 0.80
raise_statusMethod · 0.80
execute_test_codeMethod · 0.80

Calls 5

memdeleteFunction · 0.85
set_code_bufferMethod · 0.80
simplify_pathMethod · 0.45
scanMethod · 0.45
is_emptyMethod · 0.45

Tested by 1

execute_test_codeMethod · 0.64