1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:07:35 +00:00

LibIDL: Remove static maps for interfaces and resolved imports

Instead, create a tree of Parsers all pointing to a top-level Parser.

All module imports and interfaces are stored at the top level, instead
of in a static map. This allows creating multiple IDL::Parsers in the
same process without them stepping on each others toes.
This commit is contained in:
Andrew Kaster 2022-10-08 16:48:04 -06:00 committed by Andreas Kling
parent 2341294c20
commit 067a53b7e7
3 changed files with 49 additions and 14 deletions

View file

@ -28,6 +28,8 @@ private:
Yes,
};
Parser(Parser* parent, String filename, StringView contents, String import_base_path);
void assert_specific(char ch);
void assert_string(StringView expected);
void consume_whitespace();
@ -53,13 +55,17 @@ private:
NonnullRefPtr<Type> parse_type();
void parse_constant(Interface&);
static HashTable<NonnullOwnPtr<Interface>> s_interfaces;
static HashMap<String, Interface*> s_resolved_imports;
String import_base_path;
String filename;
StringView input;
GenericLexer lexer;
HashTable<NonnullOwnPtr<Interface>>& top_level_interfaces();
HashTable<NonnullOwnPtr<Interface>> interfaces;
HashMap<String, Interface*>& top_level_resolved_imports();
HashMap<String, Interface*> resolved_imports;
Parser* top_level_parser();
Parser* parent = nullptr;
};
}