void
do_export(Export_function_body* efb) const
- { efb->write_c_string(this->val_ ? "true" : "false"); }
+ { efb->write_c_string(this->val_ ? "$true" : "$false"); }
void
do_dump_expression(Ast_dump_context* ast_dump_context) const
Expression*
Boolean_expression::do_import(Import_expression* imp, Location loc)
{
+ if (imp->version() >= EXPORT_FORMAT_V3)
+ imp->require_c_string("$");
if (imp->peek_char() == 't')
{
imp->require_c_string("true");
void
do_export(Export_function_body* efb) const
- { efb->write_c_string("nil"); }
+ { efb->write_c_string("$nil"); }
void
do_dump_expression(Ast_dump_context* ast_dump_context) const
Expression*
Nil_expression::do_import(Import_expression* imp, Location loc)
{
+ if (imp->version() >= EXPORT_FORMAT_V3)
+ imp->require_c_string("$");
imp->require_c_string("nil");
return Expression::make_nil(loc);
}
void
Type_conversion_expression::do_export(Export_function_body* efb) const
{
- efb->write_c_string("convert(");
+ efb->write_c_string("$convert(");
efb->write_type(this->type_);
efb->write_c_string(", ");
this->expr_->export_expression(efb);
Expression*
Type_conversion_expression::do_import(Import_expression* imp, Location loc)
{
- imp->require_c_string("convert(");
+ imp->require_c_string("$convert(");
Type* type = imp->read_type();
imp->require_c_string(", ");
Expression* val = Expression::import_expression(imp, loc);
switch (this->op_)
{
case OPERATOR_PLUS:
- efb->write_c_string("+ ");
+ efb->write_c_string("+");
break;
case OPERATOR_MINUS:
- efb->write_c_string("- ");
+ efb->write_c_string("-");
break;
case OPERATOR_NOT:
- efb->write_c_string("! ");
+ efb->write_c_string("!");
break;
case OPERATOR_XOR:
- efb->write_c_string("^ ");
+ efb->write_c_string("^");
break;
case OPERATOR_AND:
case OPERATOR_MULT:
default:
go_unreachable();
}
- imp->require_c_string(" ");
+ if (imp->version() < EXPORT_FORMAT_V3)
+ imp->require_c_string(" ");
Expression* expr = Expression::import_expression(imp, loc);
return Expression::make_unary(op, expr, loc);
}
void
Struct_construction_expression::do_export(Export_function_body* efb) const
{
- efb->write_c_string("convert(");
+ efb->write_c_string("$convert(");
efb->write_type(this->type_);
for (Expression_list::const_iterator pv = this->vals()->begin();
pv != this->vals()->end();
void
Array_construction_expression::do_export(Export_function_body* efb) const
{
- efb->write_c_string("convert(");
+ efb->write_c_string("$convert(");
efb->write_type(this->type_);
if (this->vals() != NULL)
{
void
Map_construction_expression::do_export(Export_function_body* efb) const
{
- efb->write_c_string("convert(");
+ efb->write_c_string("$convert(");
efb->write_type(this->type_);
for (Expression_list::const_iterator pv = this->vals_->begin();
pv != this->vals_->end();
Expression::import_expression(Import_expression* imp, Location loc)
{
int c = imp->peek_char();
- if (imp->match_c_string("- ")
- || imp->match_c_string("! ")
- || imp->match_c_string("^ "))
+ if (c == '+' || c == '-' || c == '!' || c == '^')
return Unary_expression::do_import(imp, loc);
else if (c == '(')
return Binary_expression::do_import(imp, loc);
- else if (imp->match_c_string("true")
- || imp->match_c_string("false"))
+ else if (imp->match_c_string("$true")
+ || imp->match_c_string("$false")
+ || (imp->version() < EXPORT_FORMAT_V3
+ && (imp->match_c_string("true")
+ || imp->match_c_string("false"))))
return Boolean_expression::do_import(imp, loc);
else if (c == '"')
return String_expression::do_import(imp, loc);
// This handles integers, floats and complex constants.
return Integer_expression::do_import(imp, loc);
}
- else if (imp->match_c_string("nil"))
+ else if (imp->match_c_string("$nil")
+ || (imp->version() < EXPORT_FORMAT_V3
+ && imp->match_c_string("nil")))
return Nil_expression::do_import(imp, loc);
- else if (imp->match_c_string("convert"))
+ else if (imp->match_c_string("$convert")
+ || (imp->version() < EXPORT_FORMAT_V3
+ && imp->match_c_string("convert")))
return Type_conversion_expression::do_import(imp, loc);
else
{