Commit 2a2d82fd authored by Kenton Varda's avatar Kenton Varda

Fix 32-bit build.

parent fd669b11
This diff is collapsed.
......@@ -402,21 +402,24 @@ Type Schema::BrandArgumentList::operator[](uint index) const {
}
auto& binding = bindings[index];
Type result;
if (binding.which == (uint)schema::Type::ANY_POINTER) {
if (binding.scopeId != 0) {
return Type::BrandParameter { binding.scopeId, binding.paramIndex };
result = Type::BrandParameter { binding.scopeId, binding.paramIndex };
} else if (binding.isImplicitParameter) {
return Type::ImplicitParameter { binding.paramIndex };
result = Type::ImplicitParameter { binding.paramIndex };
} else {
return Type(schema::Type::ANY_POINTER, binding.listDepth, nullptr);
result = schema::Type::ANY_POINTER;
}
} else if (binding.schema == nullptr) {
// Builtin / primitive type.
return Type(static_cast<schema::Type::Which>(binding.which), binding.listDepth, nullptr);
result = static_cast<schema::Type::Which>(binding.which);
} else {
binding.schema->ensureInitialized();
return Type(static_cast<schema::Type::Which>(binding.which), binding.listDepth, binding.schema);
result = Type(static_cast<schema::Type::Which>(binding.which), binding.schema);
}
return result.wrapInList(binding.listDepth);
}
// =======================================================================================
......
......@@ -633,6 +633,12 @@ public:
bool operator==(const Type& other) const;
inline bool operator!=(const Type& other) const { return !(*this == other); }
inline Type wrapInList(uint depth = 1) const;
// Return the Type formed by wrapping this type in List() `depth` times.
inline Type(schema::Type::Which derived, const _::RawBrandedSchema* schema);
// For internal use.
private:
schema::Type::Which baseType; // type not including applications of List()
uint8_t listDepth; // 0 for T, 1 for List(T), 2 for List(List(T)), ...
......@@ -652,11 +658,12 @@ private:
};
Type(schema::Type::Which baseType, uint8_t listDepth, const _::RawBrandedSchema* schema)
: baseType(baseType), listDepth(listDepth), schema(schema) {}
: baseType(baseType), listDepth(listDepth), schema(schema) {
KJ_IREQUIRE(baseType != schema::Type::ANY_POINTER);
}
void requireUsableAs(Type expected) const;
friend class Schema;
friend class ListSchema;
};
......@@ -826,11 +833,22 @@ struct ListSchema::FromImpl<List<T>> {
inline Type::Type(): baseType(schema::Type::VOID), listDepth(0), schema(nullptr) {}
inline Type::Type(schema::Type::Which primitive)
: baseType(primitive), listDepth(0), isImplicitParam(false), scopeId(0) {
: baseType(primitive), listDepth(0), isImplicitParam(false) {
KJ_IREQUIRE(primitive != schema::Type::STRUCT &&
primitive != schema::Type::ENUM &&
primitive != schema::Type::INTERFACE &&
primitive != schema::Type::LIST);
if (primitive == schema::Type::ANY_POINTER) {
scopeId = 0;
} else {
schema = nullptr;
}
}
inline Type::Type(schema::Type::Which derived, const _::RawBrandedSchema* schema)
: baseType(derived), listDepth(0), isImplicitParam(false), schema(schema) {
KJ_IREQUIRE(derived == schema::Type::STRUCT ||
derived == schema::Type::ENUM ||
derived == schema::Type::INTERFACE);
}
inline Type::Type(StructSchema schema)
......@@ -879,6 +897,12 @@ inline bool Type::isAnyPointer() const {
return baseType == schema::Type::ANY_POINTER && listDepth == 0;
}
inline Type Type::wrapInList(uint depth) const {
Type result = *this;
result.listDepth += depth;
return result;
}
} // namespace capnp
#endif // CAPNP_SCHEMA_H_
......@@ -32,10 +32,10 @@ namespace _ { // private
void inlineRequireFailure(const char* file, int line, const char* expectation,
const char* macroArgs, const char* message) {
if (message == nullptr) {
Debug::Fault f(file, line, 0, expectation, macroArgs);
Debug::Fault f(file, line, kj::Exception::Type::FAILED, expectation, macroArgs);
f.fatal();
} else {
Debug::Fault f(file, line, 0, expectation, macroArgs, message);
Debug::Fault f(file, line, kj::Exception::Type::FAILED, expectation, macroArgs, message);
f.fatal();
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment