[fidl] Move Library under flat_ast
Change-Id: Ia6fe3cc68ccbb1965b0f270d1a6bff4b248a3eea
diff --git a/system/host/fidl/BUILD.gn b/system/host/fidl/BUILD.gn
index 92213ff..a02cb54 100644
--- a/system/host/fidl/BUILD.gn
+++ b/system/host/fidl/BUILD.gn
@@ -12,10 +12,10 @@
sources = [
"lib/error_reporter.cpp",
"lib/c_generator.cpp",
+ "lib/flat_ast.cpp",
"lib/identifier_table.cpp",
"lib/json_generator.cpp",
"lib/lexer.cpp",
- "lib/library.cpp",
"lib/parser.cpp",
"lib/source_file.cpp",
"lib/source_location.cpp",
diff --git a/system/host/fidl/compiler/main.cpp b/system/host/fidl/compiler/main.cpp
index 5206df7..c270c29 100644
--- a/system/host/fidl/compiler/main.cpp
+++ b/system/host/fidl/compiler/main.cpp
@@ -13,10 +13,10 @@
#include <vector>
#include <fidl/c_generator.h>
+#include <fidl/flat_ast.h>
#include <fidl/identifier_table.h>
#include <fidl/json_generator.h>
#include <fidl/lexer.h>
-#include <fidl/library.h>
#include <fidl/parser.h>
#include <fidl/source_manager.h>
@@ -134,7 +134,7 @@
bool Parse(Arguments* args, fidl::SourceManager* source_manager,
fidl::IdentifierTable* identifier_table, fidl::ErrorReporter* error_reporter,
- fidl::Library* library) {
+ fidl::flat::Library* library) {
while (args->Remaining()) {
std::string filename = args->Claim();
const fidl::SourceFile* source = source_manager->CreateSource(filename.data());
@@ -158,14 +158,14 @@
}
if (!library->Resolve()) {
- fprintf(stderr, "Library resolution failed!\n");
+ fprintf(stderr, "flat::Library resolution failed!\n");
return false;
}
return true;
}
-bool GenerateC(fidl::Library* library, std::fstream header_output) {
+bool GenerateC(fidl::flat::Library* library, std::fstream header_output) {
std::ostringstream header_file;
fidl::CGenerator c_generator(library);
@@ -178,7 +178,7 @@
return true;
}
-bool GenerateJSON(fidl::Library* library, std::fstream json_output) {
+bool GenerateJSON(fidl::flat::Library* library, std::fstream json_output) {
std::ostringstream json_file;
fidl::JSONGenerator json_generator(library);
@@ -234,7 +234,7 @@
fidl::SourceManager source_manager;
fidl::IdentifierTable identifier_table;
fidl::ErrorReporter error_reporter;
- fidl::Library library;
+ fidl::flat::Library library;
if (!Parse(args, &source_manager, &identifier_table, &error_reporter, &library)) {
return 1;
}
diff --git a/system/host/fidl/include/fidl/c_generator.h b/system/host/fidl/include/fidl/c_generator.h
index 90a10ed..fb2ea8d 100644
--- a/system/host/fidl/include/fidl/c_generator.h
+++ b/system/host/fidl/include/fidl/c_generator.h
@@ -10,7 +10,7 @@
#include <vector>
#include "coded_ast.h"
-#include "library.h"
+#include "flat_ast.h"
#include "string_view.h"
namespace fidl {
@@ -27,7 +27,7 @@
class CGenerator {
public:
- explicit CGenerator(Library* library) : library_(library) {}
+ explicit CGenerator(flat::Library* library) : library_(library) {}
~CGenerator() = default;
@@ -111,7 +111,7 @@
void ProduceStructDeclaration(const NamedStruct& named_struct);
void ProduceUnionDeclaration(const NamedUnion& named_union);
- Library* library_;
+ flat::Library* library_;
std::ostringstream header_file_;
};
diff --git a/system/host/fidl/include/fidl/flat_ast.h b/system/host/fidl/include/fidl/flat_ast.h
index 185e834..c18ff81 100644
--- a/system/host/fidl/include/fidl/flat_ast.h
+++ b/system/host/fidl/include/fidl/flat_ast.h
@@ -5,12 +5,16 @@
#ifndef ZIRCON_SYSTEM_HOST_FIDL_INCLUDE_FIDL_FLAT_AST_H_
#define ZIRCON_SYSTEM_HOST_FIDL_INCLUDE_FIDL_FLAT_AST_H_
+#include <errno.h>
#include <stdint.h>
+#include <map>
#include <memory>
+#include <set>
#include <vector>
#include "ast.h"
+#include "type_shape.h"
namespace fidl {
namespace flat {
@@ -151,6 +155,133 @@
uint64_t size = 8;
};
+class Library {
+public:
+ bool ConsumeFile(std::unique_ptr<ast::File> file);
+ bool Resolve();
+
+private:
+ bool ConsumeConstDeclaration(std::unique_ptr<ast::ConstDeclaration> const_declaration);
+ bool ConsumeEnumDeclaration(std::unique_ptr<ast::EnumDeclaration> enum_declaration);
+ bool
+ ConsumeInterfaceDeclaration(std::unique_ptr<ast::InterfaceDeclaration> interface_declaration);
+ bool ConsumeStructDeclaration(std::unique_ptr<ast::StructDeclaration> struct_declaration);
+ bool ConsumeUnionDeclaration(std::unique_ptr<ast::UnionDeclaration> union_declaration);
+
+ bool RegisterTypeName(const Name& name);
+
+ bool ResolveConst(const Const& const_declaration);
+ bool ResolveEnum(const Enum& enum_declaration);
+ bool ResolveInterface(const Interface& interface_declaration);
+ bool ResolveStruct(const Struct& struct_declaration);
+ bool ResolveUnion(const Union& union_declaration);
+
+ bool ResolveArrayType(const ast::ArrayType& array_type, TypeShape* out_type_metadata);
+ bool ResolveVectorType(const ast::VectorType& vector_type, TypeShape* out_type_metadata);
+ bool ResolveStringType(const ast::StringType& string_type, TypeShape* out_type_metadata);
+ bool ResolveHandleType(const ast::HandleType& handle_type, TypeShape* out_type_metadata);
+ bool ResolveRequestType(const ast::RequestType& request_type, TypeShape* out_type_metadata);
+ bool ResolvePrimitiveType(const ast::PrimitiveType& primitive_type,
+ TypeShape* out_type_metadata);
+ bool ResolveIdentifierType(const ast::IdentifierType& identifier_type,
+ TypeShape* out_type_metadata);
+ bool ResolveType(const ast::Type* type) {
+ TypeShape type_metadata;
+ return ResolveType(type, &type_metadata);
+ }
+ bool ResolveType(const ast::Type* type, TypeShape* out_type_metadata);
+ bool ResolveTypeName(const ast::CompoundIdentifier* name);
+ bool RegisterResolvedType(const Name& name, TypeShape type_metadata);
+
+ bool LookupTypeShape(const Name& name, TypeShape* out_typeshape);
+
+public:
+ // TODO(TO-702) Add a validate literal function. Some things
+ // (e.g. array indexes) want to check the value but print the
+ // constant, say.
+ template <typename IntType>
+ bool ParseIntegerLiteral(const ast::NumericLiteral* literal, IntType* out_value) {
+ if (!literal) {
+ return false;
+ }
+ auto data = literal->location.data();
+ std::string string_data(data.data(), data.data() + data.size());
+ if (std::is_unsigned<IntType>::value) {
+ errno = 0;
+ unsigned long long value = strtoull(string_data.data(), nullptr, 0);
+ if (errno != 0)
+ return false;
+ if (value > std::numeric_limits<IntType>::max())
+ return false;
+ *out_value = static_cast<IntType>(value);
+ } else {
+ errno = 0;
+ long long value = strtoll(string_data.data(), nullptr, 0);
+ if (errno != 0) {
+ return false;
+ }
+ if (value > std::numeric_limits<IntType>::max()) {
+ return false;
+ }
+ if (value < std::numeric_limits<IntType>::min()) {
+ return false;
+ }
+ *out_value = static_cast<IntType>(value);
+ }
+ return true;
+ }
+
+ template <typename IntType>
+ bool ParseIntegerConstant(const ast::Constant* constant, IntType* out_value) {
+ if (!constant) {
+ return false;
+ }
+ switch (constant->kind) {
+ case ast::Constant::Kind::Identifier: {
+ auto identifier_constant = static_cast<const ast::IdentifierConstant*>(constant);
+ auto identifier = identifier_constant->identifier.get();
+ // TODO(TO-702) Actually resolve this.
+ static_cast<void>(identifier);
+ *out_value = static_cast<IntType>(123);
+ return true;
+ }
+ case ast::Constant::Kind::Literal: {
+ auto literal_constant = static_cast<const ast::LiteralConstant*>(constant);
+ switch (literal_constant->literal->kind) {
+ case ast::Literal::Kind::String:
+ case ast::Literal::Kind::True:
+ case ast::Literal::Kind::False:
+ case ast::Literal::Kind::Default: {
+ return false;
+ }
+
+ case ast::Literal::Kind::Numeric: {
+ auto numeric_literal =
+ static_cast<const ast::NumericLiteral*>(literal_constant->literal.get());
+ return ParseIntegerLiteral<IntType>(numeric_literal, out_value);
+ }
+ }
+ }
+ }
+ }
+
+ std::unique_ptr<ast::Identifier> library_name_;
+
+ std::vector<Const> const_declarations_;
+ std::vector<Enum> enum_declarations_;
+ std::vector<Interface> interface_declarations_;
+ std::vector<Struct> struct_declarations_;
+ std::vector<Union> union_declarations_;
+
+ // TODO(TO-773) Compute this based on the DAG of aggregates
+ // including each other as members.
+ std::vector<Name> declaration_order_;
+
+private:
+ std::set<Name> registered_types_;
+ std::map<Name, TypeShape> resolved_types_;
+};
+
} // namespace flat
} // namespace fidl
diff --git a/system/host/fidl/include/fidl/json_generator.h b/system/host/fidl/include/fidl/json_generator.h
index 2d13430..2fbb904 100644
--- a/system/host/fidl/include/fidl/json_generator.h
+++ b/system/host/fidl/include/fidl/json_generator.h
@@ -12,7 +12,6 @@
#include "coded_ast.h"
#include "flat_ast.h"
-#include "library.h"
#include "string_view.h"
namespace fidl {
@@ -29,7 +28,7 @@
class JSONGenerator {
public:
- explicit JSONGenerator(Library* library)
+ explicit JSONGenerator(flat::Library* library)
: library_(library) {}
~JSONGenerator() = default;
@@ -89,7 +88,7 @@
void GenerateDeclarationMapEntry(int count, const flat::Name& name, StringView decl);
- Library* library_;
+ flat::Library* library_;
int indent_level_;
std::ostringstream json_file_;
};
diff --git a/system/host/fidl/include/fidl/library.h b/system/host/fidl/include/fidl/library.h
deleted file mode 100644
index 40d068f..0000000
--- a/system/host/fidl/include/fidl/library.h
+++ /dev/null
@@ -1,160 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef ZIRCON_SYSTEM_HOST_FIDL_INCLUDE_FIDL_LIBRARY_H_
-#define ZIRCON_SYSTEM_HOST_FIDL_INCLUDE_FIDL_LIBRARY_H_
-
-#include <errno.h>
-
-#include <map>
-#include <memory>
-#include <set>
-#include <string>
-#include <utility>
-#include <vector>
-
-#include "ast.h"
-#include "coded_ast.h"
-#include "flat_ast.h"
-#include "identifier_table.h"
-#include "source_manager.h"
-#include "type_shape.h"
-
-namespace fidl {
-
-class Library {
-public:
- bool ConsumeFile(std::unique_ptr<ast::File> file);
- bool Resolve();
-
-private:
- bool ConsumeConstDeclaration(std::unique_ptr<ast::ConstDeclaration> const_declaration);
- bool ConsumeEnumDeclaration(std::unique_ptr<ast::EnumDeclaration> enum_declaration);
- bool
- ConsumeInterfaceDeclaration(std::unique_ptr<ast::InterfaceDeclaration> interface_declaration);
- bool ConsumeStructDeclaration(std::unique_ptr<ast::StructDeclaration> struct_declaration);
- bool ConsumeUnionDeclaration(std::unique_ptr<ast::UnionDeclaration> union_declaration);
-
- bool RegisterTypeName(const flat::Name& name);
-
- bool ResolveConst(const flat::Const& const_declaration);
- bool ResolveEnum(const flat::Enum& enum_declaration);
- bool ResolveInterface(const flat::Interface& interface_declaration);
- bool ResolveStruct(const flat::Struct& struct_declaration);
- bool ResolveUnion(const flat::Union& union_declaration);
-
- bool ResolveArrayType(const ast::ArrayType& array_type, TypeShape* out_type_metadata);
- bool ResolveVectorType(const ast::VectorType& vector_type, TypeShape* out_type_metadata);
- bool ResolveStringType(const ast::StringType& string_type, TypeShape* out_type_metadata);
- bool ResolveHandleType(const ast::HandleType& handle_type, TypeShape* out_type_metadata);
- bool ResolveRequestType(const ast::RequestType& request_type, TypeShape* out_type_metadata);
- bool ResolvePrimitiveType(const ast::PrimitiveType& primitive_type,
- TypeShape* out_type_metadata);
- bool ResolveIdentifierType(const ast::IdentifierType& identifier_type,
- TypeShape* out_type_metadata);
- bool ResolveType(const ast::Type* type) {
- TypeShape type_metadata;
- return ResolveType(type, &type_metadata);
- }
- bool ResolveType(const ast::Type* type, TypeShape* out_type_metadata);
- bool ResolveTypeName(const ast::CompoundIdentifier* name);
- bool RegisterResolvedType(const flat::Name& name, TypeShape type_metadata);
-
- bool LookupTypeShape(const flat::Name& name, TypeShape* out_typeshape);
-
- const coded::Type* LookupIdentifierType(const ast::IdentifierType* identifier_type);
-
- void MaybeCreateCodingField(std::string field_name, uint32_t offset, const ast::Type* type,
- std::vector<coded::Field>* fields);
-
-public:
- // TODO(TO-702) Add a validate literal function. Some things
- // (e.g. array indexes) want to check the value but print the
- // constant, say.
- template <typename IntType>
- bool ParseIntegerLiteral(const ast::NumericLiteral* literal, IntType* out_value) {
- if (!literal) {
- return false;
- }
- auto data = literal->location.data();
- std::string string_data(data.data(), data.data() + data.size());
- if (std::is_unsigned<IntType>::value) {
- errno = 0;
- unsigned long long value = strtoull(string_data.data(), nullptr, 0);
- if (errno != 0)
- return false;
- if (value > std::numeric_limits<IntType>::max())
- return false;
- *out_value = static_cast<IntType>(value);
- } else {
- errno = 0;
- long long value = strtoll(string_data.data(), nullptr, 0);
- if (errno != 0) {
- return false;
- }
- if (value > std::numeric_limits<IntType>::max()) {
- return false;
- }
- if (value < std::numeric_limits<IntType>::min()) {
- return false;
- }
- *out_value = static_cast<IntType>(value);
- }
- return true;
- }
-
- template <typename IntType>
- bool ParseIntegerConstant(const ast::Constant* constant, IntType* out_value) {
- if (!constant) {
- return false;
- }
- switch (constant->kind) {
- case ast::Constant::Kind::Identifier: {
- auto identifier_constant = static_cast<const ast::IdentifierConstant*>(constant);
- auto identifier = identifier_constant->identifier.get();
- // TODO(TO-702) Actually resolve this.
- static_cast<void>(identifier);
- *out_value = static_cast<IntType>(123);
- return true;
- }
- case ast::Constant::Kind::Literal: {
- auto literal_constant = static_cast<const ast::LiteralConstant*>(constant);
- switch (literal_constant->literal->kind) {
- case ast::Literal::Kind::String:
- case ast::Literal::Kind::True:
- case ast::Literal::Kind::False:
- case ast::Literal::Kind::Default: {
- return false;
- }
-
- case ast::Literal::Kind::Numeric: {
- auto numeric_literal =
- static_cast<const ast::NumericLiteral*>(literal_constant->literal.get());
- return ParseIntegerLiteral<IntType>(numeric_literal, out_value);
- }
- }
- }
- }
- }
-
- std::unique_ptr<ast::Identifier> library_name_;
-
- std::vector<flat::Const> const_declarations_;
- std::vector<flat::Enum> enum_declarations_;
- std::vector<flat::Interface> interface_declarations_;
- std::vector<flat::Struct> struct_declarations_;
- std::vector<flat::Union> union_declarations_;
-
- // TODO(TO-773) Compute this based on the DAG of aggregates
- // including each other as members.
- std::vector<flat::Name> declaration_order_;
-
-private:
- std::set<flat::Name> registered_types_;
- std::map<flat::Name, TypeShape> resolved_types_;
-};
-
-} // namespace fidl
-
-#endif // ZIRCON_SYSTEM_HOST_FIDL_INCLUDE_FIDL_LIBRARY_H_
diff --git a/system/host/fidl/lib/c_generator.cpp b/system/host/fidl/lib/c_generator.cpp
index 02b4783..de21c7b 100644
--- a/system/host/fidl/lib/c_generator.cpp
+++ b/system/host/fidl/lib/c_generator.cpp
@@ -205,7 +205,7 @@
}
void EnumValue(types::PrimitiveSubtype type, const ast::Constant* constant,
- Library* library, std::string* out_value) {
+ flat::Library* library, std::string* out_value) {
// TODO(kulakowski) Move this into library resolution.
std::ostringstream member_value;
@@ -298,7 +298,7 @@
*out_value = member_value.str();
}
-std::vector<uint32_t> ArrayCounts(Library* library, const ast::Type* type) {
+std::vector<uint32_t> ArrayCounts(flat::Library* library, const ast::Type* type) {
std::vector<uint32_t> array_counts;
for (;;) {
switch (type->kind) {
@@ -320,14 +320,14 @@
}
}
-CGenerator::Member CreateMember(Library* library, const ast::Type* type, StringView name) {
+CGenerator::Member CreateMember(flat::Library* library, const ast::Type* type, StringView name) {
auto type_name = TypeName(type);
std::vector<uint32_t> array_counts = ArrayCounts(library, type);
return CGenerator::Member{type_name, name, std::move(array_counts)};
}
std::vector<CGenerator::Member>
-GenerateMembers(Library* library, const std::vector<flat::Union::Member>& union_members) {
+GenerateMembers(flat::Library* library, const std::vector<flat::Union::Member>& union_members) {
std::vector<CGenerator::Member> members;
members.reserve(union_members.size());
for (const auto& union_member : union_members) {
diff --git a/system/host/fidl/lib/library.cpp b/system/host/fidl/lib/flat_ast.cpp
similarity index 93%
rename from system/host/fidl/lib/library.cpp
rename to system/host/fidl/lib/flat_ast.cpp
index e9fa649..3bc9ffb 100644
--- a/system/host/fidl/lib/library.cpp
+++ b/system/host/fidl/lib/flat_ast.cpp
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "fidl/library.h"
+#include "fidl/flat_ast.h"
#include <assert.h>
#include <stdio.h>
@@ -15,6 +15,7 @@
#include "fidl/parser.h"
namespace fidl {
+namespace flat {
namespace {
@@ -113,7 +114,7 @@
// so on.
bool Library::ConsumeConstDeclaration(std::unique_ptr<ast::ConstDeclaration> const_declaration) {
- auto name = flat::Name(std::move(const_declaration->identifier));
+ auto name = Name(std::move(const_declaration->identifier));
if (!RegisterTypeName(name))
return false;
@@ -123,16 +124,16 @@
}
bool Library::ConsumeEnumDeclaration(std::unique_ptr<ast::EnumDeclaration> enum_declaration) {
- std::vector<flat::Enum::Member> members;
+ std::vector<Enum::Member> members;
for (auto& member : enum_declaration->members) {
- auto name = flat::Name(std::move(member->identifier));
+ auto name = Name(std::move(member->identifier));
auto value = std::move(member->value);
members.emplace_back(std::move(name), std::move(value));
}
std::unique_ptr<ast::PrimitiveType> type = std::move(enum_declaration->maybe_subtype);
if (!type)
type = std::make_unique<ast::PrimitiveType>(types::PrimitiveSubtype::Uint32);
- auto name = flat::Name(std::move(enum_declaration->identifier));
+ auto name = Name(std::move(enum_declaration->identifier));
if (!RegisterTypeName(name))
return false;
@@ -142,7 +143,7 @@
bool Library::ConsumeInterfaceDeclaration(
std::unique_ptr<ast::InterfaceDeclaration> interface_declaration) {
- auto name = flat::Name(std::move(interface_declaration->identifier));
+ auto name = Name(std::move(interface_declaration->identifier));
for (auto& const_member : interface_declaration->const_members)
if (!ConsumeConstDeclaration(std::move(const_member)))
@@ -151,7 +152,7 @@
if (!ConsumeEnumDeclaration(std::move(enum_member)))
return false;
- std::vector<flat::Interface::Method> methods;
+ std::vector<Interface::Method> methods;
for (auto& method : interface_declaration->method_members) {
auto ordinal_literal = std::move(method->ordinal);
uint32_t value;
@@ -159,12 +160,12 @@
return false;
if (value == 0u)
return false;
- flat::Ordinal ordinal(std::move(ordinal_literal), value);
+ Ordinal ordinal(std::move(ordinal_literal), value);
auto method_name = std::move(method->identifier);
bool has_request = static_cast<bool>(method->maybe_request);
- std::vector<flat::Interface::Method::Parameter> maybe_request;
+ std::vector<Interface::Method::Parameter> maybe_request;
if (has_request) {
for (auto& parameter : method->maybe_request->parameter_list) {
auto parameter_name = std::move(parameter->identifier);
@@ -173,7 +174,7 @@
}
bool has_response = static_cast<bool>(method->maybe_response);
- std::vector<flat::Interface::Method::Parameter> maybe_response;
+ std::vector<Interface::Method::Parameter> maybe_response;
if (has_response) {
for (auto& parameter : method->maybe_response->parameter_list) {
auto response_paramater_name = std::move(parameter->identifier);
@@ -196,7 +197,7 @@
}
bool Library::ConsumeStructDeclaration(std::unique_ptr<ast::StructDeclaration> struct_declaration) {
- auto name = flat::Name(std::move(struct_declaration->identifier));
+ auto name = Name(std::move(struct_declaration->identifier));
for (auto& const_member : struct_declaration->const_members)
if (!ConsumeConstDeclaration(std::move(const_member)))
@@ -205,7 +206,7 @@
if (!ConsumeEnumDeclaration(std::move(enum_member)))
return false;
- std::vector<flat::Struct::Member> members;
+ std::vector<Struct::Member> members;
for (auto& member : struct_declaration->members) {
auto name = std::move(member->identifier);
members.emplace_back(std::move(member->type), std::move(name),
@@ -219,12 +220,12 @@
}
bool Library::ConsumeUnionDeclaration(std::unique_ptr<ast::UnionDeclaration> union_declaration) {
- std::vector<flat::Union::Member> members;
+ std::vector<Union::Member> members;
for (auto& member : union_declaration->members) {
auto name = std::move(member->identifier);
members.emplace_back(std::move(member->type), std::move(name));
}
- auto name = flat::Name(std::move(union_declaration->identifier));
+ auto name = Name(std::move(union_declaration->identifier));
if (!RegisterTypeName(name))
return false;
@@ -289,14 +290,14 @@
return true;
}
-bool Library::RegisterTypeName(const flat::Name& name) {
+bool Library::RegisterTypeName(const Name& name) {
// TODO(TO-701) Should this copy the Name?
// auto iter = registered_types_.insert(name);
// return iter.second;
return true;
}
-bool Library::RegisterResolvedType(const flat::Name& name, TypeShape typeshape) {
+bool Library::RegisterResolvedType(const Name& name, TypeShape typeshape) {
// TODO(TO-701) Should this copy the Name?
// auto key_value = std::make_pair(name, typeshape);
// auto iter = resolved_types_.insert(std::move(key_value));
@@ -304,7 +305,7 @@
return true;
}
-bool Library::LookupTypeShape(const flat::Name& name, TypeShape* out_typeshape) {
+bool Library::LookupTypeShape(const Name& name, TypeShape* out_typeshape) {
auto iter = resolved_types_.find(name);
if (iter == resolved_types_.end()) {
return false;
@@ -316,7 +317,7 @@
// Library resolution is concerned with resolving identifiers to their
// declarations, and with computing type sizes and alignments.
-bool Library::ResolveConst(const flat::Const& const_declaration) {
+bool Library::ResolveConst(const Const& const_declaration) {
if (!ResolveType(const_declaration.type.get())) {
return false;
}
@@ -324,7 +325,7 @@
return true;
}
-bool Library::ResolveEnum(const flat::Enum& enum_declaration) {
+bool Library::ResolveEnum(const Enum& enum_declaration) {
TypeShape typeshape;
switch (enum_declaration.type->subtype) {
@@ -357,7 +358,7 @@
return true;
}
-bool Library::ResolveInterface(const flat::Interface& interface_declaration) {
+bool Library::ResolveInterface(const Interface& interface_declaration) {
// TODO(TO-703) Add subinterfaces here.
Scope<StringView> name_scope;
Scope<uint32_t> ordinal_scope;
@@ -388,7 +389,7 @@
return true;
}
-bool Library::ResolveStruct(const flat::Struct& struct_declaration) {
+bool Library::ResolveStruct(const Struct& struct_declaration) {
Scope<StringView> scope;
std::vector<TypeShape> member_typeshapes;
for (const auto& member : struct_declaration.members) {
@@ -407,7 +408,7 @@
return true;
}
-bool Library::ResolveUnion(const flat::Union& union_declaration) {
+bool Library::ResolveUnion(const Union& union_declaration) {
Scope<StringView> scope;
std::vector<TypeShape> member_typeshapes;
for (const auto& member : union_declaration.members) {
@@ -620,4 +621,5 @@
return true;
}
+} // namespace flat
} // namespace fidl
diff --git a/system/host/fidl/rules.mk b/system/host/fidl/rules.mk
index 6a6478c..3817666 100644
--- a/system/host/fidl/rules.mk
+++ b/system/host/fidl/rules.mk
@@ -13,10 +13,10 @@
MODULE_SRCS := \
$(LOCAL_DIR)/lib/c_generator.cpp \
$(LOCAL_DIR)/lib/error_reporter.cpp \
+ $(LOCAL_DIR)/lib/flat_ast.cpp \
$(LOCAL_DIR)/lib/identifier_table.cpp \
$(LOCAL_DIR)/lib/json_generator.cpp \
$(LOCAL_DIR)/lib/lexer.cpp \
- $(LOCAL_DIR)/lib/library.cpp \
$(LOCAL_DIR)/lib/parser.cpp \
$(LOCAL_DIR)/lib/source_file.cpp \
$(LOCAL_DIR)/lib/source_location.cpp \