mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 01:17:35 +00:00
LibIDL: Use Core::Stream
to read imports
This commit is contained in:
parent
2577bb8416
commit
558fab2703
1 changed files with 6 additions and 3 deletions
|
@ -12,6 +12,7 @@
|
||||||
#include <AK/LexicalPath.h>
|
#include <AK/LexicalPath.h>
|
||||||
#include <AK/QuickSort.h>
|
#include <AK/QuickSort.h>
|
||||||
#include <LibCore/File.h>
|
#include <LibCore/File.h>
|
||||||
|
#include <LibCore/Stream.h>
|
||||||
|
|
||||||
[[noreturn]] static void report_parsing_error(StringView message, StringView filename, StringView input, size_t offset)
|
[[noreturn]] static void report_parsing_error(StringView message, StringView filename, StringView input, size_t offset)
|
||||||
{
|
{
|
||||||
|
@ -148,12 +149,14 @@ Optional<Interface&> Parser::resolve_import(auto path)
|
||||||
report_parsing_error(DeprecatedString::formatted("Circular import detected: {}", include_path), filename, input, lexer.tell());
|
report_parsing_error(DeprecatedString::formatted("Circular import detected: {}", include_path), filename, input, lexer.tell());
|
||||||
import_stack.set(real_path);
|
import_stack.set(real_path);
|
||||||
|
|
||||||
auto file_or_error = Core::File::open(real_path, Core::OpenMode::ReadOnly);
|
auto file_or_error = Core::Stream::File::open(real_path, Core::Stream::OpenMode::Read);
|
||||||
if (file_or_error.is_error())
|
if (file_or_error.is_error())
|
||||||
report_parsing_error(DeprecatedString::formatted("Failed to open {}: {}", real_path, file_or_error.error()), filename, input, lexer.tell());
|
report_parsing_error(DeprecatedString::formatted("Failed to open {}: {}", real_path, file_or_error.error()), filename, input, lexer.tell());
|
||||||
|
|
||||||
auto data = file_or_error.value()->read_all();
|
auto data_or_error = file_or_error.value()->read_until_eof();
|
||||||
auto& result = Parser(this, real_path, data, import_base_path).parse();
|
if (data_or_error.is_error())
|
||||||
|
report_parsing_error(DeprecatedString::formatted("Failed to read {}: {}", real_path, data_or_error.error()), filename, input, lexer.tell());
|
||||||
|
auto& result = Parser(this, real_path, data_or_error.value(), import_base_path).parse();
|
||||||
import_stack.remove(real_path);
|
import_stack.remove(real_path);
|
||||||
|
|
||||||
top_level_resolved_imports().set(real_path, &result);
|
top_level_resolved_imports().set(real_path, &result);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue