this->traverse(&finalize);
}
+// Finalize the method list for a type. This is called when a type is
+// parsed for an inlined function body, which happens after the
+// finalize_methods pass.
+
+void
+Gogo::finalize_methods_for_type(Type* type)
+{
+ Finalize_methods finalize(this);
+ Type::traverse(type, &finalize);
+}
+
// Set types for unspecified variables and constants.
void
if (c == '>')
{
// A reference to a type defined earlier.
- return this->type_for_index(index, "import data", stream->pos());
+ bool parsed;
+ return this->type_for_index(index, "import data", stream->pos(),
+ &parsed);
}
if (this->version_ >= EXPORT_FORMAT_V3)
return type;
}
-// Return the type given an index.
+// Return the type given an index. Set *PARSED if we parsed it here.
Type*
Import::type_for_index(int index, const std::string& input_name,
- size_t input_offset)
+ size_t input_offset, bool* parsed)
{
+ *parsed = false;
if (index >= 0 && !this->type_data_.empty())
{
if (static_cast<size_t>(index) >= this->type_offsets_.size())
{
if (!this->parse_type(index))
return Type::make_error_type();
+ *parsed = true;
}
}
return Type::make_error_type();
}
- return this->imp_->type_for_index(static_cast<int>(val), this->name(),
- static_cast<unsigned long>(start));
+ bool parsed;
+ Type* type = this->imp_->type_for_index(static_cast<int>(val), this->name(),
+ static_cast<unsigned long>(start),
+ &parsed);
+
+ // If we just read this type's information, its methods will not
+ // have been finalized. Do that now.
+ if (parsed)
+ this->gogo_->finalize_methods_for_type(type);
+
+ return type;
}
read_type();
// Return the type for a type index. INPUT_NAME and INPUT_OFFSET
- // are only for error reporting.
+ // are only for error reporting. PARSED is set to whether we parsed
+ // the type information for a new type.
Type*
type_for_index(int index, const std::string& input_name,
- size_t input_offset);
+ size_t input_offset, bool* parsed);
// Read an escape note.
std::string