exp->write_c_string("(");
const Typed_identifier* receiver = fntype->receiver();
exp->write_name(receiver->name());
+ exp->write_escape(receiver->note());
exp->write_c_string(" ");
exp->write_type(receiver->type());
exp->write_c_string(") ");
else
exp->write_c_string(", ");
exp->write_name(p->name());
+ exp->write_escape(p->note());
exp->write_c_string(" ");
if (!is_varargs || p + 1 != parameters->end())
exp->write_type(p->type());
else
exp->write_c_string(", ");
exp->write_name(p->name());
+ exp->write_escape(p->note());
exp->write_c_string(" ");
exp->write_type(p->type());
}
{
imp->require_c_string("(");
std::string name = imp->read_name();
+ std::string escape_note = imp->read_escape();
imp->require_c_string(" ");
Type* rtype = imp->read_type();
*preceiver = new Typed_identifier(name, rtype, imp->location());
+ (*preceiver)->set_note(escape_note);
imp->require_c_string(") ");
}
while (true)
{
std::string name = imp->read_name();
+ std::string escape_note = imp->read_escape();
imp->require_c_string(" ");
if (imp->match_c_string("..."))
Type* ptype = imp->read_type();
if (*is_varargs)
ptype = Type::make_array_type(ptype, NULL);
- parameters->push_back(Typed_identifier(name, ptype,
- imp->location()));
+ Typed_identifier t = Typed_identifier(name, ptype, imp->location());
+ t.set_note(escape_note);
+ parameters->push_back(t);
if (imp->peek_char() != ',')
break;
go_assert(!*is_varargs);
while (true)
{
std::string name = imp->read_name();
+ std::string note = imp->read_escape();
imp->require_c_string(" ");
Type* rtype = imp->read_type();
- results->push_back(Typed_identifier(name, rtype,
- imp->location()));
+ Typed_identifier t = Typed_identifier(name, rtype,
+ imp->location());
+ t.set_note(note);
+ results->push_back(t);
if (imp->peek_char() != ',')
break;
imp->require_c_string(", ");
return type;
}
+// Read an escape note.
+
+std::string
+Import::read_escape()
+{
+ if (this->match_c_string(" <esc:"))
+ {
+ Stream* stream = this->stream_;
+ this->require_c_string(" <esc:");
+
+ std::string escape = "esc:";
+ int c;
+ while (true)
+ {
+ c = stream->get_char();
+ if (c != 'x' && !ISXDIGIT(c))
+ break;
+ escape += c;
+ }
+
+ if (c != '>')
+ {
+ error_at(this->location(),
+ "error in import data at %d: expect %< %> or %<>%>, got %c",
+ stream->pos(), c);
+ stream->set_saw_error();
+ stream->advance(1);
+ escape = Escape_note::make_tag(Node::ESCAPE_UNKNOWN);
+ }
+ return escape;
+ }
+ else
+ return Escape_note::make_tag(Node::ESCAPE_UNKNOWN);
+}
+
+
// Register the builtin types.
void