#include "rust-path.h"
#include "rust-macro.h"
#include "rust-operators.h"
+#include <memory>
namespace Rust {
namespace AST {
{
NodeId id;
std::unique_ptr<Expr> value;
+ AnonConst () {}
+ AnonConst (const AnonConst &other)
+ {
+ id = other.id;
+ value = other.value == nullptr
+ ? nullptr
+ : std::unique_ptr<Expr> (other.value->clone_expr ());
+ }
+
+ AnonConst operator= (const AnonConst &other)
+ {
+ id = other.id;
+ value = other.value == nullptr
+ ? nullptr
+ : std::unique_ptr<Expr> (other.value->clone_expr ());
+ return *this;
+ }
};
struct InlineAsmRegOrRegClass
{
InlineAsmRegOrRegClass reg;
std::unique_ptr<Expr> expr;
+
+ In () {}
+ In (const struct In &other)
+ {
+ reg = other.reg;
+ expr = other.expr == nullptr
+ ? nullptr
+ : std::unique_ptr<Expr> (other.expr->clone_expr ());
+ }
+
+ In operator= (const struct In &other)
+ {
+ reg = other.reg;
+ expr = other.expr == nullptr
+ ? nullptr
+ : std::unique_ptr<Expr> (other.expr->clone_expr ());
+
+ return *this;
+ }
};
struct Out
InlineAsmRegOrRegClass reg;
bool late;
std::unique_ptr<Expr> expr; // can be null
+
+ Out () {}
+ Out (const struct Out &other)
+ {
+ reg = other.reg;
+ late = other.late;
+ expr = other.expr == nullptr
+ ? nullptr
+ : std::unique_ptr<Expr> (other.expr->clone_expr ());
+ }
+
+ Out operator= (const struct Out &other)
+ {
+ reg = other.reg;
+ late = other.late;
+ expr = other.expr == nullptr
+ ? nullptr
+ : std::unique_ptr<Expr> (other.expr->clone_expr ());
+ return *this;
+ }
};
struct InOut
InlineAsmRegOrRegClass reg;
bool late;
std::unique_ptr<Expr> expr; // this can't be null
+
+ InOut () {}
+ InOut (const struct InOut &other)
+ {
+ reg = other.reg;
+ late = other.late;
+ expr = other.expr == nullptr
+ ? nullptr
+ : std::unique_ptr<Expr> (other.expr->clone_expr ());
+ }
+
+ InOut operator= (const struct InOut &other)
+ {
+ reg = other.reg;
+ late = other.late;
+ expr = other.expr == nullptr
+ ? nullptr
+ : std::unique_ptr<Expr> (other.expr->clone_expr ());
+ return *this;
+ }
};
struct SplitInOut
bool late;
std::unique_ptr<Expr> in_expr;
std::unique_ptr<Expr> out_expr; // could be null
+
+ SplitInOut () {}
+ SplitInOut (const struct SplitInOut &other)
+ {
+ reg = other.reg;
+ late = other.late;
+ in_expr = other.in_expr == nullptr
+ ? nullptr
+ : std::unique_ptr<Expr> (other.in_expr->clone_expr ());
+ out_expr = other.out_expr == nullptr
+ ? nullptr
+ : std::unique_ptr<Expr> (other.out_expr->clone_expr ());
+ }
+
+ SplitInOut operator= (const struct SplitInOut &other)
+ {
+ reg = other.reg;
+ late = other.late;
+ in_expr = other.in_expr == nullptr
+ ? nullptr
+ : std::unique_ptr<Expr> (other.in_expr->clone_expr ());
+ out_expr = other.out_expr == nullptr
+ ? nullptr
+ : std::unique_ptr<Expr> (other.out_expr->clone_expr ());
+
+ return *this;
+ }
};
struct Const
struct Sym
{
std::unique_ptr<Expr> sym;
+
+ Sym () {}
+ Sym (const struct Sym &other)
+ {
+ sym = std::unique_ptr<Expr> (other.sym->clone_expr ());
+ }
+
+ Sym operator= (const struct Sym &other)
+ {
+ sym = std::unique_ptr<Expr> (other.sym->clone_expr ());
+ return *this;
+ }
};
RegisterType registerType;
struct Const cnst;
struct Sym sym;
+ InlineAsmOperand () {}
+ InlineAsmOperand (const InlineAsmOperand &other)
+ : in (other.in), out (other.out), inOut (other.inOut),
+ splitInOut (other.splitInOut), cnst (other.cnst), sym (other.sym)
+ {}
+
location_t locus;
};
};
// Inline Assembly Node
-class InlineAsm : private ExprWithoutBlock
+class InlineAsm : public ExprWithoutBlock
{
private:
location_t locus;
void set_outer_attrs (std::vector<Attribute> v) override { outer_attrs = v; }
- ExprWithoutBlock *clone_expr_without_block_impl () const override
+ InlineAsm *clone_expr_without_block_impl () const override
{
- rust_unreachable ();
- return nullptr;
+ return new InlineAsm (*this);
}
};
bool is_explicit_reg = false;
bool is_global_asm = inlineAsm.is_global_asm;
if (!is_global_asm && check_identifier (parser, "in"))
- {}
+ {
+ return tl::nullopt;
+ }
else if (!is_global_asm && check_identifier (parser, "out"))
- {}
+ {
+ return tl::nullopt;
+ }
else if (!is_global_asm && check_identifier (parser, "lateout"))
- {}
+ {
+ return tl::nullopt;
+ }
else if (!is_global_asm && check_identifier (parser, "inout"))
- {}
+ {
+ return tl::nullopt;
+ }
else if (!is_global_asm && check_identifier (parser, "inlateout"))
- {}
+ {
+ return tl::nullopt;
+ }
else if (parser.peek_current_token ()->get_id () == CONST)
{
rust_unreachable ();
// todo: Please handle const
+ return tl::nullopt;
}
else if (false && check_identifier (parser, "sym"))
{
// todo: Please handle sym
+ return tl::nullopt;
}
else if (false && check_identifier (parser, "label"))
{
// todo: Please handle label
+ return tl::nullopt;
}
else
{
// operands stream, also handles the optional ","
parse_asm_arg (parser, last_token_id, inlineAsmCtx);
- return tl::nullopt;
+ AST::SingleASTNode single
+ = AST::SingleASTNode (inlineAsmCtx.inlineAsm.clone_expr_without_block ());
+ std::vector<AST::SingleASTNode> single_vec = {single};
+
+ AST::Fragment fragment_ast
+ = AST::Fragment (single_vec, std::vector<std::unique_ptr<AST::Token>> ());
+ return fragment_ast;
}
} // namespace Rust