}
void
-TokenCollector::visit (Literal &lit, Location locus)
+TokenCollector::visit (Literal &lit, location_t locus)
{
auto value = lit.as_string ();
switch (lit.get_lit_type ())
case EQUAL: {
skip_token ();
- Location locus = peek_token ()->get_locus ();
+ location_t locus = peek_token ()->get_locus ();
Literal lit = parse_literal ();
if (lit.is_error ())
{
std::unique_ptr<MetaItemLitExpr>
AttributeParser::parse_meta_item_lit ()
{
- Location locus = peek_token ()->get_locus ();
+ location_t locus = peek_token ()->get_locus ();
LiteralExpr lit_expr (parse_literal (), {}, locus);
return std::unique_ptr<MetaItemLitExpr> (
new MetaItemLitExpr (std::move (lit_expr)));
// Token kind.
TokenId token_id;
// Token location.
- Location locus;
+ location_t locus;
// Associated text (if any) of token.
std::string str;
// Token type hint (if any).
#if 0
/* constructor from general text - avoid using if lexer const_TokenPtr is
* available */
- Token (TokenId token_id, Location locus, std::string str,
+ Token (TokenId token_id, location_t locus, std::string str,
PrimitiveCoreType type_hint)
: token_id (token_id), locus (locus), str (std::move (str)),
type_hint (type_hint)
class SimplePathSegment : public PathSegment
{
std::string segment_name;
- Location locus;
+ location_t locus;
NodeId node_id;
// only allow identifiers, "super", "self", "crate", or "$crate"
public:
// TODO: put checks in constructor to enforce this rule?
- SimplePathSegment (std::string segment_name, Location locus)
+ SimplePathSegment (std::string segment_name, location_t locus)
: segment_name (std::move (segment_name)), locus (locus),
node_id (Analysis::Mappings::get ()->get_next_node_id ())
{}
{
bool opening_scope_resolution;
std::vector<SimplePathSegment> segments;
- Location locus;
+ location_t locus;
NodeId node_id;
public:
// Constructor
SimplePath (std::vector<SimplePathSegment> path_segments,
bool has_opening_scope_resolution = false,
- Location locus = UNDEF_LOCATION)
+ location_t locus = UNDEF_LOCATION)
: opening_scope_resolution (has_opening_scope_resolution),
segments (std::move (path_segments)), locus (locus),
node_id (Analysis::Mappings::get ()->get_next_node_id ())
* ensure that this is a valid identifier in path, so be careful. Also, this
* will have no location data.
* TODO have checks? */
- static SimplePath from_str (std::string str, Location locus)
+ static SimplePath from_str (std::string str, location_t locus)
{
std::vector<AST::SimplePathSegment> single_segments
= {AST::SimplePathSegment (std::move (str), locus)};
// bool has_attr_input;
std::unique_ptr<AttrInput> attr_input;
- Location locus;
+ location_t locus;
bool inner_attribute;
// Constructor has pointer AttrInput for polymorphism reasons
Attribute (SimplePath path, std::unique_ptr<AttrInput> input,
- Location locus = UNDEF_LOCATION, bool inner_attribute = false)
+ location_t locus = UNDEF_LOCATION, bool inner_attribute = false)
: path (std::move (path)), attr_input (std::move (input)), locus (locus),
inner_attribute (inner_attribute)
{}
{
DelimType delim_type;
std::vector<std::unique_ptr<TokenTree>> token_trees;
- Location locus;
+ location_t locus;
protected:
DelimTokenTree *clone_delim_tok_tree_impl () const
DelimTokenTree (DelimType delim_type,
std::vector<std::unique_ptr<TokenTree>> token_trees
= std::vector<std::unique_ptr<TokenTree>> (),
- Location locus = UNDEF_LOCATION)
+ location_t locus = UNDEF_LOCATION)
: delim_type (delim_type), token_trees (std::move (token_trees)),
locus (locus)
{}
{
std::vector<Attribute> outer_attrs;
Identifier ident;
- Location locus;
+ location_t locus;
public:
IdentifierExpr (Identifier ident, std::vector<Attribute> outer_attrs,
- Location locus)
+ location_t locus)
: outer_attrs (std::move (outer_attrs)), ident (std::move (ident)),
locus (locus)
{}
private:
LifetimeType lifetime_type;
std::string lifetime_name;
- Location locus;
+ location_t locus;
NodeId node_id;
public:
// Constructor
Lifetime (LifetimeType type, std::string name = std::string (),
- Location locus = UNDEF_LOCATION)
+ location_t locus = UNDEF_LOCATION)
: TypeParamBound (Analysis::Mappings::get ()->get_next_node_id ()),
lifetime_type (type), lifetime_name (std::move (name)), locus (locus)
{}
Lifetime (NodeId id, LifetimeType type, std::string name = std::string (),
- Location locus = UNDEF_LOCATION)
+ location_t locus = UNDEF_LOCATION)
: TypeParamBound (id), lifetime_type (type),
lifetime_name (std::move (name)), locus (locus)
{}
Lifetime lifetime;
std::vector<Lifetime> lifetime_bounds;
Attribute outer_attr;
- Location locus;
+ location_t locus;
public:
Lifetime get_lifetime () const { return lifetime; }
// Constructor
LifetimeParam (Lifetime lifetime, std::vector<Lifetime> lifetime_bounds,
- Attribute outer_attr, Location locus)
+ Attribute outer_attr, location_t locus)
: lifetime (std::move (lifetime)),
lifetime_bounds (std::move (lifetime_bounds)),
outer_attr (std::move (outer_attr)), locus (locus)
class TraitItem : public Visitable
{
protected:
- TraitItem (Location locus)
+ TraitItem (location_t locus)
: node_id (Analysis::Mappings::get ()->get_next_node_id ()), locus (locus)
{}
virtual TraitItem *clone_trait_item_impl () const = 0;
NodeId node_id;
- Location locus;
+ location_t locus;
public:
virtual ~TraitItem () {}
{
std::vector<Attribute> outer_attrs;
Literal literal;
- Location locus;
+ location_t locus;
public:
std::string as_string () const override { return literal.as_string (); }
LiteralExpr (std::string value_as_string, Literal::LitType type,
PrimitiveCoreType type_hint, std::vector<Attribute> outer_attrs,
- Location locus)
+ location_t locus)
: outer_attrs (std::move (outer_attrs)),
literal (std::move (value_as_string), type, type_hint), locus (locus)
{}
LiteralExpr (Literal literal, std::vector<Attribute> outer_attrs,
- Location locus)
+ location_t locus)
: outer_attrs (std::move (outer_attrs)), literal (std::move (literal)),
locus (locus)
{}
{
// TODO: create binary and unary operator subclasses?
public:
- Location locus;
+ location_t locus;
protected:
/* Variables must be protected to allow derived classes to use them as first
// Constructor (only for initialisation of expr purposes)
OperatorExpr (std::unique_ptr<Expr> main_or_left_expr,
- std::vector<Attribute> outer_attribs, Location locus)
+ std::vector<Attribute> outer_attribs, location_t locus)
: locus (locus), outer_attrs (std::move (outer_attribs)),
main_or_left_expr (std::move (main_or_left_expr))
{}
BorrowExpr (std::unique_ptr<Expr> borrow_lvalue, bool is_mut_borrow,
bool is_double_borrow, std::vector<Attribute> outer_attribs,
- Location locus)
+ location_t locus)
: OperatorExpr (std::move (borrow_lvalue), std::move (outer_attribs),
locus),
is_mut (is_mut_borrow), double_borrow (is_double_borrow)
// Constructor calls OperatorExpr's protected constructor
DereferenceExpr (std::unique_ptr<Expr> deref_lvalue,
- std::vector<Attribute> outer_attribs, Location locus)
+ std::vector<Attribute> outer_attribs, location_t locus)
: OperatorExpr (std::move (deref_lvalue), std::move (outer_attribs), locus)
{}
// Constructor calls OperatorExpr's protected constructor
ErrorPropagationExpr (std::unique_ptr<Expr> potential_error_value,
- std::vector<Attribute> outer_attribs, Location locus)
+ std::vector<Attribute> outer_attribs, location_t locus)
: OperatorExpr (std::move (potential_error_value),
std::move (outer_attribs), locus)
{}
// Constructor calls OperatorExpr's protected constructor
NegationExpr (std::unique_ptr<Expr> negated_value, ExprType expr_kind,
- std::vector<Attribute> outer_attribs, Location locus)
+ std::vector<Attribute> outer_attribs, location_t locus)
: OperatorExpr (std::move (negated_value), std::move (outer_attribs),
locus),
expr_type (expr_kind)
// Constructor calls OperatorExpr's protected constructor
ArithmeticOrLogicalExpr (std::unique_ptr<Expr> left_value,
std::unique_ptr<Expr> right_value,
- ExprType expr_kind, Location locus)
+ ExprType expr_kind, location_t locus)
: OperatorExpr (std::move (left_value), std::vector<Attribute> (), locus),
expr_type (expr_kind), right_expr (std::move (right_value))
{}
// Constructor requires pointers for polymorphism
ComparisonExpr (std::unique_ptr<Expr> left_value,
std::unique_ptr<Expr> right_value, ExprType comparison_kind,
- Location locus)
+ location_t locus)
: OperatorExpr (std::move (left_value), std::vector<Attribute> (), locus),
expr_type (comparison_kind), right_expr (std::move (right_value))
{}
// Constructor calls OperatorExpr's protected constructor
LazyBooleanExpr (std::unique_ptr<Expr> left_bool_expr,
std::unique_ptr<Expr> right_bool_expr, ExprType expr_kind,
- Location locus)
+ location_t locus)
: OperatorExpr (std::move (left_bool_expr), std::vector<Attribute> (),
locus),
expr_type (expr_kind), right_expr (std::move (right_bool_expr))
// Constructor requires calling protected constructor of OperatorExpr
TypeCastExpr (std::unique_ptr<Expr> expr_to_cast,
- std::unique_ptr<TypeNoBounds> type_to_cast_to, Location locus)
+ std::unique_ptr<TypeNoBounds> type_to_cast_to, location_t locus)
: OperatorExpr (std::move (expr_to_cast), std::vector<Attribute> (), locus),
type_to_convert_to (std::move (type_to_cast_to))
{}
// Call OperatorExpr constructor to initialise left_expr
AssignmentExpr (std::unique_ptr<Expr> value_to_assign_to,
std::unique_ptr<Expr> value_to_assign,
- std::vector<Attribute> outer_attribs, Location locus)
+ std::vector<Attribute> outer_attribs, location_t locus)
: OperatorExpr (std::move (value_to_assign_to), std::move (outer_attribs),
locus),
right_expr (std::move (value_to_assign))
// Use pointers in constructor to enable polymorphism
CompoundAssignmentExpr (std::unique_ptr<Expr> value_to_assign_to,
std::unique_ptr<Expr> value_to_assign,
- ExprType expr_kind, Location locus)
+ ExprType expr_kind, location_t locus)
: OperatorExpr (std::move (value_to_assign_to), std::vector<Attribute> (),
locus),
expr_type (expr_kind), right_expr (std::move (value_to_assign))
std::vector<Attribute> outer_attrs;
std::vector<Attribute> inner_attrs;
std::unique_ptr<Expr> expr_in_parens;
- Location locus;
+ location_t locus;
public:
std::string as_string () const override;
GroupedExpr (std::unique_ptr<Expr> parenthesised_expr,
std::vector<Attribute> inner_attribs,
- std::vector<Attribute> outer_attribs, Location locus)
+ std::vector<Attribute> outer_attribs, location_t locus)
: outer_attrs (std::move (outer_attribs)),
inner_attrs (std::move (inner_attribs)),
expr_in_parens (std::move (parenthesised_expr)), locus (locus)
class ArrayElemsValues : public ArrayElems
{
std::vector<std::unique_ptr<Expr> > values;
- Location locus;
+ location_t locus;
public:
- ArrayElemsValues (std::vector<std::unique_ptr<Expr> > elems, Location locus)
+ ArrayElemsValues (std::vector<std::unique_ptr<Expr> > elems, location_t locus)
: ArrayElems (), values (std::move (elems)), locus (locus)
{}
{
std::unique_ptr<Expr> elem_to_copy;
std::unique_ptr<Expr> num_copies;
- Location locus;
+ location_t locus;
public:
// Constructor requires pointers for polymorphism
ArrayElemsCopied (std::unique_ptr<Expr> copied_elem,
- std::unique_ptr<Expr> copy_amount, Location locus)
+ std::unique_ptr<Expr> copy_amount, location_t locus)
: ArrayElems (), elem_to_copy (std::move (copied_elem)),
num_copies (std::move (copy_amount)), locus (locus)
{}
std::vector<Attribute> outer_attrs;
std::vector<Attribute> inner_attrs;
std::unique_ptr<ArrayElems> internal_elements;
- Location locus;
+ location_t locus;
// TODO: find another way to store this to save memory?
bool marked_for_strip = false;
// Constructor requires ArrayElems pointer
ArrayExpr (std::unique_ptr<ArrayElems> array_elems,
std::vector<Attribute> inner_attribs,
- std::vector<Attribute> outer_attribs, Location locus)
+ std::vector<Attribute> outer_attribs, location_t locus)
: outer_attrs (std::move (outer_attribs)),
inner_attrs (std::move (inner_attribs)),
internal_elements (std::move (array_elems)), locus (locus)
std::vector<Attribute> outer_attrs;
std::unique_ptr<Expr> array_expr;
std::unique_ptr<Expr> index_expr;
- Location locus;
+ location_t locus;
public:
std::string as_string () const override;
ArrayIndexExpr (std::unique_ptr<Expr> array_expr,
std::unique_ptr<Expr> array_index_expr,
- std::vector<Attribute> outer_attribs, Location locus)
+ std::vector<Attribute> outer_attribs, location_t locus)
: outer_attrs (std::move (outer_attribs)),
array_expr (std::move (array_expr)),
index_expr (std::move (array_index_expr)), locus (locus)
std::vector<Attribute> outer_attrs;
std::vector<Attribute> inner_attrs;
std::vector<std::unique_ptr<Expr> > tuple_elems;
- Location locus;
+ location_t locus;
// TODO: find another way to store this to save memory?
bool marked_for_strip = false;
TupleExpr (std::vector<std::unique_ptr<Expr> > tuple_elements,
std::vector<Attribute> inner_attribs,
- std::vector<Attribute> outer_attribs, Location locus)
+ std::vector<Attribute> outer_attribs, location_t locus)
: outer_attrs (std::move (outer_attribs)),
inner_attrs (std::move (inner_attribs)),
tuple_elems (std::move (tuple_elements)), locus (locus)
// TupleIndex is a decimal int literal with no underscores or suffix
TupleIndex tuple_index;
- Location locus;
+ location_t locus;
// i.e. pair.0
TupleIndex get_tuple_index () const { return tuple_index; }
TupleIndexExpr (std::unique_ptr<Expr> tuple_expr, TupleIndex index,
- std::vector<Attribute> outer_attribs, Location locus)
+ std::vector<Attribute> outer_attribs, location_t locus)
: outer_attrs (std::move (outer_attribs)),
tuple_expr (std::move (tuple_expr)), tuple_index (index), locus (locus)
{}
{
std::vector<Attribute> inner_attrs;
- Location locus;
+ location_t locus;
public:
std::string as_string () const override;
// Constructor has to call protected constructor of base class
StructExprStruct (PathInExpression struct_path,
std::vector<Attribute> inner_attribs,
- std::vector<Attribute> outer_attribs, Location locus)
+ std::vector<Attribute> outer_attribs, location_t locus)
: StructExpr (std::move (struct_path), std::move (outer_attribs)),
inner_attrs (std::move (inner_attribs)), locus (locus)
{}
{
private:
std::unique_ptr<Expr> base_struct;
- Location locus;
+ location_t locus;
public:
- StructBase (std::unique_ptr<Expr> base_struct_ptr, Location locus)
+ StructBase (std::unique_ptr<Expr> base_struct_ptr, location_t locus)
: base_struct (std::move (base_struct_ptr)), locus (locus)
{}
class StructExprFieldIdentifier : public StructExprField
{
Identifier field_name;
- Location locus;
+ location_t locus;
public:
- StructExprFieldIdentifier (Identifier field_identifier, Location locus)
+ StructExprFieldIdentifier (Identifier field_identifier, location_t locus)
: StructExprField (), field_name (std::move (field_identifier)),
locus (locus)
{}
class StructExprFieldIdentifierValue : public StructExprFieldWithVal
{
Identifier field_name;
- Location locus;
+ location_t locus;
public:
StructExprFieldIdentifierValue (Identifier field_identifier,
std::unique_ptr<Expr> field_value,
- Location locus)
+ location_t locus)
: StructExprFieldWithVal (std::move (field_value)),
field_name (std::move (field_identifier)), locus (locus)
{}
class StructExprFieldIndexValue : public StructExprFieldWithVal
{
TupleIndex index;
- Location locus;
+ location_t locus;
public:
StructExprFieldIndexValue (TupleIndex tuple_index,
- std::unique_ptr<Expr> field_value, Location locus)
+ std::unique_ptr<Expr> field_value,
+ location_t locus)
: StructExprFieldWithVal (std::move (field_value)), index (tuple_index),
locus (locus)
{}
// Constructor for StructExprStructFields when no struct base is used
StructExprStructFields (
PathInExpression struct_path,
- std::vector<std::unique_ptr<StructExprField> > expr_fields, Location locus,
- StructBase base_struct = StructBase::error (),
+ std::vector<std::unique_ptr<StructExprField> > expr_fields,
+ location_t locus, StructBase base_struct = StructBase::error (),
std::vector<Attribute> inner_attribs = std::vector<Attribute> (),
std::vector<Attribute> outer_attribs = std::vector<Attribute> ())
: StructExprStruct (std::move (struct_path), std::move (inner_attribs),
StructExprStructBase (PathInExpression struct_path, StructBase base_struct,
std::vector<Attribute> inner_attribs,
- std::vector<Attribute> outer_attribs, Location locus)
+ std::vector<Attribute> outer_attribs, location_t locus)
: StructExprStruct (std::move (struct_path), std::move (inner_attribs),
std::move (outer_attribs), locus),
struct_base (std::move (base_struct))
std::vector<Attribute> outer_attrs;
std::unique_ptr<Expr> function;
std::vector<std::unique_ptr<Expr> > params;
- Location locus;
+ location_t locus;
public:
Function *fndeclRef;
CallExpr (std::unique_ptr<Expr> function_expr,
std::vector<std::unique_ptr<Expr> > function_params,
- std::vector<Attribute> outer_attribs, Location locus)
+ std::vector<Attribute> outer_attribs, location_t locus)
: outer_attrs (std::move (outer_attribs)),
function (std::move (function_expr)),
params (std::move (function_params)), locus (locus)
std::unique_ptr<Expr> receiver;
PathExprSegment method_name;
std::vector<std::unique_ptr<Expr> > params;
- Location locus;
+ location_t locus;
public:
std::string as_string () const override;
MethodCallExpr (std::unique_ptr<Expr> call_receiver,
PathExprSegment method_path,
std::vector<std::unique_ptr<Expr> > method_params,
- std::vector<Attribute> outer_attribs, Location locus)
+ std::vector<Attribute> outer_attribs, location_t locus)
: outer_attrs (std::move (outer_attribs)),
receiver (std::move (call_receiver)),
method_name (std::move (method_path)), params (std::move (method_params)),
std::vector<Attribute> outer_attrs;
std::unique_ptr<Expr> receiver;
Identifier field;
- Location locus;
+ location_t locus;
public:
std::string as_string () const override;
FieldAccessExpr (std::unique_ptr<Expr> field_access_receiver,
Identifier field_name, std::vector<Attribute> outer_attribs,
- Location locus)
+ location_t locus)
: outer_attrs (std::move (outer_attribs)),
receiver (std::move (field_access_receiver)),
field (std::move (field_name)), locus (locus)
std::vector<Attribute> outer_attrs;
std::unique_ptr<Pattern> pattern;
std::unique_ptr<Type> type;
- Location locus;
+ location_t locus;
public:
// Returns whether the type of the parameter has been given.
bool has_outer_attrs () const { return !outer_attrs.empty (); }
// Constructor for closure parameter
- ClosureParam (std::unique_ptr<Pattern> param_pattern, Location locus,
+ ClosureParam (std::unique_ptr<Pattern> param_pattern, location_t locus,
std::unique_ptr<Type> param_type = nullptr,
std::vector<Attribute> outer_attrs = {})
: outer_attrs (std::move (outer_attrs)),
std::vector<Attribute> outer_attrs;
bool has_move;
std::vector<ClosureParam> params; // may be empty
- Location locus;
+ location_t locus;
protected:
ClosureExpr (std::vector<ClosureParam> closure_params, bool has_move,
- std::vector<Attribute> outer_attribs, Location locus)
+ std::vector<Attribute> outer_attribs, location_t locus)
: outer_attrs (std::move (outer_attribs)), has_move (has_move),
params (std::move (closure_params)), locus (locus)
{}
// Constructor for a ClosureExprInner
ClosureExprInner (std::unique_ptr<Expr> closure_inner_expr,
- std::vector<ClosureParam> closure_params, Location locus,
+ std::vector<ClosureParam> closure_params, location_t locus,
bool is_move = false,
std::vector<Attribute> outer_attribs
= std::vector<Attribute> ())
ClosureExprInnerTyped (std::unique_ptr<Type> closure_return_type,
std::unique_ptr<BlockExpr> closure_expr,
std::vector<ClosureParam> closure_params,
- Location locus, bool is_move = false,
+ location_t locus, bool is_move = false,
std::vector<Attribute> outer_attribs
= std::vector<Attribute> ())
: ClosureExpr (std::move (closure_params), is_move,
{
std::vector<Attribute> outer_attrs;
Lifetime label;
- Location locus;
+ location_t locus;
// TODO: find another way to store this to save memory?
bool marked_for_strip = false;
// Constructor for a ContinueExpr with a label.
ContinueExpr (Lifetime label, std::vector<Attribute> outer_attribs,
- Location locus)
+ location_t locus)
: outer_attrs (std::move (outer_attribs)), label (std::move (label)),
locus (locus)
{}
std::vector<Attribute> outer_attrs;
Lifetime label;
std::unique_ptr<Expr> break_expr;
- Location locus;
+ location_t locus;
// TODO: find another way to store this to save memory?
bool marked_for_strip = false;
// Constructor for a break expression
BreakExpr (Lifetime break_label, std::unique_ptr<Expr> expr_in_break,
- std::vector<Attribute> outer_attribs, Location locus)
+ std::vector<Attribute> outer_attribs, location_t locus)
: outer_attrs (std::move (outer_attribs)), label (std::move (break_label)),
break_expr (std::move (expr_in_break)), locus (locus)
{}
// Base range expression AST node object - abstract
class RangeExpr : public ExprWithoutBlock
{
- Location locus;
+ location_t locus;
protected:
// outer attributes not allowed before range expressions
- RangeExpr (Location locus) : locus (locus) {}
+ RangeExpr (location_t locus) : locus (locus) {}
public:
Location get_locus () const override final { return locus; }
std::string as_string () const override;
RangeFromToExpr (std::unique_ptr<Expr> range_from,
- std::unique_ptr<Expr> range_to, Location locus)
+ std::unique_ptr<Expr> range_to, location_t locus)
: RangeExpr (locus), from (std::move (range_from)),
to (std::move (range_to))
{}
public:
std::string as_string () const override;
- RangeFromExpr (std::unique_ptr<Expr> range_from, Location locus)
+ RangeFromExpr (std::unique_ptr<Expr> range_from, location_t locus)
: RangeExpr (locus), from (std::move (range_from))
{}
std::string as_string () const override;
// outer attributes not allowed
- RangeToExpr (std::unique_ptr<Expr> range_to, Location locus)
+ RangeToExpr (std::unique_ptr<Expr> range_to, location_t locus)
: RangeExpr (locus), to (std::move (range_to))
{}
public:
std::string as_string () const override;
- RangeFullExpr (Location locus) : RangeExpr (locus) {}
+ RangeFullExpr (location_t locus) : RangeExpr (locus) {}
// outer attributes not allowed
void accept_vis (ASTVisitor &vis) override;
std::string as_string () const override;
RangeFromToInclExpr (std::unique_ptr<Expr> range_from,
- std::unique_ptr<Expr> range_to, Location locus)
+ std::unique_ptr<Expr> range_to, location_t locus)
: RangeExpr (locus), from (std::move (range_from)),
to (std::move (range_to))
{}
public:
std::string as_string () const override;
- RangeToInclExpr (std::unique_ptr<Expr> range_to, Location locus)
+ RangeToInclExpr (std::unique_ptr<Expr> range_to, location_t locus)
: RangeExpr (locus), to (std::move (range_to))
{}
// outer attributes not allowed
{
std::vector<Attribute> outer_attrs;
std::unique_ptr<Expr> return_expr;
- Location locus;
+ location_t locus;
// TODO: find another way to store this to save memory?
bool marked_for_strip = false;
// Constructor for ReturnExpr.
ReturnExpr (std::unique_ptr<Expr> returned_expr,
- std::vector<Attribute> outer_attribs, Location locus)
+ std::vector<Attribute> outer_attribs, location_t locus)
: outer_attrs (std::move (outer_attribs)),
return_expr (std::move (returned_expr)), locus (locus)
{}
std::vector<Attribute> outer_attrs;
// Or just have it extend BlockExpr
std::unique_ptr<BlockExpr> expr;
- Location locus;
+ location_t locus;
public:
std::string as_string () const override;
UnsafeBlockExpr (std::unique_ptr<BlockExpr> block_expr,
- std::vector<Attribute> outer_attribs, Location locus)
+ std::vector<Attribute> outer_attribs, location_t locus)
: outer_attrs (std::move (outer_attribs)), expr (std::move (block_expr)),
locus (locus)
{}
class LoopLabel /*: public Node*/
{
Lifetime label; // or type LIFETIME_OR_LABEL
- Location locus;
+ location_t locus;
NodeId node_id;
public:
std::string as_string () const;
- LoopLabel (Lifetime loop_label, Location locus = UNDEF_LOCATION)
+ LoopLabel (Lifetime loop_label, location_t locus = UNDEF_LOCATION)
: label (std::move (loop_label)), locus (locus),
node_id (Analysis::Mappings::get ()->get_next_node_id ())
{}
std::unique_ptr<BlockExpr> loop_block;
private:
- Location locus;
+ location_t locus;
protected:
// Constructor for BaseLoopExpr
- BaseLoopExpr (std::unique_ptr<BlockExpr> loop_block, Location locus,
+ BaseLoopExpr (std::unique_ptr<BlockExpr> loop_block, location_t locus,
LoopLabel loop_label = LoopLabel::error (),
std::vector<Attribute> outer_attribs
= std::vector<Attribute> ())
std::string as_string () const override;
// Constructor for LoopExpr
- LoopExpr (std::unique_ptr<BlockExpr> loop_block, Location locus,
+ LoopExpr (std::unique_ptr<BlockExpr> loop_block, location_t locus,
LoopLabel loop_label = LoopLabel::error (),
std::vector<Attribute> outer_attribs = std::vector<Attribute> ())
: BaseLoopExpr (std::move (loop_block), locus, std::move (loop_label),
// Constructor for while loop with loop label
WhileLoopExpr (std::unique_ptr<Expr> loop_condition,
- std::unique_ptr<BlockExpr> loop_block, Location locus,
+ std::unique_ptr<BlockExpr> loop_block, location_t locus,
LoopLabel loop_label = LoopLabel::error (),
std::vector<Attribute> outer_attribs
= std::vector<Attribute> ())
// Constructor with a loop label
WhileLetLoopExpr (std::vector<std::unique_ptr<Pattern> > match_arm_patterns,
std::unique_ptr<Expr> scrutinee,
- std::unique_ptr<BlockExpr> loop_block, Location locus,
+ std::unique_ptr<BlockExpr> loop_block, location_t locus,
LoopLabel loop_label = LoopLabel::error (),
std::vector<Attribute> outer_attribs
= std::vector<Attribute> ())
// Constructor with loop label
ForLoopExpr (std::unique_ptr<Pattern> loop_pattern,
std::unique_ptr<Expr> iterator_expr,
- std::unique_ptr<BlockExpr> loop_body, Location locus,
+ std::unique_ptr<BlockExpr> loop_body, location_t locus,
LoopLabel loop_label = LoopLabel::error (),
std::vector<Attribute> outer_attribs = std::vector<Attribute> ())
: BaseLoopExpr (std::move (loop_body), locus, std::move (loop_label),
std::vector<Attribute> outer_attrs;
std::unique_ptr<Expr> condition;
std::unique_ptr<BlockExpr> if_block;
- Location locus;
+ location_t locus;
public:
std::string as_string () const override;
IfExpr (std::unique_ptr<Expr> condition, std::unique_ptr<BlockExpr> if_block,
- std::vector<Attribute> outer_attrs, Location locus)
+ std::vector<Attribute> outer_attrs, location_t locus)
: outer_attrs (std::move (outer_attrs)), condition (std::move (condition)),
if_block (std::move (if_block)), locus (locus)
{}
IfExprConseqElse (std::unique_ptr<Expr> condition,
std::unique_ptr<BlockExpr> if_block,
std::unique_ptr<ExprWithBlock> else_block,
- std::vector<Attribute> outer_attrs, Location locus)
+ std::vector<Attribute> outer_attrs, location_t locus)
: IfExpr (std::move (condition), std::move (if_block),
std::move (outer_attrs), locus),
else_block (std::move (else_block))
std::vector<std::unique_ptr<Pattern> > match_arm_patterns; // inlined
std::unique_ptr<Expr> value;
std::unique_ptr<BlockExpr> if_block;
- Location locus;
+ location_t locus;
public:
std::string as_string () const override;
IfLetExpr (std::vector<std::unique_ptr<Pattern> > match_arm_patterns,
std::unique_ptr<Expr> value, std::unique_ptr<BlockExpr> if_block,
- std::vector<Attribute> outer_attrs, Location locus)
+ std::vector<Attribute> outer_attrs, location_t locus)
: outer_attrs (std::move (outer_attrs)),
match_arm_patterns (std::move (match_arm_patterns)),
value (std::move (value)), if_block (std::move (if_block)), locus (locus)
std::vector<std::unique_ptr<Pattern> > match_arm_patterns,
std::unique_ptr<Expr> value, std::unique_ptr<BlockExpr> if_block,
std::unique_ptr<ExprWithBlock> else_block,
- std::vector<Attribute> outer_attrs, Location locus)
+ std::vector<Attribute> outer_attrs, location_t locus)
: IfLetExpr (std::move (match_arm_patterns), std::move (value),
std::move (if_block), std::move (outer_attrs), locus),
else_block (std::move (else_block))
// inlined from MatchArmGuard
std::unique_ptr<Expr> guard_expr;
- Location locus;
+ location_t locus;
public:
// Returns whether the MatchArm has a match arm guard expression
// Constructor for match arm with a guard expression
MatchArm (std::vector<std::unique_ptr<Pattern> > match_arm_patterns,
- Location locus, std::unique_ptr<Expr> guard_expr = nullptr,
+ location_t locus, std::unique_ptr<Expr> guard_expr = nullptr,
std::vector<Attribute> outer_attrs = std::vector<Attribute> ())
: outer_attrs (std::move (outer_attrs)),
match_arm_patterns (std::move (match_arm_patterns)),
// Creates a match arm in an error state.
static MatchArm create_error ()
{
- Location locus = UNDEF_LOCATION;
+ location_t locus = UNDEF_LOCATION;
return MatchArm (std::vector<std::unique_ptr<Pattern> > (), locus);
}
std::unique_ptr<Expr> branch_value;
std::vector<Attribute> inner_attrs;
std::vector<MatchCase> match_arms;
- Location locus;
+ location_t locus;
public:
std::string as_string () const override;
MatchExpr (std::unique_ptr<Expr> branch_value,
std::vector<MatchCase> match_arms,
std::vector<Attribute> inner_attrs,
- std::vector<Attribute> outer_attrs, Location locus)
+ std::vector<Attribute> outer_attrs, location_t locus)
: outer_attrs (std::move (outer_attrs)),
branch_value (std::move (branch_value)),
inner_attrs (std::move (inner_attrs)),
{
std::vector<Attribute> outer_attrs;
std::unique_ptr<Expr> awaited_expr;
- Location locus;
+ location_t locus;
public:
// TODO: ensure outer attributes are actually allowed
AwaitExpr (std::unique_ptr<Expr> awaited_expr,
- std::vector<Attribute> outer_attrs, Location locus)
+ std::vector<Attribute> outer_attrs, location_t locus)
: outer_attrs (std::move (outer_attrs)),
awaited_expr (std::move (awaited_expr)), locus (locus)
{}
std::vector<Attribute> outer_attrs;
bool has_move;
std::unique_ptr<BlockExpr> block_expr;
- Location locus;
+ location_t locus;
public:
AsyncBlockExpr (std::unique_ptr<BlockExpr> block_expr, bool has_move,
- std::vector<Attribute> outer_attrs, Location locus)
+ std::vector<Attribute> outer_attrs, location_t locus)
: outer_attrs (std::move (outer_attrs)), has_move (has_move),
block_expr (std::move (block_expr)), locus (locus)
{}
};
Identifier name;
- Location locus;
+ location_t locus;
};
struct InlineAsmOperand
{
std::unique_ptr<Expr> sym;
};
- Location locus;
+ location_t locus;
};
struct InlineAsmPlaceHolder
{
size_t operand_idx;
char modifier; // can be null
- Location locus;
+ location_t locus;
};
struct InlineAsmTemplatePiece
// bool has_type;
std::unique_ptr<Type> type;
- Location locus;
+ location_t locus;
public:
Identifier get_type_representation () const { return type_representation; }
// Returns whether the type param has an outer attribute.
bool has_outer_attribute () const { return !outer_attr.is_empty (); }
- TypeParam (Identifier type_representation, Location locus = UNDEF_LOCATION,
+ TypeParam (Identifier type_representation, location_t locus = UNDEF_LOCATION,
std::vector<std::unique_ptr<TypeParamBound>> type_param_bounds
= std::vector<std::unique_ptr<TypeParamBound>> (),
std::unique_ptr<Type> type = nullptr,
{
Lifetime lifetime;
std::vector<Lifetime> lifetime_bounds;
- Location locus;
+ location_t locus;
NodeId node_id;
public:
LifetimeWhereClauseItem (Lifetime lifetime,
std::vector<Lifetime> lifetime_bounds,
- Location locus)
+ location_t locus)
: lifetime (std::move (lifetime)),
lifetime_bounds (std::move (lifetime_bounds)), locus (locus),
node_id (Analysis::Mappings::get ()->get_next_node_id ())
std::unique_ptr<Type> bound_type;
std::vector<std::unique_ptr<TypeParamBound>> type_param_bounds;
NodeId node_id;
- Location locus;
+ location_t locus;
public:
// Returns whether the item has ForLifetimes
TypeBoundWhereClauseItem (
std::vector<LifetimeParam> for_lifetimes, std::unique_ptr<Type> bound_type,
std::vector<std::unique_ptr<TypeParamBound>> type_param_bounds,
- Location locus)
+ location_t locus)
: for_lifetimes (std::move (for_lifetimes)),
bound_type (std::move (bound_type)),
type_param_bounds (std::move (type_param_bounds)),
NodeId node_id;
- Location locus;
+ location_t locus;
// Unrestricted constructor used for error state
SelfParam (Lifetime lifetime, bool has_ref, bool is_mut, Type *type)
}
// Type-based self parameter (not ref, no lifetime)
- SelfParam (std::unique_ptr<Type> type, bool is_mut, Location locus)
+ SelfParam (std::unique_ptr<Type> type, bool is_mut, location_t locus)
: has_ref (false), is_mut (is_mut), lifetime (Lifetime::error ()),
type (std::move (type)),
node_id (Analysis::Mappings::get ()->get_next_node_id ()), locus (locus)
{}
// Lifetime-based self parameter (is ref, no type)
- SelfParam (Lifetime lifetime, bool is_mut, Location locus)
+ SelfParam (Lifetime lifetime, bool is_mut, location_t locus)
: has_ref (true), is_mut (is_mut), lifetime (std::move (lifetime)),
node_id (Analysis::Mappings::get ()->get_next_node_id ()), locus (locus)
{}
bool has_unsafe;
bool has_extern;
std::string extern_abi;
- Location locus;
+ location_t locus;
public:
- FunctionQualifiers (Location locus, AsyncConstStatus const_status,
+ FunctionQualifiers (location_t locus, AsyncConstStatus const_status,
bool has_unsafe, bool has_extern = false,
std::string extern_abi = std::string ())
: const_status (const_status), has_unsafe (has_unsafe),
class FunctionParam
{
std::vector<Attribute> outer_attrs;
- Location locus;
+ location_t locus;
std::unique_ptr<Pattern> param_name;
std::unique_ptr<Type> type;
public:
FunctionParam (std::unique_ptr<Pattern> param_name,
std::unique_ptr<Type> param_type,
- std::vector<Attribute> outer_attrs, Location locus)
+ std::vector<Attribute> outer_attrs, location_t locus)
: outer_attrs (std::move (outer_attrs)), locus (locus),
param_name (std::move (param_name)), type (std::move (param_type)),
node_id (Analysis::Mappings::get ()->get_next_node_id ())
VisType vis_type;
// Only assigned if vis_type is IN_PATH
SimplePath in_path;
- Location locus;
+ location_t locus;
// should this store location info?
public:
// Creates a Visibility - TODO make constructor protected or private?
- Visibility (VisType vis_type, SimplePath in_path, Location locus)
+ Visibility (VisType vis_type, SimplePath in_path, location_t locus)
: vis_type (vis_type), in_path (std::move (in_path)), locus (locus)
{}
std::unique_ptr<Type> return_type;
WhereClause where_clause;
std::unique_ptr<BlockExpr> function_body;
- Location locus;
+ location_t locus;
NodeId node_id;
bool is_default;
SelfParam self_param, std::vector<FunctionParam> function_params,
std::unique_ptr<Type> return_type, WhereClause where_clause,
std::unique_ptr<BlockExpr> function_body, Visibility vis,
- std::vector<Attribute> outer_attrs, Location locus,
+ std::vector<Attribute> outer_attrs, location_t locus,
bool is_default = false)
: outer_attrs (std::move (outer_attrs)), vis (std::move (vis)),
qualifiers (std::move (qualifiers)),
private:
Identifier module_name;
- Location locus;
+ location_t locus;
ModuleKind kind;
// Name of the file including the module
// Unloaded module constructor
Module (Identifier module_name, Visibility visibility,
- std::vector<Attribute> outer_attrs, Location locus,
+ std::vector<Attribute> outer_attrs, location_t locus,
std::string outer_filename, std::vector<std::string> module_scope)
: VisItem (std::move (visibility), std::move (outer_attrs)),
module_name (module_name), locus (locus), kind (ModuleKind::UNLOADED),
{}
// Loaded module constructor, with items
- Module (Identifier name, Location locus,
+ Module (Identifier name, location_t locus,
std::vector<std::unique_ptr<Item>> items,
Visibility visibility = Visibility::create_error (),
std::vector<Attribute> inner_attrs = std::vector<Attribute> (),
// this is either an identifier or "_", with _ parsed to string
std::string as_clause_name;
- Location locus;
+ location_t locus;
/* e.g.
"extern crate foo as _"
// Constructor
ExternCrate (std::string referenced_crate, Visibility visibility,
- std::vector<Attribute> outer_attrs, Location locus,
+ std::vector<Attribute> outer_attrs, location_t locus,
std::string as_clause_name = std::string ())
: VisItem (std::move (visibility), std::move (outer_attrs)),
referenced_crate (std::move (referenced_crate)),
// The path-ish thing referred to in a use declaration - abstract base class
class UseTree
{
- Location locus;
+ location_t locus;
public:
enum Kind
// Clone function implementation as pure virtual method
virtual UseTree *clone_use_tree_impl () const = 0;
- UseTree (Location locus) : locus (locus) {}
+ UseTree (location_t locus) : locus (locus) {}
};
// Use tree with a glob (wildcard) operator
SimplePath path;
public:
- UseTreeGlob (PathType glob_type, SimplePath path, Location locus)
+ UseTreeGlob (PathType glob_type, SimplePath path, location_t locus)
: UseTree (locus), glob_type (glob_type), path (std::move (path))
{
if (this->glob_type != PATH_PREFIXED)
public:
UseTreeList (PathType path_type, SimplePath path,
- std::vector<std::unique_ptr<UseTree>> trees, Location locus)
+ std::vector<std::unique_ptr<UseTree>> trees, location_t locus)
: UseTree (locus), path_type (path_type), path (std::move (path)),
trees (std::move (trees))
{
Identifier identifier; // only if NewBindType is IDENTIFIER
public:
- UseTreeRebind (NewBindType bind_type, SimplePath path, Location locus,
+ UseTreeRebind (NewBindType bind_type, SimplePath path, location_t locus,
Identifier identifier = std::string ())
: UseTree (locus), path (std::move (path)), bind_type (bind_type),
identifier (std::move (identifier))
class UseDeclaration : public VisItem
{
std::unique_ptr<UseTree> use_tree;
- Location locus;
+ location_t locus;
public:
std::string as_string () const override;
UseDeclaration (std::unique_ptr<UseTree> use_tree, Visibility visibility,
- std::vector<Attribute> outer_attrs, Location locus)
+ std::vector<Attribute> outer_attrs, location_t locus)
: VisItem (std::move (visibility), std::move (outer_attrs)),
use_tree (std::move (use_tree)), locus (locus)
{}
std::unique_ptr<Type> return_type;
WhereClause where_clause;
std::unique_ptr<BlockExpr> function_body;
- Location locus;
+ location_t locus;
bool is_default;
public:
std::vector<FunctionParam> function_params,
std::unique_ptr<Type> return_type, WhereClause where_clause,
std::unique_ptr<BlockExpr> function_body, Visibility vis,
- std::vector<Attribute> outer_attrs, Location locus,
+ std::vector<Attribute> outer_attrs, location_t locus,
bool is_default = false)
: VisItem (std::move (vis), std::move (outer_attrs)),
qualifiers (std::move (qualifiers)),
std::unique_ptr<Type> existing_type;
- Location locus;
+ location_t locus;
public:
std::string as_string () const override;
TypeAlias (Identifier new_type_name,
std::vector<std::unique_ptr<GenericParam>> generic_params,
WhereClause where_clause, std::unique_ptr<Type> existing_type,
- Visibility vis, std::vector<Attribute> outer_attrs, Location locus)
+ Visibility vis, std::vector<Attribute> outer_attrs,
+ location_t locus)
: VisItem (std::move (vis), std::move (outer_attrs)),
new_type_name (std::move (new_type_name)),
generic_params (std::move (generic_params)),
WhereClause where_clause;
private:
- Location locus;
+ location_t locus;
public:
// Returns whether struct has generic parameters.
protected:
Struct (Identifier struct_name,
std::vector<std::unique_ptr<GenericParam>> generic_params,
- WhereClause where_clause, Visibility vis, Location locus,
+ WhereClause where_clause, Visibility vis, location_t locus,
std::vector<Attribute> outer_attrs = std::vector<Attribute> ())
: VisItem (std::move (vis), std::move (outer_attrs)),
struct_name (std::move (struct_name)),
NodeId node_id;
- Location locus;
+ location_t locus;
public:
// Returns whether struct field has any outer attributes.
bool has_visibility () const { return !visibility.is_error (); }
StructField (Identifier field_name, std::unique_ptr<Type> field_type,
- Visibility vis, Location locus,
+ Visibility vis, location_t locus,
std::vector<Attribute> outer_attrs = std::vector<Attribute> ())
: outer_attrs (std::move (outer_attrs)), visibility (std::move (vis)),
field_name (std::move (field_name)), field_type (std::move (field_type)),
StructStruct (std::vector<StructField> fields, Identifier struct_name,
std::vector<std::unique_ptr<GenericParam>> generic_params,
WhereClause where_clause, bool is_unit, Visibility vis,
- std::vector<Attribute> outer_attrs, Location locus)
+ std::vector<Attribute> outer_attrs, location_t locus)
: Struct (std::move (struct_name), std::move (generic_params),
std::move (where_clause), std::move (vis), locus,
std::move (outer_attrs)),
StructStruct (Identifier struct_name,
std::vector<std::unique_ptr<GenericParam>> generic_params,
WhereClause where_clause, Visibility vis,
- std::vector<Attribute> outer_attrs, Location locus)
+ std::vector<Attribute> outer_attrs, location_t locus)
: Struct (std::move (struct_name), std::move (generic_params),
std::move (where_clause), std::move (vis), locus,
std::move (outer_attrs)),
NodeId node_id;
- Location locus;
+ location_t locus;
public:
// Returns whether tuple field has outer attributes.
bool has_visibility () const { return !visibility.is_error (); }
// Complete constructor
- TupleField (std::unique_ptr<Type> field_type, Visibility vis, Location locus,
+ TupleField (std::unique_ptr<Type> field_type, Visibility vis,
+ location_t locus,
std::vector<Attribute> outer_attrs = std::vector<Attribute> ())
: outer_attrs (std::move (outer_attrs)), visibility (std::move (vis)),
field_type (std::move (field_type)),
TupleStruct (std::vector<TupleField> fields, Identifier struct_name,
std::vector<std::unique_ptr<GenericParam>> generic_params,
WhereClause where_clause, Visibility vis,
- std::vector<Attribute> outer_attrs, Location locus)
+ std::vector<Attribute> outer_attrs, location_t locus)
: Struct (std::move (struct_name), std::move (generic_params),
std::move (where_clause), std::move (vis), locus,
std::move (outer_attrs)),
{
Identifier variant_name;
- Location locus;
+ location_t locus;
public:
virtual ~EnumItem () {}
EnumItem (Identifier variant_name, Visibility vis,
- std::vector<Attribute> outer_attrs, Location locus)
+ std::vector<Attribute> outer_attrs, location_t locus)
: VisItem (std::move (vis), std::move (outer_attrs)),
variant_name (std::move (variant_name)), locus (locus)
{}
EnumItemTuple (Identifier variant_name, Visibility vis,
std::vector<TupleField> tuple_fields,
- std::vector<Attribute> outer_attrs, Location locus)
+ std::vector<Attribute> outer_attrs, location_t locus)
: EnumItem (std::move (variant_name), std::move (vis),
std::move (outer_attrs), locus),
tuple_fields (std::move (tuple_fields))
EnumItemStruct (Identifier variant_name, Visibility vis,
std::vector<StructField> struct_fields,
- std::vector<Attribute> outer_attrs, Location locus)
+ std::vector<Attribute> outer_attrs, location_t locus)
: EnumItem (std::move (variant_name), std::move (vis),
std::move (outer_attrs), locus),
struct_fields (std::move (struct_fields))
public:
EnumItemDiscriminant (Identifier variant_name, Visibility vis,
std::unique_ptr<Expr> expr,
- std::vector<Attribute> outer_attrs, Location locus)
+ std::vector<Attribute> outer_attrs, location_t locus)
: EnumItem (std::move (variant_name), std::move (vis),
std::move (outer_attrs), locus),
expression (std::move (expr))
std::vector<std::unique_ptr<EnumItem>> items;
- Location locus;
+ location_t locus;
public:
std::string as_string () const override;
Enum (Identifier enum_name, Visibility vis,
std::vector<std::unique_ptr<GenericParam>> generic_params,
WhereClause where_clause, std::vector<std::unique_ptr<EnumItem>> items,
- std::vector<Attribute> outer_attrs, Location locus)
+ std::vector<Attribute> outer_attrs, location_t locus)
: VisItem (std::move (vis), std::move (outer_attrs)),
enum_name (std::move (enum_name)),
generic_params (std::move (generic_params)),
std::vector<StructField> variants;
- Location locus;
+ location_t locus;
public:
std::string as_string () const override;
Union (Identifier union_name, Visibility vis,
std::vector<std::unique_ptr<GenericParam>> generic_params,
WhereClause where_clause, std::vector<StructField> variants,
- std::vector<Attribute> outer_attrs, Location locus)
+ std::vector<Attribute> outer_attrs, location_t locus)
: VisItem (std::move (vis), std::move (outer_attrs)),
union_name (std::move (union_name)),
generic_params (std::move (generic_params)),
std::unique_ptr<Type> type;
std::unique_ptr<Expr> const_expr;
- Location locus;
+ location_t locus;
public:
std::string as_string () const override;
ConstantItem (std::string ident, Visibility vis, std::unique_ptr<Type> type,
std::unique_ptr<Expr> const_expr,
- std::vector<Attribute> outer_attrs, Location locus)
+ std::vector<Attribute> outer_attrs, location_t locus)
: VisItem (std::move (vis), std::move (outer_attrs)),
identifier (std::move (ident)), type (std::move (type)),
const_expr (std::move (const_expr)), locus (locus)
Identifier name;
std::unique_ptr<Type> type;
std::unique_ptr<Expr> expr;
- Location locus;
+ location_t locus;
public:
std::string as_string () const override;
StaticItem (Identifier name, bool is_mut, std::unique_ptr<Type> type,
std::unique_ptr<Expr> expr, Visibility vis,
- std::vector<Attribute> outer_attrs, Location locus)
+ std::vector<Attribute> outer_attrs, location_t locus)
: VisItem (std::move (vis), std::move (outer_attrs)), has_mut (is_mut),
name (std::move (name)), type (std::move (type)), expr (std::move (expr)),
locus (locus)
bool has_definition () const { return block_expr != nullptr; }
TraitItemFunc (TraitFunctionDecl decl, std::unique_ptr<BlockExpr> block_expr,
- std::vector<Attribute> outer_attrs, Location locus)
+ std::vector<Attribute> outer_attrs, location_t locus)
: TraitItem (locus), outer_attrs (std::move (outer_attrs)),
decl (std::move (decl)), block_expr (std::move (block_expr))
{}
bool has_definition () const { return block_expr != nullptr; }
TraitItemMethod (TraitMethodDecl decl, std::unique_ptr<BlockExpr> block_expr,
- std::vector<Attribute> outer_attrs, Location locus)
+ std::vector<Attribute> outer_attrs, location_t locus)
: TraitItem (locus), outer_attrs (std::move (outer_attrs)),
decl (std::move (decl)), block_expr (std::move (block_expr))
{}
TraitItemConst (Identifier name, std::unique_ptr<Type> type,
std::unique_ptr<Expr> expr,
- std::vector<Attribute> outer_attrs, Location locus)
+ std::vector<Attribute> outer_attrs, location_t locus)
: TraitItem (locus), outer_attrs (std::move (outer_attrs)),
name (std::move (name)), type (std::move (type)), expr (std::move (expr))
{}
TraitItemType (Identifier name,
std::vector<std::unique_ptr<TypeParamBound>> type_param_bounds,
- std::vector<Attribute> outer_attrs, Location locus)
+ std::vector<Attribute> outer_attrs, location_t locus)
: TraitItem (locus), outer_attrs (std::move (outer_attrs)),
name (std::move (name)), type_param_bounds (std::move (type_param_bounds))
{}
WhereClause where_clause;
std::vector<Attribute> inner_attrs;
std::vector<std::unique_ptr<TraitItem>> trait_items;
- Location locus;
+ location_t locus;
public:
std::string as_string () const override;
WhereClause where_clause,
std::vector<std::unique_ptr<TraitItem>> trait_items, Visibility vis,
std::vector<Attribute> outer_attrs, std::vector<Attribute> inner_attrs,
- Location locus)
+ location_t locus)
: VisItem (std::move (vis), std::move (outer_attrs)),
has_unsafe (is_unsafe), has_auto (is_auto), name (std::move (name)),
generic_params (std::move (generic_params)),
private:
// doesn't really need to be protected as write access probably not needed
- Location locus;
+ location_t locus;
public:
// Returns whether impl has generic parameters.
Impl (std::vector<std::unique_ptr<GenericParam>> generic_params,
std::unique_ptr<Type> trait_type, WhereClause where_clause,
Visibility vis, std::vector<Attribute> inner_attrs,
- std::vector<Attribute> outer_attrs, Location locus)
+ std::vector<Attribute> outer_attrs, location_t locus)
: VisItem (std::move (vis), std::move (outer_attrs)),
generic_params (std::move (generic_params)),
trait_type (std::move (trait_type)),
std::vector<std::unique_ptr<GenericParam>> generic_params,
std::unique_ptr<Type> trait_type, WhereClause where_clause,
Visibility vis, std::vector<Attribute> inner_attrs,
- std::vector<Attribute> outer_attrs, Location locus)
+ std::vector<Attribute> outer_attrs, location_t locus)
: Impl (std::move (generic_params), std::move (trait_type),
std::move (where_clause), std::move (vis), std::move (inner_attrs),
std::move (outer_attrs), locus),
std::vector<std::unique_ptr<GenericParam>> generic_params,
std::unique_ptr<Type> trait_type, WhereClause where_clause,
Visibility vis, std::vector<Attribute> inner_attrs,
- std::vector<Attribute> outer_attrs, Location locus)
+ std::vector<Attribute> outer_attrs, location_t locus)
: Impl (std::move (generic_params), std::move (trait_type),
std::move (where_clause), std::move (vis), std::move (inner_attrs),
std::move (outer_attrs), locus),
Visibility visibility;
Identifier item_name;
- Location locus;
+ location_t locus;
public:
virtual ~ExternalItem () {}
protected:
ExternalItem (Identifier item_name, Visibility vis,
- std::vector<Attribute> outer_attrs, Location locus)
+ std::vector<Attribute> outer_attrs, location_t locus)
: outer_attrs (std::move (outer_attrs)), visibility (std::move (vis)),
item_name (std::move (item_name)), locus (locus)
{}
Visibility visibility;
Identifier item_name;
- Location locus;
+ location_t locus;
bool marked_for_strip;
public:
ExternalTypeItem (Identifier item_name, Visibility vis,
- std::vector<Attribute> outer_attrs, Location locus)
+ std::vector<Attribute> outer_attrs, location_t locus)
: ExternalItem (), outer_attrs (std::move (outer_attrs)), visibility (vis),
item_name (std::move (item_name)), locus (locus), marked_for_strip (false)
{}
Visibility visibility;
Identifier item_name;
- Location locus;
+ location_t locus;
bool has_mut;
std::unique_ptr<Type> item_type;
public:
ExternalStaticItem (Identifier item_name, std::unique_ptr<Type> item_type,
bool is_mut, Visibility vis,
- std::vector<Attribute> outer_attrs, Location locus)
+ std::vector<Attribute> outer_attrs, location_t locus)
: ExternalItem (), outer_attrs (std::move (outer_attrs)),
visibility (std::move (vis)), item_name (std::move (item_name)),
locus (locus), has_mut (is_mut), item_type (std::move (item_type))
std::vector<Attribute> outer_attrs;
NodeId node_id;
- Location locus;
+ location_t locus;
public:
/* Returns whether the named function parameter has a name (i.e. name is not
}
NamedFunctionParam (std::string name, std::unique_ptr<Type> param_type,
- std::vector<Attribute> outer_attrs, Location locus)
+ std::vector<Attribute> outer_attrs, location_t locus)
: name (std::move (name)), param_type (std::move (param_type)),
outer_attrs (std::move (outer_attrs)),
node_id (Analysis::Mappings::get ()->get_next_node_id ()), locus (locus)
Visibility visibility;
Identifier item_name;
- Location locus;
+ location_t locus;
// bool has_generics;
// Generics generic_params;
std::unique_ptr<Type> return_type, WhereClause where_clause,
std::vector<NamedFunctionParam> function_params, bool has_variadics,
std::vector<Attribute> variadic_outer_attrs, Visibility vis,
- std::vector<Attribute> outer_attrs, Location locus)
+ std::vector<Attribute> outer_attrs, location_t locus)
: ExternalItem (), outer_attrs (std::move (outer_attrs)),
visibility (std::move (vis)), item_name (std::move (item_name)),
locus (locus), generic_params (std::move (generic_params)),
// bool has_extern_items;
std::vector<std::unique_ptr<ExternalItem>> extern_items;
- Location locus;
+ location_t locus;
// TODO: find another way to store this to save memory?
bool marked_for_strip = false;
ExternBlock (std::string abi,
std::vector<std::unique_ptr<ExternalItem>> extern_items,
Visibility vis, std::vector<Attribute> inner_attrs,
- std::vector<Attribute> outer_attrs, Location locus)
+ std::vector<Attribute> outer_attrs, location_t locus)
: VisItem (std::move (vis), std::move (outer_attrs)), abi (std::move (abi)),
inner_attrs (std::move (inner_attrs)),
extern_items (std::move (extern_items)), locus (locus)
{
Identifier ident;
MacroFragSpec frag_spec;
- Location locus;
+ location_t locus;
public:
- MacroMatchFragment (Identifier ident, MacroFragSpec frag_spec, Location locus)
+ MacroMatchFragment (Identifier ident, MacroFragSpec frag_spec,
+ location_t locus)
: ident (std::move (ident)), frag_spec (frag_spec), locus (locus)
{}
}
// Creates an error state macro match fragment.
- static MacroMatchFragment create_error (Location locus)
+ static MacroMatchFragment create_error (location_t locus)
{
return MacroMatchFragment (std::string (""),
MacroFragSpec (MacroFragSpec::Kind::INVALID),
typedef Token MacroRepSep;
// any token except delimiters and repetition operators
std::unique_ptr<MacroRepSep> sep;
- Location locus;
+ location_t locus;
public:
// Returns whether macro match repetition has separator token.
MacroMatchRepetition (std::vector<std::unique_ptr<MacroMatch>> matches,
MacroRepOp op, std::unique_ptr<MacroRepSep> sep,
- Location locus)
+ location_t locus)
: matches (std::move (matches)), op (op), sep (std::move (sep)),
locus (locus)
{}
{
DelimType delim_type;
std::vector<std::unique_ptr<MacroMatch>> matches;
- Location locus;
+ location_t locus;
// TODO: think of way to mark invalid that doesn't take up more space
bool is_invalid;
public:
MacroMatcher (DelimType delim_type,
std::vector<std::unique_ptr<MacroMatch>> matches,
- Location locus)
+ location_t locus)
: delim_type (delim_type), matches (std::move (matches)), locus (locus),
is_invalid (false)
{}
MacroMatcher &operator= (MacroMatcher &&other) = default;
// Creates an error state macro matcher.
- static MacroMatcher create_error (Location locus)
+ static MacroMatcher create_error (location_t locus)
{
return MacroMatcher (true, locus);
}
}
// constructor only used to create error matcher
- MacroMatcher (bool is_invalid, Location locus)
+ MacroMatcher (bool is_invalid, location_t locus)
: delim_type (PARENS), locus (locus), is_invalid (is_invalid)
{}
};
{
private:
DelimTokenTree token_tree;
- Location locus;
+ location_t locus;
public:
- MacroTranscriber (DelimTokenTree token_tree, Location locus)
+ MacroTranscriber (DelimTokenTree token_tree, location_t locus)
: token_tree (std::move (token_tree)), locus (locus)
{}
private:
MacroMatcher matcher;
MacroTranscriber transcriber;
- Location locus;
+ location_t locus;
public:
- MacroRule (MacroMatcher matcher, MacroTranscriber transcriber, Location locus)
+ MacroRule (MacroMatcher matcher, MacroTranscriber transcriber,
+ location_t locus)
: matcher (std::move (matcher)), transcriber (std::move (transcriber)),
locus (locus)
{}
bool is_error () const { return matcher.is_error (); }
// Creates an error state macro rule.
- static MacroRule create_error (Location locus)
+ static MacroRule create_error (location_t locus)
{
return MacroRule (MacroMatcher::create_error (locus),
MacroTranscriber (DelimTokenTree::create_empty (),
DelimType delim_type;
// MacroRules rules;
std::vector<MacroRule> rules; // inlined form
- Location locus;
+ location_t locus;
std::function<Fragment (Location, MacroInvocData &)> associated_transcriber;
// Since we can't compare std::functions, we need to use an extra boolean
* is "extremely self-referential and non-intuitive". */
MacroRulesDefinition (Identifier rule_name, DelimType delim_type,
std::vector<MacroRule> rules,
- std::vector<Attribute> outer_attrs, Location locus,
+ std::vector<Attribute> outer_attrs, location_t locus,
MacroKind kind, Visibility vis)
: VisItem (std::move (vis), outer_attrs),
outer_attrs (std::move (outer_attrs)), rule_name (std::move (rule_name)),
static std::unique_ptr<MacroRulesDefinition>
mbe (Identifier rule_name, DelimType delim_type, std::vector<MacroRule> rules,
- std::vector<Attribute> outer_attrs, Location locus)
+ std::vector<Attribute> outer_attrs, location_t locus)
{
return Rust::make_unique<MacroRulesDefinition> (
MacroRulesDefinition (rule_name, delim_type, rules, outer_attrs, locus,
static std::unique_ptr<MacroRulesDefinition>
decl_macro (Identifier rule_name, std::vector<MacroRule> rules,
- std::vector<Attribute> outer_attrs, Location locus,
+ std::vector<Attribute> outer_attrs, location_t locus,
Visibility vis)
{
return Rust::make_unique<MacroRulesDefinition> (MacroRulesDefinition (
*/
static std::unique_ptr<MacroInvocation>
Regular (MacroInvocData invoc_data, std::vector<Attribute> outer_attrs,
- Location locus, bool is_semi_coloned = false)
+ location_t locus, bool is_semi_coloned = false)
{
return std::unique_ptr<MacroInvocation> (
new MacroInvocation (InvocKind::Regular, tl::nullopt, invoc_data,
*/
static std::unique_ptr<MacroInvocation> Builtin (
BuiltinMacro kind, MacroInvocData invoc_data,
- std::vector<Attribute> outer_attrs, Location locus,
+ std::vector<Attribute> outer_attrs, location_t locus,
std::vector<std::unique_ptr<MacroInvocation>> &&pending_eager_invocations
= {},
bool is_semi_coloned = false)
MacroInvocation (
InvocKind kind, tl::optional<BuiltinMacro> builtin_kind,
MacroInvocData invoc_data, std::vector<Attribute> outer_attrs,
- Location locus, bool is_semi_coloned,
+ location_t locus, bool is_semi_coloned,
std::vector<std::unique_ptr<MacroInvocation>> &&pending_eager_invocs)
: TraitItem (locus), outer_attrs (std::move (outer_attrs)), locus (locus),
node_id (Analysis::Mappings::get ()->get_next_node_id ()),
}
std::vector<Attribute> outer_attrs;
- Location locus;
+ location_t locus;
NodeId node_id;
/* The data given to the macro invocation */
}
// kind of a HACK to get locus depending on opening scope resolution
- Location locus = UNKNOWN_LOCATION;
+ location_t locus = UNKNOWN_LOCATION;
if (with_opening_scope_resolution)
locus = simple_segments[0].get_locus () - 2; // minus 2 chars for ::
else
class PathIdentSegment
{
std::string segment_name;
- Location locus;
+ location_t locus;
// only allow identifiers, "super", "self", "Self", "crate", or "$crate"
public:
- PathIdentSegment (std::string segment_name, Location locus)
+ PathIdentSegment (std::string segment_name, location_t locus)
: segment_name (std::move (segment_name)), locus (locus)
{}
private:
Identifier identifier;
std::unique_ptr<Type> type;
- Location locus;
+ location_t locus;
public:
// Returns whether binding is in an error state.
// Pointer type for type in constructor to enable polymorphism
GenericArgsBinding (Identifier ident, std::unique_ptr<Type> type_ptr,
- Location locus = UNDEF_LOCATION)
+ location_t locus = UNDEF_LOCATION)
: identifier (std::move (ident)), type (std::move (type_ptr)), locus (locus)
{}
return GenericArg (nullptr, std::move (type), {""}, Kind::Type, locus);
}
- static GenericArg create_ambiguous (Identifier path, Location locus)
+ static GenericArg create_ambiguous (Identifier path, location_t locus)
{
return GenericArg (nullptr, nullptr, std::move (path), Kind::Either, locus);
}
private:
GenericArg (std::unique_ptr<Expr> expression, std::unique_ptr<Type> type,
- Identifier path, Kind kind, Location locus)
+ Identifier path, Kind kind, location_t locus)
: expression (std::move (expression)), type (std::move (type)),
path (std::move (path)), kind (kind), locus (locus)
{}
/* Which kind of const generic application are we dealing with */
Kind kind;
- Location locus;
+ location_t locus;
};
/**
GenericArg default_value;
Attribute outer_attr;
- Location locus;
+ location_t locus;
public:
ConstGenericParam (Identifier name, std::unique_ptr<AST::Type> type,
GenericArg default_value, Attribute outer_attr,
- Location locus)
+ location_t locus)
: name (name), type (std::move (type)),
default_value (std::move (default_value)), outer_attr (outer_attr),
locus (locus)
std::vector<Lifetime> lifetime_args;
std::vector<GenericArg> generic_args;
std::vector<GenericArgsBinding> binding_args;
- Location locus;
+ location_t locus;
public:
// Returns true if there are any generic arguments
GenericArgs (std::vector<Lifetime> lifetime_args,
std::vector<GenericArg> generic_args,
std::vector<GenericArgsBinding> binding_args,
- Location locus = UNDEF_LOCATION)
+ location_t locus = UNDEF_LOCATION)
: lifetime_args (std::move (lifetime_args)),
generic_args (std::move (generic_args)),
binding_args (std::move (binding_args)), locus (locus)
private:
PathIdentSegment segment_name;
GenericArgs generic_args;
- Location locus;
+ location_t locus;
NodeId node_id;
public:
bool has_generic_args () const { return generic_args.has_generic_args (); }
// Constructor for segment (from IdentSegment and GenericArgs)
- PathExprSegment (PathIdentSegment segment_name, Location locus,
+ PathExprSegment (PathIdentSegment segment_name, location_t locus,
GenericArgs generic_args = GenericArgs::create_empty ())
: segment_name (std::move (segment_name)),
generic_args (std::move (generic_args)), locus (locus),
/* Constructor for segment with generic arguments (from segment name and all
* args) */
- PathExprSegment (std::string segment_name, Location locus,
+ PathExprSegment (std::string segment_name, location_t locus,
std::vector<Lifetime> lifetime_args = {},
std::vector<GenericArg> generic_args = {},
std::vector<GenericArgsBinding> binding_args = {})
{
std::vector<Attribute> outer_attrs;
bool has_opening_scope_resolution;
- Location locus;
+ location_t locus;
NodeId _node_id;
public:
// Constructor
PathInExpression (std::vector<PathExprSegment> path_segments,
- std::vector<Attribute> outer_attrs, Location locus,
+ std::vector<Attribute> outer_attrs, location_t locus,
bool has_opening_scope_resolution = false)
: PathPattern (std::move (path_segments)),
outer_attrs (std::move (outer_attrs)),
private:
PathIdentSegment ident_segment;
- Location locus;
+ location_t locus;
protected:
/* This is protected because it is only really used by derived classes, not
}
TypePathSegment (PathIdentSegment ident_segment,
- bool has_separating_scope_resolution, Location locus)
+ bool has_separating_scope_resolution, location_t locus)
: ident_segment (std::move (ident_segment)), locus (locus),
has_separating_scope_resolution (has_separating_scope_resolution),
node_id (Analysis::Mappings::get ()->get_next_node_id ())
{}
TypePathSegment (std::string segment_name,
- bool has_separating_scope_resolution, Location locus)
+ bool has_separating_scope_resolution, location_t locus)
: ident_segment (PathIdentSegment (std::move (segment_name), locus)),
locus (locus),
has_separating_scope_resolution (has_separating_scope_resolution),
// Constructor with PathIdentSegment and GenericArgs
TypePathSegmentGeneric (PathIdentSegment ident_segment,
bool has_separating_scope_resolution,
- GenericArgs generic_args, Location locus)
+ GenericArgs generic_args, location_t locus)
: TypePathSegment (std::move (ident_segment),
has_separating_scope_resolution, locus),
generic_args (std::move (generic_args))
std::vector<Lifetime> lifetime_args,
std::vector<GenericArg> generic_args,
std::vector<GenericArgsBinding> binding_args,
- Location locus)
+ location_t locus)
: TypePathSegment (std::move (segment_name),
has_separating_scope_resolution, locus),
generic_args (GenericArgs (std::move (lifetime_args),
// FIXME: think of better way to mark as invalid than taking up storage
bool is_invalid;
- Location locus;
+ location_t locus;
protected:
// Constructor only used to create invalid type path functions.
- TypePathFunction (bool is_invalid, Location locus)
+ TypePathFunction (bool is_invalid, location_t locus)
: is_invalid (is_invalid), locus (locus)
{}
}
// Constructor
- TypePathFunction (std::vector<std::unique_ptr<Type> > inputs, Location locus,
- std::unique_ptr<Type> type = nullptr)
+ TypePathFunction (std::vector<std::unique_ptr<Type> > inputs,
+ location_t locus, std::unique_ptr<Type> type = nullptr)
: inputs (std::move (inputs)), return_type (std::move (type)),
is_invalid (false), locus (locus)
{}
// Constructor with PathIdentSegment and TypePathFn
TypePathSegmentFunction (PathIdentSegment ident_segment,
bool has_separating_scope_resolution,
- TypePathFunction function_path, Location locus)
+ TypePathFunction function_path, location_t locus)
: TypePathSegment (std::move (ident_segment),
has_separating_scope_resolution, locus),
function_path (std::move (function_path))
// Constructor with segment name and TypePathFn
TypePathSegmentFunction (std::string segment_name,
bool has_separating_scope_resolution,
- TypePathFunction function_path, Location locus)
+ TypePathFunction function_path, location_t locus)
: TypePathSegment (std::move (segment_name),
has_separating_scope_resolution, locus),
function_path (std::move (function_path))
{
bool has_opening_scope_resolution;
std::vector<std::unique_ptr<TypePathSegment> > segments;
- Location locus;
+ location_t locus;
protected:
/* Use covariance to implement clone function as returning this object
// Constructor
TypePath (std::vector<std::unique_ptr<TypePathSegment> > segments,
- Location locus, bool has_opening_scope_resolution = false)
+ location_t locus, bool has_opening_scope_resolution = false)
: TypeNoBounds (),
has_opening_scope_resolution (has_opening_scope_resolution),
segments (std::move (segments)), locus (locus)
private:
std::unique_ptr<Type> type_to_invoke_on;
TypePath trait_path;
- Location locus;
+ location_t locus;
NodeId node_id;
public:
// Constructor
QualifiedPathType (std::unique_ptr<Type> invoke_on_type,
- Location locus = UNDEF_LOCATION,
+ location_t locus = UNDEF_LOCATION,
TypePath trait_path = TypePath::create_error ())
: type_to_invoke_on (std::move (invoke_on_type)),
trait_path (std::move (trait_path)), locus (locus),
{
std::vector<Attribute> outer_attrs;
QualifiedPathType path_type;
- Location locus;
+ location_t locus;
NodeId _node_id;
public:
QualifiedPathInExpression (QualifiedPathType qual_path_type,
std::vector<PathExprSegment> path_segments,
- std::vector<Attribute> outer_attrs, Location locus)
+ std::vector<Attribute> outer_attrs,
+ location_t locus)
: PathPattern (std::move (path_segments)),
outer_attrs (std::move (outer_attrs)),
path_type (std::move (qual_path_type)), locus (locus),
QualifiedPathType path_type;
std::unique_ptr<TypePathSegment> associated_segment;
std::vector<std::unique_ptr<TypePathSegment> > segments;
- Location locus;
+ location_t locus;
protected:
/* Use covariance to implement clone function as returning this object
QualifiedPathType qual_path_type,
std::unique_ptr<TypePathSegment> associated_segment,
std::vector<std::unique_ptr<TypePathSegment> > path_segments,
- Location locus)
+ location_t locus)
: path_type (std::move (qual_path_type)),
associated_segment (std::move (associated_segment)),
segments (std::move (path_segments)), locus (locus)
class LiteralPattern : public Pattern
{
Literal lit;
- Location locus;
+ location_t locus;
NodeId node_id;
public:
std::string as_string () const override;
// Constructor for a literal pattern
- LiteralPattern (Literal lit, Location locus)
+ LiteralPattern (Literal lit, location_t locus)
: lit (std::move (lit)), locus (locus),
node_id (Analysis::Mappings::get ()->get_next_node_id ())
{}
- LiteralPattern (std::string val, Literal::LitType type, Location locus,
+ LiteralPattern (std::string val, Literal::LitType type, location_t locus,
PrimitiveCoreType type_hint)
: lit (Literal (std::move (val), type, type_hint)), locus (locus),
node_id (Analysis::Mappings::get ()->get_next_node_id ())
// bool has_pattern;
std::unique_ptr<Pattern> to_bind;
- Location locus;
+ location_t locus;
NodeId node_id;
public:
bool has_pattern_to_bind () const { return to_bind != nullptr; }
// Constructor
- IdentifierPattern (Identifier ident, Location locus, bool is_ref = false,
+ IdentifierPattern (Identifier ident, location_t locus, bool is_ref = false,
bool is_mut = false,
std::unique_ptr<Pattern> to_bind = nullptr)
: Pattern (), variable_ident (std::move (ident)), is_ref (is_ref),
node_id (Analysis::Mappings::get ()->get_next_node_id ())
{}
- IdentifierPattern (NodeId node_id, Identifier ident, Location locus,
+ IdentifierPattern (NodeId node_id, Identifier ident, location_t locus,
bool is_ref = false, bool is_mut = false,
std::unique_ptr<Pattern> to_bind = nullptr)
: Pattern (), variable_ident (std::move (ident)), is_ref (is_ref),
// AST node for using the '_' wildcard "match any value" pattern
class WildcardPattern : public Pattern
{
- Location locus;
+ location_t locus;
NodeId node_id;
public:
std::string as_string () const override { return std::string (1, '_'); }
- WildcardPattern (Location locus)
+ WildcardPattern (location_t locus)
: locus (locus), node_id (Analysis::Mappings::get ()->get_next_node_id ())
{}
class RestPattern : public Pattern
{
- Location locus;
+ location_t locus;
NodeId node_id;
public:
std::string as_string () const override { return ".."; }
- RestPattern (Location locus)
+ RestPattern (location_t locus)
: locus (locus), node_id (Analysis::Mappings::get ()->get_next_node_id ())
{}
// Minus prefixed to literal (if integer or floating-point)
bool has_minus;
- Location locus;
+ location_t locus;
public:
// Constructor
- RangePatternBoundLiteral (Literal literal, Location locus,
+ RangePatternBoundLiteral (Literal literal, location_t locus,
bool has_minus = false)
: literal (literal), has_minus (has_minus), locus (locus)
{}
/* location only stored to avoid a dereference - lower pattern should give
* correct location so maybe change in future */
- Location locus;
+ location_t locus;
NodeId node_id;
public:
// Constructor
RangePattern (std::unique_ptr<RangePatternBound> lower,
- std::unique_ptr<RangePatternBound> upper, Location locus,
+ std::unique_ptr<RangePatternBound> upper, location_t locus,
bool has_ellipsis_syntax = false)
: lower (std::move (lower)), upper (std::move (upper)),
has_ellipsis_syntax (has_ellipsis_syntax), locus (locus),
bool has_two_amps;
bool is_mut;
std::unique_ptr<Pattern> pattern;
- Location locus;
+ location_t locus;
NodeId node_id;
public:
std::string as_string () const override;
ReferencePattern (std::unique_ptr<Pattern> pattern, bool is_mut_reference,
- bool ref_has_two_amps, Location locus)
+ bool ref_has_two_amps, location_t locus)
: has_two_amps (ref_has_two_amps), is_mut (is_mut_reference),
pattern (std::move (pattern)), locus (locus),
node_id (Analysis::Mappings::get ()->get_next_node_id ())
class StructPatternField
{
std::vector<Attribute> outer_attrs;
- Location locus;
+ location_t locus;
protected:
NodeId node_id;
const std::vector<Attribute> &get_outer_attrs () const { return outer_attrs; }
protected:
- StructPatternField (std::vector<Attribute> outer_attribs, Location locus,
+ StructPatternField (std::vector<Attribute> outer_attribs, location_t locus,
NodeId node_id)
: outer_attrs (std::move (outer_attribs)), locus (locus), node_id (node_id)
{}
StructPatternFieldTuplePat (TupleIndex index,
std::unique_ptr<Pattern> tuple_pattern,
std::vector<Attribute> outer_attribs,
- Location locus)
+ location_t locus)
: StructPatternField (std::move (outer_attribs), locus,
Analysis::Mappings::get ()->get_next_node_id ()),
index (index), tuple_pattern (std::move (tuple_pattern))
StructPatternFieldIdentPat (Identifier ident,
std::unique_ptr<Pattern> ident_pattern,
std::vector<Attribute> outer_attrs,
- Location locus)
+ location_t locus)
: StructPatternField (std::move (outer_attrs), locus,
Analysis::Mappings::get ()->get_next_node_id ()),
ident (std::move (ident)), ident_pattern (std::move (ident_pattern))
public:
StructPatternFieldIdent (Identifier ident, bool is_ref, bool is_mut,
- std::vector<Attribute> outer_attrs, Location locus)
+ std::vector<Attribute> outer_attrs, location_t locus)
: StructPatternField (std::move (outer_attrs), locus,
Analysis::Mappings::get ()->get_next_node_id ()),
has_ref (is_ref), has_mut (is_mut), ident (std::move (ident))
StructPatternElements elems;
NodeId node_id;
- Location locus;
+ location_t locus;
public:
std::string as_string () const override;
// Constructs a struct pattern from specified StructPatternElements
- StructPattern (PathInExpression struct_path, Location locus,
+ StructPattern (PathInExpression struct_path, location_t locus,
StructPatternElements elems
= StructPatternElements::create_empty ())
: path (std::move (struct_path)), elems (std::move (elems)),
{
// bool has_tuple_pattern_items;
std::unique_ptr<TuplePatternItems> items;
- Location locus;
+ location_t locus;
NodeId node_id;
public:
// Returns true if the tuple pattern has items
bool has_tuple_pattern_items () const { return items != nullptr; }
- TuplePattern (std::unique_ptr<TuplePatternItems> items, Location locus)
+ TuplePattern (std::unique_ptr<TuplePatternItems> items, location_t locus)
: items (std::move (items)), locus (locus),
node_id (Analysis::Mappings::get ()->get_next_node_id ())
{}
class GroupedPattern : public Pattern
{
std::unique_ptr<Pattern> pattern_in_parens;
- Location locus;
+ location_t locus;
NodeId node_id;
public:
return "(" + pattern_in_parens->as_string () + ")";
}
- GroupedPattern (std::unique_ptr<Pattern> pattern_in_parens, Location locus)
+ GroupedPattern (std::unique_ptr<Pattern> pattern_in_parens, location_t locus)
: pattern_in_parens (std::move (pattern_in_parens)), locus (locus),
node_id (Analysis::Mappings::get ()->get_next_node_id ())
{}
class SlicePattern : public Pattern
{
std::vector<std::unique_ptr<Pattern>> items;
- Location locus;
+ location_t locus;
NodeId node_id;
public:
std::string as_string () const override;
- SlicePattern (std::vector<std::unique_ptr<Pattern>> items, Location locus)
+ SlicePattern (std::vector<std::unique_ptr<Pattern>> items, location_t locus)
: items (std::move (items)), locus (locus),
node_id (Analysis::Mappings::get ()->get_next_node_id ())
{}
class AltPattern : public Pattern
{
std::vector<std::unique_ptr<Pattern>> alts;
- Location locus;
+ location_t locus;
NodeId node_id;
public:
std::string as_string () const override;
- AltPattern (std::vector<std::unique_ptr<Pattern>> alts, Location locus)
+ AltPattern (std::vector<std::unique_ptr<Pattern>> alts, location_t locus)
: alts (std::move (alts)), locus (locus),
node_id (Analysis::Mappings::get ()->get_next_node_id ())
{}
// Just a semi-colon, which apparently is a statement.
class EmptyStmt : public Stmt
{
- Location locus;
+ location_t locus;
// TODO: find another way to store this to save memory?
bool marked_for_strip = false;
public:
std::string as_string () const override { return std::string (1, ';'); }
- EmptyStmt (Location locus) : locus (locus) {}
+ EmptyStmt (location_t locus) : locus (locus) {}
Location get_locus () const override final { return locus; }
// bool has_init_expr;
std::unique_ptr<Expr> init_expr;
- Location locus;
+ location_t locus;
public:
Type *inferedType;
LetStmt (std::unique_ptr<Pattern> variables_pattern,
std::unique_ptr<Expr> init_expr, std::unique_ptr<Type> type,
- std::vector<Attribute> outer_attrs, Location locus)
+ std::vector<Attribute> outer_attrs, location_t locus)
: outer_attrs (std::move (outer_attrs)),
variables_pattern (std::move (variables_pattern)),
type (std::move (type)), init_expr (std::move (init_expr)), locus (locus)
class ExprStmt : public Stmt
{
std::unique_ptr<Expr> expr;
- Location locus;
+ location_t locus;
bool semicolon_followed;
public:
std::vector<LetStmt *> locals;
- ExprStmt (std::unique_ptr<Expr> &&expr, Location locus,
+ ExprStmt (std::unique_ptr<Expr> &&expr, location_t locus,
bool semicolon_followed)
: expr (std::move (expr)), locus (locus),
semicolon_followed (semicolon_followed)
TypePath type_path;
- Location locus;
+ location_t locus;
public:
// Returns whether trait bound has "for" lifetimes
std::vector<LifetimeParam> &get_for_lifetimes () { return for_lifetimes; }
- TraitBound (TypePath type_path, Location locus, bool in_parens = false,
+ TraitBound (TypePath type_path, location_t locus, bool in_parens = false,
bool opening_question_mark = false,
std::vector<LifetimeParam> for_lifetimes
= std::vector<LifetimeParam> ())
type_path (std::move (type_path)), locus (locus)
{}
- TraitBound (NodeId id, TypePath type_path, Location locus,
+ TraitBound (NodeId id, TypePath type_path, location_t locus,
bool in_parens = false, bool opening_question_mark = false,
std::vector<LifetimeParam> for_lifetimes
= std::vector<LifetimeParam> ())
// inlined form
std::vector<std::unique_ptr<TypeParamBound> > type_param_bounds;
- Location locus;
+ location_t locus;
protected:
/* Use covariance to implement clone function as returning this object rather
public:
ImplTraitType (
std::vector<std::unique_ptr<TypeParamBound> > type_param_bounds,
- Location locus)
+ location_t locus)
: type_param_bounds (std::move (type_param_bounds)), locus (locus)
{}
{
bool has_dyn;
std::vector<std::unique_ptr<TypeParamBound> > type_param_bounds;
- Location locus;
+ location_t locus;
protected:
/* Use covariance to implement clone function as returning this object rather
public:
TraitObjectType (
std::vector<std::unique_ptr<TypeParamBound> > type_param_bounds,
- Location locus, bool is_dyn_dispatch)
+ location_t locus, bool is_dyn_dispatch)
: has_dyn (is_dyn_dispatch),
type_param_bounds (std::move (type_param_bounds)), locus (locus)
{}
class ParenthesisedType : public TypeNoBounds
{
std::unique_ptr<Type> type_in_parens;
- Location locus;
+ location_t locus;
protected:
/* Use covariance to implement clone function as returning this object rather
public:
// Constructor uses Type pointer for polymorphism
- ParenthesisedType (std::unique_ptr<Type> type_inside_parens, Location locus)
+ ParenthesisedType (std::unique_ptr<Type> type_inside_parens, location_t locus)
: type_in_parens (std::move (type_inside_parens)), locus (locus)
{}
class ImplTraitTypeOneBound : public TypeNoBounds
{
TraitBound trait_bound;
- Location locus;
+ location_t locus;
protected:
/* Use covariance to implement clone function as returning this object rather
}
public:
- ImplTraitTypeOneBound (TraitBound trait_bound, Location locus)
+ ImplTraitTypeOneBound (TraitBound trait_bound, location_t locus)
: trait_bound (std::move (trait_bound)), locus (locus)
{}
{
bool has_dyn;
TraitBound trait_bound;
- Location locus;
+ location_t locus;
protected:
/* Use covariance to implement clone function as returning this object rather
}
public:
- TraitObjectTypeOneBound (TraitBound trait_bound, Location locus,
+ TraitObjectTypeOneBound (TraitBound trait_bound, location_t locus,
bool is_dyn_dispatch = false)
: has_dyn (is_dyn_dispatch), trait_bound (std::move (trait_bound)),
locus (locus)
class TupleType : public TypeNoBounds
{
std::vector<std::unique_ptr<Type> > elems;
- Location locus;
+ location_t locus;
public:
// Returns whether the tuple type is the unit type, i.e. has no elements.
bool is_unit_type () const { return elems.empty (); }
- TupleType (std::vector<std::unique_ptr<Type> > elems, Location locus)
+ TupleType (std::vector<std::unique_ptr<Type> > elems, location_t locus)
: elems (std::move (elems)), locus (locus)
{}
* Represented as "!". */
class NeverType : public TypeNoBounds
{
- Location locus;
+ location_t locus;
protected:
/* Use covariance to implement clone function as returning this object rather
}
public:
- NeverType (Location locus) : locus (locus) {}
+ NeverType (location_t locus) : locus (locus) {}
std::string as_string () const override { return "! (never type)"; }
private:
PointerType pointer_type;
std::unique_ptr<TypeNoBounds> type;
- Location locus;
+ location_t locus;
public:
// Returns whether the pointer is mutable or constant.
// Constructor requires pointer for polymorphism reasons
RawPointerType (PointerType pointer_type,
- std::unique_ptr<TypeNoBounds> type_no_bounds, Location locus)
+ std::unique_ptr<TypeNoBounds> type_no_bounds,
+ location_t locus)
: pointer_type (pointer_type), type (std::move (type_no_bounds)),
locus (locus)
{}
bool has_mut;
std::unique_ptr<TypeNoBounds> type;
- Location locus;
+ location_t locus;
public:
// Returns whether the reference is mutable or immutable.
// Constructor
ReferenceType (bool is_mut, std::unique_ptr<TypeNoBounds> type_no_bounds,
- Location locus, Lifetime lifetime = Lifetime::error ())
+ location_t locus, Lifetime lifetime = Lifetime::error ())
: lifetime (std::move (lifetime)), has_mut (is_mut),
type (std::move (type_no_bounds)), locus (locus)
{}
{
std::unique_ptr<Type> elem_type;
std::unique_ptr<Expr> size;
- Location locus;
+ location_t locus;
public:
// Constructor requires pointers for polymorphism
ArrayType (std::unique_ptr<Type> type, std::unique_ptr<Expr> array_size,
- Location locus)
+ location_t locus)
: elem_type (std::move (type)), size (std::move (array_size)), locus (locus)
{}
class SliceType : public TypeNoBounds
{
std::unique_ptr<Type> elem_type;
- Location locus;
+ location_t locus;
public:
// Constructor requires pointer for polymorphism
- SliceType (std::unique_ptr<Type> type, Location locus)
+ SliceType (std::unique_ptr<Type> type, location_t locus)
: elem_type (std::move (type)), locus (locus)
{}
* pattern) */
class InferredType : public TypeNoBounds
{
- Location locus;
+ location_t locus;
// e.g. Vec<_> = whatever
protected:
}
public:
- InferredType (Location locus) : locus (locus) {}
+ InferredType (location_t locus) : locus (locus) {}
std::string as_string () const override;
ParamKind param_kind;
Identifier name; // technically, can be an identifier or '_'
- Location locus;
+ location_t locus;
public:
MaybeNamedParam (Identifier name, ParamKind param_kind,
std::unique_ptr<Type> param_type,
- std::vector<Attribute> outer_attrs, Location locus)
+ std::vector<Attribute> outer_attrs, location_t locus)
: outer_attrs (std::move (outer_attrs)),
param_type (std::move (param_type)), param_kind (param_kind),
name (std::move (name)), locus (locus)
// BareFunctionReturnType return_type;
std::unique_ptr<TypeNoBounds> return_type; // inlined version
- Location locus;
+ location_t locus;
public:
// Whether a return type is defined with the function.
FunctionQualifiers qualifiers,
std::vector<MaybeNamedParam> named_params, bool is_variadic,
std::vector<Attribute> variadic_attrs,
- std::unique_ptr<TypeNoBounds> type, Location locus)
+ std::unique_ptr<TypeNoBounds> type, location_t locus)
: for_lifetimes (std::move (lifetime_params)),
function_qualifiers (std::move (qualifiers)),
params (std::move (named_params)), _is_variadic (is_variadic),
// it is fine to use ARRAY_REFs for vector subscripts on vector
// register variables.
bool
-HIRCompileBase::mark_addressable (tree exp, Location locus)
+HIRCompileBase::mark_addressable (tree exp, location_t locus)
{
tree x = exp;
}
tree
-HIRCompileBase::indirect_expression (tree expr, Location locus)
+HIRCompileBase::indirect_expression (tree expr, location_t locus)
{
if (expr == error_mark_node)
return error_mark_node;
if (function_body.has_expr ())
{
- Location locus = function_body.get_final_expr ()->get_locus ();
+ location_t locus = function_body.get_final_expr ()->get_locus ();
tree return_value = CompileExpr::Compile (function_body.expr.get (), ctx);
// we can only return this if non unit value return type
{
// we can only do this if the function is of unit type otherwise other
// errors should have occurred
- Location locus = function_body.get_locus ();
+ location_t locus = function_body.get_locus ();
tree return_value = unit_expression (ctx, locus);
tree return_stmt
= ctx->get_backend ()->return_statement (fndecl, return_value, locus);
const std::string &fn_name, HIR::SelfParam &self_param,
std::vector<HIR::FunctionParam> &function_params,
const HIR::FunctionQualifiers &qualifiers, HIR::Visibility &visibility,
- AST::AttrVec &outer_attrs, Location locus, HIR::BlockExpr *function_body,
+ AST::AttrVec &outer_attrs, location_t locus, HIR::BlockExpr *function_body,
const Resolver::CanonicalPath *canonical_path, TyTy::FnType *fntype)
{
tree compiled_fn_type = TyTyResolveCompile::compile (ctx, fntype);
tree
HIRCompileBase::compile_constant_item (
TyTy::BaseType *resolved_type, const Resolver::CanonicalPath *canonical_path,
- HIR::Expr *const_value_expr, Location locus)
+ HIR::Expr *const_value_expr, location_t locus)
{
const std::string &ident = canonical_path->get ();
}
tree
-HIRCompileBase::unit_expression (Context *ctx, Location locus)
+HIRCompileBase::unit_expression (Context *ctx, location_t locus)
{
tree unit_type = TyTyResolveCompile::get_unit_type (ctx);
return ctx->get_backend ()->constructor_expression (unit_type, false, {}, -1,
Location rvalue_locus);
tree coerce_to_dyn_object (tree compiled_ref, const TyTy::BaseType *actual,
- const TyTy::DynamicObjectType *ty, Location locus);
+ const TyTy::DynamicObjectType *ty,
+ location_t locus);
tree compute_address_for_trait_item (
const Resolver::TraitItemReference *ref,
const TyTy::TypeBoundPredicate *predicate,
std::vector<std::pair<Resolver::TraitReference *, HIR::ImplBlock *>>
&receiver_bounds,
- const TyTy::BaseType *receiver, const TyTy::BaseType *root, Location locus);
+ const TyTy::BaseType *receiver, const TyTy::BaseType *root,
+ location_t locus);
bool verify_array_capacities (tree ltype, tree rtype, Location ltype_locus,
Location rtype_locus);
Location expr_locus, bool is_qualified_path);
tree resolve_adjustements (std::vector<Resolver::Adjustment> &adjustments,
- tree expression, Location locus);
+ tree expression, location_t locus);
tree resolve_deref_adjustment (Resolver::Adjustment &adjustment,
- tree expression, Location locus);
+ tree expression, location_t locus);
tree resolve_indirection_adjustment (Resolver::Adjustment &adjustment,
- tree expression, Location locus);
+ tree expression, location_t locus);
tree resolve_unsized_adjustment (Resolver::Adjustment &adjustment,
- tree expression, Location locus);
+ tree expression, location_t locus);
tree resolve_unsized_slice_adjustment (Resolver::Adjustment &adjustment,
- tree expression, Location locus);
+ tree expression, location_t locus);
tree resolve_unsized_dyn_adjustment (Resolver::Adjustment &adjustment,
- tree expression, Location locus);
+ tree expression, location_t locus);
tree resolve_method_address (TyTy::FnType *fntype, TyTy::BaseType *receiver,
Location expr_locus);
tree compile_constant_item (TyTy::BaseType *resolved_type,
const Resolver::CanonicalPath *canonical_path,
- HIR::Expr *const_value_expr, Location locus);
+ HIR::Expr *const_value_expr, location_t locus);
tree compile_function (const std::string &fn_name, HIR::SelfParam &self_param,
std::vector<HIR::FunctionParam> &function_params,
const HIR::FunctionQualifiers &qualifiers,
HIR::Visibility &visibility, AST::AttrVec &outer_attrs,
- Location locus, HIR::BlockExpr *function_body,
+ location_t locus, HIR::BlockExpr *function_body,
const Resolver::CanonicalPath *canonical_path,
TyTy::FnType *fntype);
- static tree unit_expression (Context *ctx, Location locus);
+ static tree unit_expression (Context *ctx, location_t locus);
static void setup_fndecl (tree fndecl, bool is_main_entry_point,
bool is_generic_fn, HIR::Visibility &visibility,
static void setup_abi_options (tree fndecl, ABI abi);
- static tree address_expression (tree expr, Location locus);
+ static tree address_expression (tree expr, location_t locus);
- static tree indirect_expression (tree expr, Location locus);
+ static tree indirect_expression (tree expr, location_t locus);
static bool mark_addressable (tree, Location);
tree compiled_expr = CompileExpr::Compile (expr.expr.get (), ctx);
if (result != nullptr)
{
- Location locus = expr.get_final_expr ()->get_locus ();
+ location_t locus = expr.get_final_expr ()->get_locus ();
tree result_reference
= ctx->get_backend ()->var_expression (result, locus);
}
else if (result != nullptr)
{
- Location locus = expr.get_locus ();
+ location_t locus = expr.get_locus ();
tree compiled_expr = unit_expression (ctx, expr.get_locus ());
tree result_reference
= ctx->get_backend ()->var_expression (result, locus);
tree
HIRCompileBase::resolve_adjustements (
std::vector<Resolver::Adjustment> &adjustments, tree expression,
- Location locus)
+ location_t locus)
{
tree e = expression;
for (auto &adjustment : adjustments)
tree
HIRCompileBase::resolve_deref_adjustment (Resolver::Adjustment &adjustment,
- tree expression, Location locus)
+ tree expression, location_t locus)
{
rust_assert (adjustment.is_deref_adjustment ()
|| adjustment.is_deref_mut_adjustment ());
tree
HIRCompileBase::resolve_indirection_adjustment (
- Resolver::Adjustment &adjustment, tree expression, Location locus)
+ Resolver::Adjustment &adjustment, tree expression, location_t locus)
{
return indirect_expression (expression, locus);
}
tree
HIRCompileBase::resolve_unsized_adjustment (Resolver::Adjustment &adjustment,
- tree expression, Location locus)
+ tree expression, location_t locus)
{
bool expect_slice
= adjustment.get_expected ()->get_kind () == TyTy::TypeKind::SLICE;
tree
HIRCompileBase::resolve_unsized_slice_adjustment (
- Resolver::Adjustment &adjustment, tree expression, Location locus)
+ Resolver::Adjustment &adjustment, tree expression, location_t locus)
{
// assumes this is an array
tree expr_type = TREE_TYPE (expression);
tree
HIRCompileBase::resolve_unsized_dyn_adjustment (
- Resolver::Adjustment &adjustment, tree expression, Location locus)
+ Resolver::Adjustment &adjustment, tree expression, location_t locus)
{
tree rvalue = expression;
Location rvalue_locus = locus;
tree compile_byte_string_literal (const HIR::LiteralExpr &expr,
const TyTy::BaseType *tyty);
- tree type_cast_expression (tree type_to_cast_to, tree expr, Location locus);
+ tree type_cast_expression (tree type_to_cast_to, tree expr, location_t locus);
tree array_value_expr (Location expr_locus, const TyTy::ArrayType &array_tyty,
tree array_type, HIR::ArrayElemsValues &elems);
namespace Compile {
CompileFnParam::CompileFnParam (Context *ctx, tree fndecl, tree decl_type,
- Location locus)
+ location_t locus)
: HIRCompileBase (ctx), fndecl (fndecl), decl_type (decl_type), locus (locus),
compiled_param (ctx->get_backend ()->error_variable ())
{}
Bvariable *
CompileFnParam::compile (Context *ctx, tree fndecl, HIR::FunctionParam *param,
- tree decl_type, Location locus)
+ tree decl_type, location_t locus)
{
CompileFnParam compiler (ctx, fndecl, decl_type, locus);
param->get_param_name ()->accept_vis (compiler);
Bvariable *
CompileFnParam::compile (Context *ctx, tree fndecl, HIR::Pattern *param,
- tree decl_type, Location locus)
+ tree decl_type, location_t locus)
{
CompileFnParam compiler (ctx, fndecl, decl_type, locus);
param->accept_vis (compiler);
Bvariable *
CompileSelfParam::compile (Context *ctx, tree fndecl, HIR::SelfParam &self,
- tree decl_type, Location locus)
+ tree decl_type, location_t locus)
{
bool is_immutable
= self.get_self_kind () == HIR::SelfParam::ImplicitSelfKind::IMM
public:
static Bvariable *compile (Context *ctx, tree fndecl,
HIR::FunctionParam *param, tree decl_type,
- Location locus);
+ location_t locus);
static Bvariable *compile (Context *ctx, tree fndecl, HIR::Pattern *param,
- tree decl_type, Location locus);
+ tree decl_type, location_t locus);
void visit (HIR::IdentifierPattern &pattern) override;
void visit (HIR::WildcardPattern &pattern) override;
void visit (HIR::TuplePattern &) override {}
private:
- CompileFnParam (Context *ctx, tree fndecl, tree decl_type, Location locus);
+ CompileFnParam (Context *ctx, tree fndecl, tree decl_type, location_t locus);
tree create_tmp_param_var (tree decl_type);
tree fndecl;
tree decl_type;
- Location locus;
+ location_t locus;
Bvariable *compiled_param;
};
{
public:
static Bvariable *compile (Context *ctx, tree fndecl, HIR::SelfParam &self,
- tree decl_type, Location locus);
+ tree decl_type, location_t locus);
};
} // namespace Compile
}
static bool
-check_for_basic_integer_type (const std::string &intrinsic_str, Location locus,
- TyTy::BaseType *type)
+check_for_basic_integer_type (const std::string &intrinsic_str,
+ location_t locus, TyTy::BaseType *type)
{
auto is_basic_integer = is_basic_integer_type (type);
if (!is_basic_integer)
if (it != generic_intrinsics.end ())
return it->second (ctx, fntype);
- Location locus = ctx->get_mappings ()->lookup_location (fntype->get_ref ());
+ location_t locus = ctx->get_mappings ()->lookup_location (fntype->get_ref ());
rust_error_at (locus, ErrorCode ("E0093"),
"unrecognized intrinsic function: %<%s%>",
fntype->get_identifier ().c_str ());
}
static std::string
-build_atomic_builtin_name (const std::string &prefix, Location locus,
+build_atomic_builtin_name (const std::string &prefix, location_t locus,
TyTy::BaseType *operand_type)
{
static const std::map<std::string, std::string> allowed_types = {
static tree
compile_range_pattern_bound (HIR::RangePatternBound *bound,
- Analysis::NodeMapping mappings, Location locus,
+ Analysis::NodeMapping mappings, location_t locus,
Context *ctx)
{
tree result = NULL_TREE;
{}
tree resolve (const HIR::PathIdentSegment &final_segment,
- const Analysis::NodeMapping &mappings, Location locus,
+ const Analysis::NodeMapping &mappings, location_t locus,
bool is_qualified_path);
tree resolved;
HIRCompileBase::coerce_to_dyn_object (tree compiled_ref,
const TyTy::BaseType *actual,
const TyTy::DynamicObjectType *ty,
- Location locus)
+ location_t locus)
{
// DST's get wrapped in a pseudo reference that doesnt exist...
const TyTy::ReferenceType r (ctx->get_mappings ()->get_next_hir_id (),
const TyTy::TypeBoundPredicate *predicate,
std::vector<std::pair<Resolver::TraitReference *, HIR::ImplBlock *>>
&receiver_bounds,
- const TyTy::BaseType *receiver, const TyTy::BaseType *root, Location locus)
+ const TyTy::BaseType *receiver, const TyTy::BaseType *root, location_t locus)
{
// There are two cases here one where its an item which has an implementation
// within a trait-impl-block. Then there is the case where there is a default
{}
void
-ConstChecker::check_function_call (HirId fn_id, Location locus)
+ConstChecker::check_function_call (HirId fn_id, location_t locus)
{
if (!const_context.is_in_context ())
return;
/**
* Check that only const functions are called in const contexts
*/
- void check_function_call (HirId fn_id, Location locus);
+ void check_function_call (HirId fn_id, location_t locus);
/* All possible const contexts */
enum class ConstGenericCtx
}
static void
-check_static_mut (HIR::Item *maybe_static, Location locus)
+check_static_mut (HIR::Item *maybe_static, location_t locus)
{
if (maybe_static->get_hir_kind () == Node::BaseKind::VIS_ITEM)
{
}
static void
-check_extern_static (HIR::ExternalItem *maybe_static, Location locus)
+check_extern_static (HIR::ExternalItem *maybe_static, location_t locus)
{
if (maybe_static->get_extern_kind () == ExternalItem::ExternKind::Static)
rust_error_at (locus,
}
void
-UnsafeChecker::check_use_of_static (HirId node_id, Location locus)
+UnsafeChecker::check_use_of_static (HirId node_id, location_t locus)
{
if (unsafe_context.is_in_context ())
return;
}
static void
-check_unsafe_call (HIR::Function *fn, Location locus, const std::string &kind)
+check_unsafe_call (HIR::Function *fn, location_t locus, const std::string &kind)
{
if (fn->get_qualifiers ().is_unsafe ())
rust_error_at (locus, ErrorCode ("E0133"),
static void
check_extern_call (HIR::ExternalItem *maybe_fn, HIR::ExternBlock *parent_block,
- Location locus)
+ location_t locus)
{
// We have multiple operations to perform here
// 1. Is the item an actual function we're calling
}
void
-UnsafeChecker::check_function_call (HirId node_id, Location locus)
+UnsafeChecker::check_function_call (HirId node_id, location_t locus)
{
if (unsafe_context.is_in_context ())
return;
}
static void
-check_target_attr (HIR::Function *fn, Location locus)
+check_target_attr (HIR::Function *fn, location_t locus)
{
if (std::any_of (fn->get_outer_attrs ().begin (),
fn->get_outer_attrs ().end (),
}
void
-UnsafeChecker::check_function_attr (HirId node_id, Location locus)
+UnsafeChecker::check_function_attr (HirId node_id, location_t locus)
{
if (unsafe_context.is_in_context ())
return;
* Check if a mutable static or external static item is used outside of an
* unsafe context
*/
- void check_use_of_static (HirId node_id, Location locus);
+ void check_use_of_static (HirId node_id, location_t locus);
/**
* Check if a call to an unsafe or external function is outside of an unsafe
* context
*/
- void check_function_call (HirId node_id, Location locus);
+ void check_function_call (HirId node_id, location_t locus);
/**
* Check if any unsafe attributes are present on a function
*/
- void check_function_attr (HirId node_id, Location locus);
+ void check_function_attr (HirId node_id, location_t locus);
StackedContexts<HirId> unsafe_context;
}
std::unique_ptr<AST::Expr>
-make_string (Location locus, std::string value)
+make_string (location_t locus, std::string value)
{
return std::unique_ptr<AST::Expr> (
new AST::LiteralExpr (value, AST::Literal::STRING,
// TODO: Is this correct?
static AST::Fragment
make_eager_builtin_invocation (
- BuiltinMacro kind, Location locus, AST::DelimTokenTree arguments,
+ BuiltinMacro kind, location_t locus, AST::DelimTokenTree arguments,
std::vector<std::unique_ptr<AST::MacroInvocation>> &&pending_invocations)
{
auto path_str = make_macro_path_str (kind);
compiled, and return the absolute path for it. */
std::string
-source_relative_path (std::string path, Location locus)
+source_relative_path (std::string path, location_t locus)
{
std::string compile_fname = LOCATION_FILE (locus);
void expand_invoc (AST::MacroInvocation &invoc, bool has_semicolon);
// Expands a single declarative macro.
- AST::Fragment expand_decl_macro (Location locus, AST::MacroInvocData &invoc,
+ AST::Fragment expand_decl_macro (location_t locus, AST::MacroInvocData &invoc,
AST::MacroRulesDefinition &rules_def,
bool semicolon);
private:
const Analysis::NodeMapping &mappings;
- Location locus;
+ location_t locus;
const AST::AttrVec &outer_attrs;
};
generic_params = lower_generic_params (function.get_generic_params ());
}
Identifier function_name = function.get_function_name ();
- Location locus = function.get_locus ();
+ location_t locus = function.get_locus ();
std::unique_ptr<HIR::Type> return_type
= function.has_return_type () ? std::unique_ptr<HIR::Type> (
generic_params = lower_generic_params (method.get_generic_params ());
}
Identifier method_name = method.get_method_name ();
- Location locus = method.get_locus ();
+ location_t locus = method.get_locus ();
HIR::SelfParam self_param = lower_self (method.get_self_param ());
generic_params = lower_generic_params (function.get_generic_params ());
}
Identifier function_name = function.get_function_name ();
- Location locus = function.get_locus ();
+ location_t locus = function.get_locus ();
std::unique_ptr<HIR::Type> return_type
= function.has_return_type () ? std::unique_ptr<HIR::Type> (
class LiteralExpr : public ExprWithoutBlock
{
Literal literal;
- Location locus;
+ location_t locus;
public:
std::string as_string () const override
LiteralExpr (Analysis::NodeMapping mappings, std::string value_as_string,
Literal::LitType type, PrimitiveCoreType type_hint,
- Location locus, AST::AttrVec outer_attrs)
+ location_t locus, AST::AttrVec outer_attrs)
: ExprWithoutBlock (std::move (mappings), std::move (outer_attrs)),
literal (std::move (value_as_string), type, type_hint), locus (locus)
{}
- LiteralExpr (Analysis::NodeMapping mappings, Literal literal, Location locus,
- AST::AttrVec outer_attrs)
+ LiteralExpr (Analysis::NodeMapping mappings, Literal literal,
+ location_t locus, AST::AttrVec outer_attrs)
: ExprWithoutBlock (std::move (mappings), std::move (outer_attrs)),
literal (std::move (literal)), locus (locus)
{}
{
// TODO: create binary and unary operator subclasses?
public:
- Location locus;
+ location_t locus;
protected:
/* Variable must be protected to allow derived classes to use it as a first
// Constructor (only for initialisation of expr purposes)
OperatorExpr (Analysis::NodeMapping mappings,
std::unique_ptr<Expr> main_or_left_expr,
- AST::AttrVec outer_attribs, Location locus)
+ AST::AttrVec outer_attribs, location_t locus)
: ExprWithoutBlock (std::move (mappings), std::move (outer_attribs)),
locus (locus), main_or_left_expr (std::move (main_or_left_expr))
{}
BorrowExpr (Analysis::NodeMapping mappings,
std::unique_ptr<Expr> borrow_lvalue, Mutability mut,
- AST::AttrVec outer_attribs, Location locus)
+ AST::AttrVec outer_attribs, location_t locus)
: OperatorExpr (std::move (mappings), std::move (borrow_lvalue),
std::move (outer_attribs), locus),
mut (mut)
// Constructor calls OperatorExpr's protected constructor
DereferenceExpr (Analysis::NodeMapping mappings,
std::unique_ptr<Expr> deref_lvalue,
- AST::AttrVec outer_attribs, Location locus)
+ AST::AttrVec outer_attribs, location_t locus)
: OperatorExpr (std::move (mappings), std::move (deref_lvalue),
std::move (outer_attribs), locus)
{}
// Constructor calls OperatorExpr's protected constructor
ErrorPropagationExpr (Analysis::NodeMapping mappings,
std::unique_ptr<Expr> potential_error_value,
- AST::AttrVec outer_attribs, Location locus)
+ AST::AttrVec outer_attribs, location_t locus)
: OperatorExpr (std::move (mappings), std::move (potential_error_value),
std::move (outer_attribs), locus)
{}
// Constructor calls OperatorExpr's protected constructor
NegationExpr (Analysis::NodeMapping mappings,
std::unique_ptr<Expr> negated_value, ExprType expr_kind,
- AST::AttrVec outer_attribs, Location locus)
+ AST::AttrVec outer_attribs, location_t locus)
: OperatorExpr (std::move (mappings), std::move (negated_value),
std::move (outer_attribs), locus),
expr_type (expr_kind)
ArithmeticOrLogicalExpr (Analysis::NodeMapping mappings,
std::unique_ptr<Expr> left_value,
std::unique_ptr<Expr> right_value,
- ExprType expr_kind, Location locus)
+ ExprType expr_kind, location_t locus)
: OperatorExpr (std::move (mappings), std::move (left_value),
AST::AttrVec (), locus),
expr_type (expr_kind), right_expr (std::move (right_value))
ComparisonExpr (Analysis::NodeMapping mappings,
std::unique_ptr<Expr> left_value,
std::unique_ptr<Expr> right_value, ExprType comparison_kind,
- Location locus)
+ location_t locus)
: OperatorExpr (std::move (mappings), std::move (left_value),
AST::AttrVec (), locus),
expr_type (comparison_kind), right_expr (std::move (right_value))
LazyBooleanExpr (Analysis::NodeMapping mappings,
std::unique_ptr<Expr> left_bool_expr,
std::unique_ptr<Expr> right_bool_expr, ExprType expr_kind,
- Location locus)
+ location_t locus)
: OperatorExpr (std::move (mappings), std::move (left_bool_expr),
AST::AttrVec (), locus),
expr_type (expr_kind), right_expr (std::move (right_bool_expr))
// Constructor requires calling protected constructor of OperatorExpr
TypeCastExpr (Analysis::NodeMapping mappings,
std::unique_ptr<Expr> expr_to_cast,
- std::unique_ptr<Type> type_to_cast_to, Location locus)
+ std::unique_ptr<Type> type_to_cast_to, location_t locus)
: OperatorExpr (std::move (mappings), std::move (expr_to_cast),
AST::AttrVec (), locus),
type_to_convert_to (std::move (type_to_cast_to))
// Call OperatorExpr constructor to initialise left_expr
AssignmentExpr (Analysis::NodeMapping mappings,
std::unique_ptr<Expr> value_to_assign_to,
- std::unique_ptr<Expr> value_to_assign, Location locus)
+ std::unique_ptr<Expr> value_to_assign, location_t locus)
: OperatorExpr (std::move (mappings), std::move (value_to_assign_to),
AST::AttrVec (), locus),
right_expr (std::move (value_to_assign))
CompoundAssignmentExpr (Analysis::NodeMapping mappings,
std::unique_ptr<Expr> value_to_assign_to,
std::unique_ptr<Expr> value_to_assign,
- ExprType expr_kind, Location locus)
+ ExprType expr_kind, location_t locus)
: OperatorExpr (std::move (mappings), std::move (value_to_assign_to),
AST::AttrVec (), locus),
expr_type (expr_kind), right_expr (std::move (value_to_assign))
{
std::unique_ptr<Expr> expr_in_parens;
- Location locus;
+ location_t locus;
public:
std::string as_string () const override;
GroupedExpr (Analysis::NodeMapping mappings,
std::unique_ptr<Expr> parenthesised_expr,
AST::AttrVec inner_attribs, AST::AttrVec outer_attribs,
- Location locus)
+ location_t locus)
: ExprWithoutBlock (std::move (mappings), std::move (outer_attribs)),
WithInnerAttrs (std::move (inner_attribs)),
expr_in_parens (std::move (parenthesised_expr)), locus (locus)
{
std::unique_ptr<ArrayElems> internal_elements;
- Location locus;
+ location_t locus;
public:
std::string as_string () const override;
ArrayExpr (Analysis::NodeMapping mappings,
std::unique_ptr<ArrayElems> array_elems,
AST::AttrVec inner_attribs, AST::AttrVec outer_attribs,
- Location locus)
+ location_t locus)
: ExprWithoutBlock (std::move (mappings), std::move (outer_attribs)),
WithInnerAttrs (std::move (inner_attribs)),
internal_elements (std::move (array_elems)), locus (locus)
std::unique_ptr<Expr> array_expr;
std::unique_ptr<Expr> index_expr;
- Location locus;
+ location_t locus;
public:
std::string as_string () const override;
ArrayIndexExpr (Analysis::NodeMapping mappings,
std::unique_ptr<Expr> array_expr,
std::unique_ptr<Expr> array_index_expr,
- AST::AttrVec outer_attribs, Location locus)
+ AST::AttrVec outer_attribs, location_t locus)
: ExprWithoutBlock (std::move (mappings), std::move (outer_attribs)),
array_expr (std::move (array_expr)),
index_expr (std::move (array_index_expr)), locus (locus)
std::vector<std::unique_ptr<Expr> > tuple_elems;
// replaces (inlined version of) TupleElements
- Location locus;
+ location_t locus;
public:
std::string as_string () const override;
TupleExpr (Analysis::NodeMapping mappings,
std::vector<std::unique_ptr<Expr> > tuple_elements,
AST::AttrVec inner_attribs, AST::AttrVec outer_attribs,
- Location locus)
+ location_t locus)
: ExprWithoutBlock (std::move (mappings), std::move (outer_attribs)),
WithInnerAttrs (std::move (inner_attribs)),
tuple_elems (std::move (tuple_elements)), locus (locus)
{
std::unique_ptr<Expr> tuple_expr;
TupleIndex tuple_index;
- Location locus;
+ location_t locus;
public:
std::string as_string () const override;
TupleIndexExpr (Analysis::NodeMapping mappings,
std::unique_ptr<Expr> tuple_expr, TupleIndex index,
- AST::AttrVec outer_attribs, Location locus)
+ AST::AttrVec outer_attribs, location_t locus)
: ExprWithoutBlock (std::move (mappings), std::move (outer_attribs)),
tuple_expr (std::move (tuple_expr)), tuple_index (index), locus (locus)
{}
// Actual HIR node of the struct creator (with no fields). Not abstract!
class StructExprStruct : public StructExpr, public WithInnerAttrs
{
- Location locus;
+ location_t locus;
public:
std::string as_string () const override;
// Constructor has to call protected constructor of base class
StructExprStruct (Analysis::NodeMapping mappings,
PathInExpression struct_path, AST::AttrVec inner_attribs,
- AST::AttrVec outer_attribs, Location locus)
+ AST::AttrVec outer_attribs, location_t locus)
: StructExpr (std::move (mappings), std::move (struct_path),
std::move (outer_attribs)),
WithInnerAttrs (std::move (inner_attribs)), locus (locus)
// pure virtual clone implementation
virtual StructExprField *clone_struct_expr_field_impl () const = 0;
- StructExprField (Analysis::NodeMapping mapping, Location locus)
+ StructExprField (Analysis::NodeMapping mapping, location_t locus)
: mappings (mapping), locus (locus)
{}
Analysis::NodeMapping mappings;
- Location locus;
+ location_t locus;
};
// Identifier-only variant of StructExprField HIR node
// TODO: should this store location data?
public:
StructExprFieldIdentifier (Analysis::NodeMapping mapping,
- Identifier field_identifier, Location locus)
+ Identifier field_identifier, location_t locus)
: StructExprField (mapping, locus),
field_name (std::move (field_identifier))
{}
protected:
StructExprFieldWithVal (Analysis::NodeMapping mapping,
- std::unique_ptr<Expr> field_value, Location locus)
+ std::unique_ptr<Expr> field_value, location_t locus)
: StructExprField (mapping, locus), value (std::move (field_value))
{}
StructExprFieldIdentifierValue (Analysis::NodeMapping mapping,
Identifier field_identifier,
std::unique_ptr<Expr> field_value,
- Location locus)
+ location_t locus)
: StructExprFieldWithVal (mapping, std::move (field_value), locus),
field_name (std::move (field_identifier))
{}
StructExprFieldIndexValue (Analysis::NodeMapping mapping,
TupleIndex tuple_index,
- std::unique_ptr<Expr> field_value, Location locus)
+ std::unique_ptr<Expr> field_value,
+ location_t locus)
: StructExprFieldWithVal (mapping, std::move (field_value), locus),
index (tuple_index)
{}
// Constructor for StructExprStructFields when no struct base is used
StructExprStructFields (
Analysis::NodeMapping mappings, PathInExpression struct_path,
- std::vector<std::unique_ptr<StructExprField> > expr_fields, Location locus,
- StructBase *base_struct, AST::AttrVec inner_attribs = AST::AttrVec (),
+ std::vector<std::unique_ptr<StructExprField> > expr_fields,
+ location_t locus, StructBase *base_struct,
+ AST::AttrVec inner_attribs = AST::AttrVec (),
AST::AttrVec outer_attribs = AST::AttrVec ())
: StructExprStruct (std::move (mappings), std::move (struct_path),
std::move (inner_attribs), std::move (outer_attribs),
StructExprStructBase (Analysis::NodeMapping mappings,
PathInExpression struct_path, StructBase base_struct,
AST::AttrVec inner_attribs, AST::AttrVec outer_attribs,
- Location locus)
+ location_t locus)
: StructExprStruct (std::move (mappings), std::move (struct_path),
std::move (inner_attribs), std::move (outer_attribs),
locus),
{
std::unique_ptr<Expr> function;
std::vector<std::unique_ptr<Expr> > params;
- Location locus;
+ location_t locus;
public:
std::string as_string () const override;
CallExpr (Analysis::NodeMapping mappings, std::unique_ptr<Expr> function_expr,
std::vector<std::unique_ptr<Expr> > function_params,
- AST::AttrVec outer_attribs, Location locus)
+ AST::AttrVec outer_attribs, location_t locus)
: ExprWithoutBlock (std::move (mappings), std::move (outer_attribs)),
function (std::move (function_expr)),
params (std::move (function_params)), locus (locus)
std::unique_ptr<Expr> receiver;
PathExprSegment method_name;
std::vector<std::unique_ptr<Expr> > params;
- Location locus;
+ location_t locus;
public:
std::string as_string () const override;
std::unique_ptr<Expr> call_receiver,
PathExprSegment method_path,
std::vector<std::unique_ptr<Expr> > method_params,
- AST::AttrVec outer_attribs, Location locus)
+ AST::AttrVec outer_attribs, location_t locus)
: ExprWithoutBlock (std::move (mappings), std::move (outer_attribs)),
receiver (std::move (call_receiver)),
method_name (std::move (method_path)), params (std::move (method_params)),
std::unique_ptr<Expr> receiver;
Identifier field;
- Location locus;
+ location_t locus;
public:
std::string as_string () const override;
FieldAccessExpr (Analysis::NodeMapping mappings,
std::unique_ptr<Expr> field_access_receiver,
Identifier field_name, AST::AttrVec outer_attribs,
- Location locus)
+ location_t locus)
: ExprWithoutBlock (std::move (mappings), std::move (outer_attribs)),
receiver (std::move (field_access_receiver)),
field (std::move (field_name)), locus (locus)
std::vector<AST::Attribute> outer_attrs;
std::unique_ptr<Pattern> pattern;
std::unique_ptr<Type> type;
- Location locus;
+ location_t locus;
public:
// Returns whether the type of the parameter has been given.
bool has_type_given () const { return type != nullptr; }
// Constructor for closure parameter
- ClosureParam (std::unique_ptr<Pattern> param_pattern, Location locus,
+ ClosureParam (std::unique_ptr<Pattern> param_pattern, location_t locus,
std::unique_ptr<Type> param_type = nullptr,
std::vector<AST::Attribute> outer_attrs = {})
: outer_attrs (std::move (outer_attrs)),
private:
bool has_move;
std::vector<ClosureParam> params;
- Location locus;
+ location_t locus;
std::unique_ptr<Type> return_type;
std::unique_ptr<Expr> expr;
std::vector<ClosureParam> closure_params,
std::unique_ptr<Type> closure_return_type,
std::unique_ptr<Expr> closure_expr, bool has_move,
- AST::AttrVec outer_attribs, Location locus)
+ AST::AttrVec outer_attribs, location_t locus)
: ExprWithoutBlock (std::move (mappings), std::move (outer_attribs)),
has_move (has_move), params (std::move (closure_params)), locus (locus),
return_type (std::move (closure_return_type)),
class ContinueExpr : public ExprWithoutBlock
{
Lifetime label;
- Location locus;
+ location_t locus;
public:
std::string as_string () const override;
bool has_label () const { return !label.is_error (); }
// Constructor for a ContinueExpr with a label.
- ContinueExpr (Analysis::NodeMapping mappings, Location locus, Lifetime label,
- AST::AttrVec outer_attribs = AST::AttrVec ())
+ ContinueExpr (Analysis::NodeMapping mappings, location_t locus,
+ Lifetime label, AST::AttrVec outer_attribs = AST::AttrVec ())
: ExprWithoutBlock (std::move (mappings), std::move (outer_attribs)),
label (std::move (label)), locus (locus)
{}
// bool has_break_expr;
std::unique_ptr<Expr> break_expr;
- Location locus;
+ location_t locus;
public:
std::string as_string () const override;
bool has_break_expr () const { return break_expr != nullptr; }
// Constructor for a break expression
- BreakExpr (Analysis::NodeMapping mappings, Location locus,
+ BreakExpr (Analysis::NodeMapping mappings, location_t locus,
Lifetime break_label,
std::unique_ptr<Expr> expr_in_break = nullptr,
AST::AttrVec outer_attribs = AST::AttrVec ())
// Base range expression HIR node object - abstract
class RangeExpr : public ExprWithoutBlock
{
- Location locus;
+ location_t locus;
protected:
// outer attributes not allowed before range expressions
- RangeExpr (Analysis::NodeMapping mappings, Location locus)
+ RangeExpr (Analysis::NodeMapping mappings, location_t locus)
: ExprWithoutBlock (std::move (mappings), AST::AttrVec ()), locus (locus)
{}
RangeFromToExpr (Analysis::NodeMapping mappings,
std::unique_ptr<Expr> range_from,
- std::unique_ptr<Expr> range_to, Location locus)
+ std::unique_ptr<Expr> range_to, location_t locus)
: RangeExpr (std::move (mappings), locus), from (std::move (range_from)),
to (std::move (range_to))
{}
std::string as_string () const override;
RangeFromExpr (Analysis::NodeMapping mappings,
- std::unique_ptr<Expr> range_from, Location locus)
+ std::unique_ptr<Expr> range_from, location_t locus)
: RangeExpr (std::move (mappings), locus), from (std::move (range_from))
{}
// outer attributes not allowed
RangeToExpr (Analysis::NodeMapping mappings, std::unique_ptr<Expr> range_to,
- Location locus)
+ location_t locus)
: RangeExpr (std::move (mappings), locus), to (std::move (range_to))
{}
public:
std::string as_string () const override;
- RangeFullExpr (Analysis::NodeMapping mappings, Location locus)
+ RangeFullExpr (Analysis::NodeMapping mappings, location_t locus)
: RangeExpr (std::move (mappings), locus)
{}
// outer attributes not allowed
RangeFromToInclExpr (Analysis::NodeMapping mappings,
std::unique_ptr<Expr> range_from,
- std::unique_ptr<Expr> range_to, Location locus)
+ std::unique_ptr<Expr> range_to, location_t locus)
: RangeExpr (std::move (mappings), locus), from (std::move (range_from)),
to (std::move (range_to))
{}
std::string as_string () const override;
RangeToInclExpr (Analysis::NodeMapping mappings,
- std::unique_ptr<Expr> range_to, Location locus)
+ std::unique_ptr<Expr> range_to, location_t locus)
: RangeExpr (std::move (mappings), locus), to (std::move (range_to))
{}
// outer attributes not allowed
public:
std::unique_ptr<Expr> return_expr;
- Location locus;
+ location_t locus;
std::string as_string () const override;
bool has_return_expr () const { return return_expr != nullptr; }
// Constructor for ReturnExpr.
- ReturnExpr (Analysis::NodeMapping mappings, Location locus,
+ ReturnExpr (Analysis::NodeMapping mappings, location_t locus,
std::unique_ptr<Expr> returned_expr = nullptr,
AST::AttrVec outer_attribs = AST::AttrVec ())
: ExprWithoutBlock (std::move (mappings), std::move (outer_attribs)),
{
// Or just have it extend BlockExpr
std::unique_ptr<BlockExpr> expr;
- Location locus;
+ location_t locus;
public:
std::string as_string () const override;
UnsafeBlockExpr (Analysis::NodeMapping mappings,
std::unique_ptr<BlockExpr> block_expr,
- AST::AttrVec outer_attribs, Location locus)
+ AST::AttrVec outer_attribs, location_t locus)
: ExprWithBlock (std::move (mappings), std::move (outer_attribs)),
expr (std::move (block_expr)), locus (locus)
{}
{
Lifetime label; // or type LIFETIME_OR_LABEL
- Location locus;
+ location_t locus;
Analysis::NodeMapping mappings;
public:
std::string as_string () const;
- LoopLabel (Analysis::NodeMapping mapping, Lifetime loop_label, Location locus)
+ LoopLabel (Analysis::NodeMapping mapping, Lifetime loop_label,
+ location_t locus)
: label (std::move (loop_label)), locus (locus), mappings (mapping)
{}
std::unique_ptr<BlockExpr> loop_block;
private:
- Location locus;
+ location_t locus;
protected:
// Constructor for BaseLoopExpr
BaseLoopExpr (Analysis::NodeMapping mappings,
- std::unique_ptr<BlockExpr> loop_block, Location locus,
+ std::unique_ptr<BlockExpr> loop_block, location_t locus,
LoopLabel loop_label,
AST::AttrVec outer_attribs = AST::AttrVec ())
: ExprWithBlock (std::move (mappings), std::move (outer_attribs)),
// Constructor for LoopExpr
LoopExpr (Analysis::NodeMapping mappings,
- std::unique_ptr<BlockExpr> loop_block, Location locus,
+ std::unique_ptr<BlockExpr> loop_block, location_t locus,
LoopLabel loop_label, AST::AttrVec outer_attribs = AST::AttrVec ())
: BaseLoopExpr (std::move (mappings), std::move (loop_block), locus,
std::move (loop_label), std::move (outer_attribs))
// Constructor for while loop with loop label
WhileLoopExpr (Analysis::NodeMapping mappings,
std::unique_ptr<Expr> loop_condition,
- std::unique_ptr<BlockExpr> loop_block, Location locus,
+ std::unique_ptr<BlockExpr> loop_block, location_t locus,
LoopLabel loop_label,
AST::AttrVec outer_attribs = AST::AttrVec ())
: BaseLoopExpr (std::move (mappings), std::move (loop_block), locus,
WhileLetLoopExpr (Analysis::NodeMapping mappings,
std::vector<std::unique_ptr<Pattern> > match_arm_patterns,
std::unique_ptr<Expr> condition,
- std::unique_ptr<BlockExpr> loop_block, Location locus,
+ std::unique_ptr<BlockExpr> loop_block, location_t locus,
LoopLabel loop_label,
AST::AttrVec outer_attribs = AST::AttrVec ())
: BaseLoopExpr (std::move (mappings), std::move (loop_block), locus,
ForLoopExpr (Analysis::NodeMapping mappings,
std::unique_ptr<Pattern> loop_pattern,
std::unique_ptr<Expr> iterator_expr,
- std::unique_ptr<BlockExpr> loop_body, Location locus,
+ std::unique_ptr<BlockExpr> loop_body, location_t locus,
LoopLabel loop_label,
AST::AttrVec outer_attribs = AST::AttrVec ())
: BaseLoopExpr (std::move (mappings), std::move (loop_body), locus,
std::unique_ptr<Expr> condition;
std::unique_ptr<BlockExpr> if_block;
- Location locus;
+ location_t locus;
public:
std::string as_string () const override;
IfExpr (Analysis::NodeMapping mappings, std::unique_ptr<Expr> condition,
- std::unique_ptr<BlockExpr> if_block, Location locus)
+ std::unique_ptr<BlockExpr> if_block, location_t locus)
: ExprWithBlock (std::move (mappings), AST::AttrVec ()),
condition (std::move (condition)), if_block (std::move (if_block)),
locus (locus)
IfExprConseqElse (Analysis::NodeMapping mappings,
std::unique_ptr<Expr> condition,
std::unique_ptr<BlockExpr> if_block,
- std::unique_ptr<ExprWithBlock> else_block, Location locus)
+ std::unique_ptr<ExprWithBlock> else_block, location_t locus)
: IfExpr (std::move (mappings), std::move (condition), std::move (if_block),
locus),
else_block (std::move (else_block))
std::unique_ptr<Expr> value;
std::unique_ptr<BlockExpr> if_block;
- Location locus;
+ location_t locus;
public:
std::string as_string () const override;
IfLetExpr (Analysis::NodeMapping mappings,
std::vector<std::unique_ptr<Pattern> > match_arm_patterns,
std::unique_ptr<Expr> value, std::unique_ptr<BlockExpr> if_block,
- Location locus)
+ location_t locus)
: ExprWithBlock (std::move (mappings), AST::AttrVec ()),
match_arm_patterns (std::move (match_arm_patterns)),
value (std::move (value)), if_block (std::move (if_block)), locus (locus)
Analysis::NodeMapping mappings,
std::vector<std::unique_ptr<Pattern> > match_arm_patterns,
std::unique_ptr<Expr> value, std::unique_ptr<BlockExpr> if_block,
- std::unique_ptr<ExprWithBlock> else_block, Location locus)
+ std::unique_ptr<ExprWithBlock> else_block, location_t locus)
: IfLetExpr (std::move (mappings), std::move (match_arm_patterns),
std::move (value), std::move (if_block), locus),
else_block (std::move (else_block))
AST::AttrVec outer_attrs;
std::vector<std::unique_ptr<Pattern> > match_arm_patterns;
std::unique_ptr<Expr> guard_expr;
- Location locus;
+ location_t locus;
public:
// Returns whether the MatchArm has a match arm guard expression
// Constructor for match arm with a guard expression
MatchArm (std::vector<std::unique_ptr<Pattern> > match_arm_patterns,
- Location locus, std::unique_ptr<Expr> guard_expr = nullptr,
+ location_t locus, std::unique_ptr<Expr> guard_expr = nullptr,
AST::AttrVec outer_attrs = AST::AttrVec ())
: outer_attrs (std::move (outer_attrs)),
match_arm_patterns (std::move (match_arm_patterns)),
// Creates a match arm in an error state.
static MatchArm create_error ()
{
- Location locus = UNDEF_LOCATION;
+ location_t locus = UNDEF_LOCATION;
return MatchArm (std::vector<std::unique_ptr<Pattern> > (), locus);
}
{
std::unique_ptr<Expr> branch_value;
std::vector<MatchCase> match_arms;
- Location locus;
+ location_t locus;
public:
std::string as_string () const override;
MatchExpr (Analysis::NodeMapping mappings, std::unique_ptr<Expr> branch_value,
std::vector<MatchCase> match_arms, AST::AttrVec inner_attrs,
- AST::AttrVec outer_attrs, Location locus)
+ AST::AttrVec outer_attrs, location_t locus)
: ExprWithBlock (std::move (mappings), std::move (outer_attrs)),
WithInnerAttrs (std::move (inner_attrs)),
branch_value (std::move (branch_value)),
class AwaitExpr : public ExprWithoutBlock
{
std::unique_ptr<Expr> awaited_expr;
- Location locus;
+ location_t locus;
public:
// TODO: ensure outer attributes are actually allowed
AwaitExpr (Analysis::NodeMapping mappings, std::unique_ptr<Expr> awaited_expr,
- AST::AttrVec outer_attrs, Location locus)
+ AST::AttrVec outer_attrs, location_t locus)
: ExprWithoutBlock (std::move (mappings), std::move (outer_attrs)),
awaited_expr (std::move (awaited_expr)), locus (locus)
{}
{
bool has_move;
std::unique_ptr<BlockExpr> block_expr;
- Location locus;
+ location_t locus;
public:
AsyncBlockExpr (Analysis::NodeMapping mappings,
std::unique_ptr<BlockExpr> block_expr, bool has_move,
- AST::AttrVec outer_attrs, Location locus)
+ AST::AttrVec outer_attrs, location_t locus)
: ExprWithBlock (std::move (mappings), std::move (outer_attrs)),
has_move (has_move), block_expr (std::move (block_expr)), locus (locus)
{}
private:
const Analysis::NodeMapping node_mappings;
const Analysis::NodeMapping lvalue_mappings;
- Location locus;
+ location_t locus;
};
class InlineAsmReg
};
Identifier name;
- Location locus;
+ location_t locus;
};
// Inline Assembly Node
// bool has_type;
std::unique_ptr<Type> type;
- Location locus;
+ location_t locus;
public:
// Returns whether the type of the type param has been specified.
AST::Attribute &get_outer_attribute () { return outer_attr; }
TypeParam (Analysis::NodeMapping mappings, Identifier type_representation,
- Location locus = UNDEF_LOCATION,
+ location_t locus = UNDEF_LOCATION,
std::vector<std::unique_ptr<TypeParamBound>> type_param_bounds
= std::vector<std::unique_ptr<TypeParamBound>> (),
std::unique_ptr<Type> type = nullptr,
{
Lifetime lifetime;
std::vector<Lifetime> lifetime_bounds;
- Location locus;
+ location_t locus;
Analysis::NodeMapping mappings;
public:
LifetimeWhereClauseItem (Analysis::NodeMapping mappings, Lifetime lifetime,
std::vector<Lifetime> lifetime_bounds,
- Location locus)
+ location_t locus)
: lifetime (std::move (lifetime)),
lifetime_bounds (std::move (lifetime_bounds)), locus (locus),
mappings (std::move (mappings))
std::unique_ptr<Type> bound_type;
std::vector<std::unique_ptr<TypeParamBound>> type_param_bounds;
Analysis::NodeMapping mappings;
- Location locus;
+ location_t locus;
public:
// Returns whether the item has ForLifetimes
Analysis::NodeMapping mappings, std::vector<LifetimeParam> for_lifetimes,
std::unique_ptr<Type> bound_type,
std::vector<std::unique_ptr<TypeParamBound>> type_param_bounds,
- Location locus)
+ location_t locus)
: for_lifetimes (std::move (for_lifetimes)),
bound_type (std::move (bound_type)),
type_param_bounds (std::move (type_param_bounds)),
ImplicitSelfKind self_kind;
Lifetime lifetime;
std::unique_ptr<Type> type;
- Location locus;
+ location_t locus;
Analysis::NodeMapping mappings;
SelfParam (Analysis::NodeMapping mappings, ImplicitSelfKind self_kind,
public:
// Type-based self parameter (not ref, no lifetime)
SelfParam (Analysis::NodeMapping mappings, std::unique_ptr<Type> type,
- bool is_mut, Location locus)
+ bool is_mut, location_t locus)
: self_kind (is_mut ? ImplicitSelfKind::MUT : ImplicitSelfKind::IMM),
lifetime (
Lifetime (mappings, AST::Lifetime::LifetimeType::NAMED, "", locus)),
// Lifetime-based self parameter (is ref, no type)
SelfParam (Analysis::NodeMapping mappings, Lifetime lifetime, bool is_mut,
- Location locus)
+ location_t locus)
: self_kind (is_mut ? ImplicitSelfKind::MUT_REF
: ImplicitSelfKind::IMM_REF),
lifetime (std::move (lifetime)), locus (locus), mappings (mappings)
{
std::unique_ptr<Pattern> param_name;
std::unique_ptr<Type> type;
- Location locus;
+ location_t locus;
Analysis::NodeMapping mappings;
public:
FunctionParam (Analysis::NodeMapping mappings,
std::unique_ptr<Pattern> param_name,
- std::unique_ptr<Type> param_type, Location locus)
+ std::unique_ptr<Type> param_type, location_t locus)
: param_name (std::move (param_name)), type (std::move (param_type)),
locus (locus), mappings (mappings)
{}
private:
VisType vis_type;
HIR::SimplePath path;
- Location locus;
+ location_t locus;
// should this store location info?
public:
Visibility (VisType vis_type,
HIR::SimplePath path = HIR::SimplePath::create_empty (),
- Location locus = UNDEF_LOCATION)
+ location_t locus = UNDEF_LOCATION)
: vis_type (vis_type), path (std::move (path)), locus (locus)
{}
class Module : public VisItem, public WithInnerAttrs
{
Identifier module_name;
- Location locus;
+ location_t locus;
// bool has_items;
std::vector<std::unique_ptr<Item>> items;
// Full constructor
Module (Analysis::NodeMapping mappings, Identifier module_name,
- Location locus, std::vector<std::unique_ptr<Item>> items,
+ location_t locus, std::vector<std::unique_ptr<Item>> items,
Visibility visibility = Visibility::create_error (),
AST::AttrVec inner_attrs = AST::AttrVec (),
AST::AttrVec outer_attrs = AST::AttrVec ())
// this is either an identifier or "_", with _ parsed to string
std::string as_clause_name;
- Location locus;
+ location_t locus;
/* e.g.
"extern crate foo as _"
// Constructor
ExternCrate (Analysis::NodeMapping mappings, std::string referenced_crate,
- Visibility visibility, AST::AttrVec outer_attrs, Location locus,
- std::string as_clause_name = std::string ())
+ Visibility visibility, AST::AttrVec outer_attrs,
+ location_t locus, std::string as_clause_name = std::string ())
: VisItem (std::move (mappings), std::move (visibility),
std::move (outer_attrs)),
referenced_crate (std::move (referenced_crate)),
// The path-ish thing referred to in a use declaration - abstract base class
class UseTree : public FullVisitable
{
- Location locus;
+ location_t locus;
public:
virtual ~UseTree () {}
// Clone function implementation as pure virtual method
virtual UseTree *clone_use_tree_impl () const = 0;
- UseTree (Location locus) : locus (locus) {}
+ UseTree (location_t locus) : locus (locus) {}
};
// Use tree with a glob (wildcard) operator
AST::SimplePath path;
public:
- UseTreeGlob (PathType glob_type, AST::SimplePath path, Location locus)
+ UseTreeGlob (PathType glob_type, AST::SimplePath path, location_t locus)
: UseTree (locus), glob_type (glob_type), path (std::move (path))
{
if (this->glob_type != PATH_PREFIXED)
public:
UseTreeList (PathType path_type, AST::SimplePath path,
- std::vector<std::unique_ptr<UseTree>> trees, Location locus)
+ std::vector<std::unique_ptr<UseTree>> trees, location_t locus)
: UseTree (locus), path_type (path_type), path (std::move (path)),
trees (std::move (trees))
{
Identifier identifier; // only if NewBindType is IDENTIFIER
public:
- UseTreeRebind (NewBindType bind_type, AST::SimplePath path, Location locus,
+ UseTreeRebind (NewBindType bind_type, AST::SimplePath path, location_t locus,
Identifier identifier = std::string ())
: UseTree (locus), path (std::move (path)), bind_type (bind_type),
identifier (std::move (identifier))
class UseDeclaration : public VisItem
{
std::unique_ptr<UseTree> use_tree;
- Location locus;
+ location_t locus;
public:
std::string as_string () const override;
UseDeclaration (Analysis::NodeMapping mappings,
std::unique_ptr<UseTree> use_tree, Visibility visibility,
- AST::AttrVec outer_attrs, Location locus)
+ AST::AttrVec outer_attrs, location_t locus)
: VisItem (std::move (mappings), std::move (visibility),
std::move (outer_attrs)),
use_tree (std::move (use_tree)), locus (locus)
WhereClause where_clause;
std::unique_ptr<BlockExpr> function_body;
SelfParam self;
- Location locus;
+ location_t locus;
public:
std::string as_string () const override;
std::vector<FunctionParam> function_params,
std::unique_ptr<Type> return_type, WhereClause where_clause,
std::unique_ptr<BlockExpr> function_body, Visibility vis,
- AST::AttrVec outer_attrs, SelfParam self, Location locus)
+ AST::AttrVec outer_attrs, SelfParam self, location_t locus)
: VisItem (std::move (mappings), std::move (vis), std::move (outer_attrs)),
qualifiers (std::move (qualifiers)),
function_name (std::move (function_name)),
std::unique_ptr<Type> existing_type;
- Location locus;
+ location_t locus;
public:
std::string as_string () const override;
TypeAlias (Analysis::NodeMapping mappings, Identifier new_type_name,
std::vector<std::unique_ptr<GenericParam>> generic_params,
WhereClause where_clause, std::unique_ptr<Type> existing_type,
- Visibility vis, AST::AttrVec outer_attrs, Location locus)
+ Visibility vis, AST::AttrVec outer_attrs, location_t locus)
: VisItem (std::move (mappings), std::move (vis), std::move (outer_attrs)),
new_type_name (std::move (new_type_name)),
generic_params (std::move (generic_params)),
// bool has_where_clause;
WhereClause where_clause;
- Location locus;
+ location_t locus;
public:
Identifier get_identifier () const { return struct_name; }
protected:
Struct (Analysis::NodeMapping mappings, Identifier struct_name,
std::vector<std::unique_ptr<GenericParam>> generic_params,
- WhereClause where_clause, Visibility vis, Location locus,
+ WhereClause where_clause, Visibility vis, location_t locus,
AST::AttrVec outer_attrs = AST::AttrVec ())
: VisItem (std::move (mappings), std::move (vis), std::move (outer_attrs)),
struct_name (std::move (struct_name)),
Analysis::NodeMapping mappings;
- Location locus;
+ location_t locus;
// Returns whether struct field has any outer attributes.
bool has_outer_attributes () const { return !outer_attrs.empty (); }
bool has_visibility () const { return !visibility.is_error (); }
StructField (Analysis::NodeMapping mappings, Identifier field_name,
- std::unique_ptr<Type> field_type, Visibility vis, Location locus,
- AST::AttrVec outer_attrs = AST::AttrVec ())
+ std::unique_ptr<Type> field_type, Visibility vis,
+ location_t locus, AST::AttrVec outer_attrs = AST::AttrVec ())
: outer_attrs (std::move (outer_attrs)), visibility (std::move (vis)),
field_name (std::move (field_name)), field_type (std::move (field_type)),
mappings (mappings), locus (locus)
Identifier struct_name,
std::vector<std::unique_ptr<GenericParam>> generic_params,
WhereClause where_clause, bool is_unit, Visibility vis,
- AST::AttrVec outer_attrs, Location locus)
+ AST::AttrVec outer_attrs, location_t locus)
: Struct (std::move (mappings), std::move (struct_name),
std::move (generic_params), std::move (where_clause),
std::move (vis), locus, std::move (outer_attrs)),
StructStruct (Analysis::NodeMapping mappings, Identifier struct_name,
std::vector<std::unique_ptr<GenericParam>> generic_params,
WhereClause where_clause, Visibility vis,
- AST::AttrVec outer_attrs, Location locus)
+ AST::AttrVec outer_attrs, location_t locus)
: Struct (std::move (mappings), std::move (struct_name),
std::move (generic_params), std::move (where_clause),
std::move (vis), locus, std::move (outer_attrs)),
std::unique_ptr<Type> field_type;
- Location locus;
+ location_t locus;
Analysis::NodeMapping mappings;
// Complete constructor
TupleField (Analysis::NodeMapping mapping, std::unique_ptr<Type> field_type,
- Visibility vis, Location locus,
+ Visibility vis, location_t locus,
AST::AttrVec outer_attrs = AST::AttrVec ())
: outer_attrs (std::move (outer_attrs)), visibility (std::move (vis)),
field_type (std::move (field_type)), locus (locus), mappings (mapping)
Identifier struct_name,
std::vector<std::unique_ptr<GenericParam>> generic_params,
WhereClause where_clause, Visibility vis,
- AST::AttrVec outer_attrs, Location locus)
+ AST::AttrVec outer_attrs, location_t locus)
: Struct (std::move (mappings), std::move (struct_name),
std::move (generic_params), std::move (where_clause),
std::move (vis), locus, std::move (outer_attrs)),
class EnumItem : public Item
{
Identifier variant_name;
- Location locus;
+ location_t locus;
public:
virtual ~EnumItem () {}
};
EnumItem (Analysis::NodeMapping mappings, Identifier variant_name,
- AST::AttrVec outer_attrs, Location locus)
+ AST::AttrVec outer_attrs, location_t locus)
: Item (std::move (mappings), std::move (outer_attrs)),
variant_name (std::move (variant_name)), locus (locus)
{}
EnumItemTuple (Analysis::NodeMapping mappings, Identifier variant_name,
std::vector<TupleField> tuple_fields, AST::AttrVec outer_attrs,
- Location locus)
+ location_t locus)
: EnumItem (std::move (mappings), std::move (variant_name),
std::move (outer_attrs), locus),
tuple_fields (std::move (tuple_fields))
EnumItemStruct (Analysis::NodeMapping mappings, Identifier variant_name,
std::vector<StructField> struct_fields,
- AST::AttrVec outer_attrs, Location locus)
+ AST::AttrVec outer_attrs, location_t locus)
: EnumItem (std::move (mappings), std::move (variant_name),
std::move (outer_attrs), locus),
struct_fields (std::move (struct_fields))
public:
EnumItemDiscriminant (Analysis::NodeMapping mappings, Identifier variant_name,
std::unique_ptr<Expr> expr, AST::AttrVec outer_attrs,
- Location locus)
+ location_t locus)
: EnumItem (std::move (mappings), std::move (variant_name),
std::move (outer_attrs), locus),
expression (std::move (expr))
std::vector<std::unique_ptr<EnumItem>> items;
- Location locus;
+ location_t locus;
public:
std::string as_string () const override;
Enum (Analysis::NodeMapping mappings, Identifier enum_name, Visibility vis,
std::vector<std::unique_ptr<GenericParam>> generic_params,
WhereClause where_clause, std::vector<std::unique_ptr<EnumItem>> items,
- AST::AttrVec outer_attrs, Location locus)
+ AST::AttrVec outer_attrs, location_t locus)
: VisItem (std::move (mappings), std::move (vis), std::move (outer_attrs)),
enum_name (std::move (enum_name)),
generic_params (std::move (generic_params)),
std::vector<StructField> variants;
- Location locus;
+ location_t locus;
public:
std::string as_string () const override;
Union (Analysis::NodeMapping mappings, Identifier union_name, Visibility vis,
std::vector<std::unique_ptr<GenericParam>> generic_params,
WhereClause where_clause, std::vector<StructField> variants,
- AST::AttrVec outer_attrs, Location locus)
+ AST::AttrVec outer_attrs, location_t locus)
: VisItem (std::move (mappings), std::move (vis), std::move (outer_attrs)),
union_name (std::move (union_name)),
generic_params (std::move (generic_params)),
Identifier identifier;
std::unique_ptr<Type> type;
std::unique_ptr<Expr> const_expr;
- Location locus;
+ location_t locus;
public:
std::string as_string () const override;
ConstantItem (Analysis::NodeMapping mappings, Identifier ident,
Visibility vis, std::unique_ptr<Type> type,
std::unique_ptr<Expr> const_expr, AST::AttrVec outer_attrs,
- Location locus)
+ location_t locus)
: VisItem (std::move (mappings), std::move (vis), std::move (outer_attrs)),
identifier (std::move (ident)), type (std::move (type)),
const_expr (std::move (const_expr)), locus (locus)
Identifier name;
std::unique_ptr<Type> type;
std::unique_ptr<Expr> expr;
- Location locus;
+ location_t locus;
public:
std::string as_string () const override;
StaticItem (Analysis::NodeMapping mappings, Identifier name, Mutability mut,
std::unique_ptr<Type> type, std::unique_ptr<Expr> expr,
- Visibility vis, AST::AttrVec outer_attrs, Location locus)
+ Visibility vis, AST::AttrVec outer_attrs, location_t locus)
: VisItem (std::move (mappings), std::move (vis), std::move (outer_attrs)),
mut (mut), name (std::move (name)), type (std::move (type)),
expr (std::move (expr)), locus (locus)
AST::AttrVec outer_attrs;
TraitFunctionDecl decl;
std::unique_ptr<BlockExpr> block_expr;
- Location locus;
+ location_t locus;
public:
// Returns whether function has a definition or is just a declaration.
TraitItemFunc (Analysis::NodeMapping mappings, TraitFunctionDecl decl,
std::unique_ptr<BlockExpr> block_expr,
- AST::AttrVec outer_attrs, Location locus)
+ AST::AttrVec outer_attrs, location_t locus)
: TraitItem (mappings), outer_attrs (std::move (outer_attrs)),
decl (std::move (decl)), block_expr (std::move (block_expr)),
locus (locus)
Identifier name;
std::unique_ptr<Type> type;
std::unique_ptr<Expr> expr;
- Location locus;
+ location_t locus;
public:
// Whether the constant item has an associated expression.
TraitItemConst (Analysis::NodeMapping mappings, Identifier name,
std::unique_ptr<Type> type, std::unique_ptr<Expr> expr,
- AST::AttrVec outer_attrs, Location locus)
+ AST::AttrVec outer_attrs, location_t locus)
: TraitItem (mappings), outer_attrs (std::move (outer_attrs)),
name (std::move (name)), type (std::move (type)), expr (std::move (expr)),
locus (locus)
Identifier name;
std::vector<std::unique_ptr<TypeParamBound>>
type_param_bounds; // inlined form
- Location locus;
+ location_t locus;
public:
// Returns whether trait item type has type param bounds.
TraitItemType (Analysis::NodeMapping mappings, Identifier name,
std::vector<std::unique_ptr<TypeParamBound>> type_param_bounds,
- AST::AttrVec outer_attrs, Location locus)
+ AST::AttrVec outer_attrs, location_t locus)
: TraitItem (mappings), outer_attrs (std::move (outer_attrs)),
name (std::move (name)),
type_param_bounds (std::move (type_param_bounds)), locus (locus)
std::vector<std::unique_ptr<TypeParamBound>> type_param_bounds;
WhereClause where_clause;
std::vector<std::unique_ptr<TraitItem>> trait_items;
- Location locus;
+ location_t locus;
public:
std::string as_string () const override;
std::vector<std::unique_ptr<TypeParamBound>> type_param_bounds,
WhereClause where_clause,
std::vector<std::unique_ptr<TraitItem>> trait_items, Visibility vis,
- AST::AttrVec outer_attrs, Location locus)
+ AST::AttrVec outer_attrs, location_t locus)
: VisItem (std::move (mappings), std::move (vis), std::move (outer_attrs)),
unsafety (unsafety), name (std::move (name)),
generic_params (std::move (generic_params)),
std::unique_ptr<TypePath> trait_ref;
WhereClause where_clause;
Polarity polarity;
- Location locus;
+ location_t locus;
std::vector<std::unique_ptr<ImplItem>> impl_items;
public:
std::unique_ptr<Type> impl_type,
std::unique_ptr<TypePath> trait_ref, WhereClause where_clause,
Polarity polarity, Visibility vis, AST::AttrVec inner_attrs,
- AST::AttrVec outer_attrs, Location locus)
+ AST::AttrVec outer_attrs, location_t locus)
: VisItem (std::move (mappings), std::move (vis), std::move (outer_attrs)),
WithInnerAttrs (std::move (inner_attrs)),
generic_params (std::move (generic_params)),
AST::AttrVec outer_attrs;
Visibility visibility;
Identifier item_name;
- Location locus;
+ location_t locus;
public:
enum class ExternKind
protected:
ExternalItem (Analysis::NodeMapping mappings, Identifier item_name,
- Visibility vis, AST::AttrVec outer_attrs, Location locus)
+ Visibility vis, AST::AttrVec outer_attrs, location_t locus)
: mappings (mappings), outer_attrs (std::move (outer_attrs)),
visibility (std::move (vis)), item_name (std::move (item_name)),
locus (locus)
public:
ExternalStaticItem (Analysis::NodeMapping mappings, Identifier item_name,
std::unique_ptr<Type> item_type, Mutability mut,
- Visibility vis, AST::AttrVec outer_attrs, Location locus)
+ Visibility vis, AST::AttrVec outer_attrs,
+ location_t locus)
: ExternalItem (std::move (mappings), std::move (item_name),
std::move (vis), std::move (outer_attrs), locus),
mut (mut), item_type (std::move (item_type))
std::vector<std::unique_ptr<GenericParam>> generic_params,
std::unique_ptr<Type> return_type, WhereClause where_clause,
std::vector<NamedFunctionParam> function_params, bool has_variadics,
- Visibility vis, AST::AttrVec outer_attrs, Location locus)
+ Visibility vis, AST::AttrVec outer_attrs, location_t locus)
: ExternalItem (std::move (mappings), std::move (item_name),
std::move (vis), std::move (outer_attrs), locus),
generic_params (std::move (generic_params)),
{
ABI abi;
std::vector<std::unique_ptr<ExternalItem>> extern_items;
- Location locus;
+ location_t locus;
public:
std::string as_string () const override;
ExternBlock (Analysis::NodeMapping mappings, ABI abi,
std::vector<std::unique_ptr<ExternalItem>> extern_items,
Visibility vis, AST::AttrVec inner_attrs,
- AST::AttrVec outer_attrs, Location locus)
+ AST::AttrVec outer_attrs, location_t locus)
: VisItem (std::move (mappings), std::move (vis), std::move (outer_attrs)),
WithInnerAttrs (std::move (inner_attrs)), abi (abi),
extern_items (std::move (extern_items)), locus (locus)
Identifier identifier;
std::unique_ptr<Type> type;
- Location locus;
+ location_t locus;
public:
// Returns whether binding is in an error state.
// Pointer type for type in constructor to enable polymorphism
GenericArgsBinding (Identifier ident, std::unique_ptr<Type> type_ptr,
- Location locus = UNDEF_LOCATION)
+ location_t locus = UNDEF_LOCATION)
: identifier (std::move (ident)), type (std::move (type_ptr)), locus (locus)
{}
// at name-resolution, hence no need for ambiguities here
public:
- ConstGenericArg (std::unique_ptr<Expr> expression, Location locus)
+ ConstGenericArg (std::unique_ptr<Expr> expression, location_t locus)
: expression (std::move (expression)), locus (locus)
{}
private:
std::unique_ptr<Expr> expression;
- Location locus;
+ location_t locus;
};
class GenericArgs
std::vector<std::unique_ptr<Type> > type_args;
std::vector<GenericArgsBinding> binding_args;
std::vector<ConstGenericArg> const_args;
- Location locus;
+ location_t locus;
public:
// Returns true if there are any generic arguments
GenericArgs (std::vector<Lifetime> lifetime_args,
std::vector<std::unique_ptr<Type> > type_args,
std::vector<GenericArgsBinding> binding_args,
- std::vector<ConstGenericArg> const_args, Location locus)
+ std::vector<ConstGenericArg> const_args, location_t locus)
: lifetime_args (std::move (lifetime_args)),
type_args (std::move (type_args)),
binding_args (std::move (binding_args)),
GenericArgs &operator= (GenericArgs &&other) = default;
// Creates an empty GenericArgs (no arguments)
- static GenericArgs create_empty (Location locus = UNDEF_LOCATION)
+ static GenericArgs create_empty (location_t locus = UNDEF_LOCATION)
{
return GenericArgs ({}, {}, {}, {}, locus);
}
Analysis::NodeMapping mappings;
PathIdentSegment segment_name;
GenericArgs generic_args;
- Location locus;
+ location_t locus;
public:
PathExprSegment (Analysis::NodeMapping mappings,
- PathIdentSegment segment_name, Location locus,
+ PathIdentSegment segment_name, location_t locus,
GenericArgs generic_args)
: mappings (std::move (mappings)), segment_name (std::move (segment_name)),
generic_args (std::move (generic_args)), locus (locus)
class PathInExpression : public PathPattern, public PathExpr
{
bool has_opening_scope_resolution;
- Location locus;
+ location_t locus;
public:
std::string as_string () const override;
// Constructor
PathInExpression (Analysis::NodeMapping mappings,
std::vector<PathExprSegment> path_segments,
- Location locus = UNDEF_LOCATION,
+ location_t locus = UNDEF_LOCATION,
bool has_opening_scope_resolution = false,
std::vector<AST::Attribute> outer_attrs
= std::vector<AST::Attribute> ())
private:
Analysis::NodeMapping mappings;
PathIdentSegment ident_segment;
- Location locus;
+ location_t locus;
protected:
bool has_separating_scope_resolution;
TypePathSegment (Analysis::NodeMapping mappings,
PathIdentSegment ident_segment,
- bool has_separating_scope_resolution, Location locus)
+ bool has_separating_scope_resolution, location_t locus)
: mappings (std::move (mappings)),
ident_segment (std::move (ident_segment)), locus (locus),
has_separating_scope_resolution (has_separating_scope_resolution),
{}
TypePathSegment (Analysis::NodeMapping mappings, std::string segment_name,
- bool has_separating_scope_resolution, Location locus)
+ bool has_separating_scope_resolution, location_t locus)
: mappings (std::move (mappings)),
ident_segment (PathIdentSegment (std::move (segment_name))),
locus (locus),
TypePathSegmentGeneric (Analysis::NodeMapping mappings,
PathIdentSegment ident_segment,
bool has_separating_scope_resolution,
- GenericArgs generic_args, Location locus)
+ GenericArgs generic_args, location_t locus)
: TypePathSegment (std::move (mappings), std::move (ident_segment),
has_separating_scope_resolution, locus),
generic_args (std::move (generic_args))
std::vector<std::unique_ptr<Type> > type_args,
std::vector<GenericArgsBinding> binding_args,
std::vector<ConstGenericArg> const_args,
- Location locus)
+ location_t locus)
: TypePathSegment (std::move (mappings), std::move (segment_name),
has_separating_scope_resolution, locus),
generic_args (
TypePathSegmentFunction (Analysis::NodeMapping mappings,
PathIdentSegment ident_segment,
bool has_separating_scope_resolution,
- TypePathFunction function_path, Location locus)
+ TypePathFunction function_path, location_t locus)
: TypePathSegment (std::move (mappings), std::move (ident_segment),
has_separating_scope_resolution, locus),
function_path (std::move (function_path))
TypePathSegmentFunction (Analysis::NodeMapping mappings,
std::string segment_name,
bool has_separating_scope_resolution,
- TypePathFunction function_path, Location locus)
+ TypePathFunction function_path, location_t locus)
: TypePathSegment (std::move (mappings), std::move (segment_name),
has_separating_scope_resolution, locus),
function_path (std::move (function_path))
// Constructor
TypePath (Analysis::NodeMapping mappings,
std::vector<std::unique_ptr<TypePathSegment> > segments,
- Location locus, bool has_opening_scope_resolution = false)
+ location_t locus, bool has_opening_scope_resolution = false)
: TypeNoBounds (mappings, locus),
has_opening_scope_resolution (has_opening_scope_resolution),
segments (std::move (segments))
{
std::unique_ptr<Type> type;
std::unique_ptr<TypePath> trait;
- Location locus;
+ location_t locus;
Analysis::NodeMapping mappings;
public:
// Constructor
QualifiedPathType (Analysis::NodeMapping mappings, std::unique_ptr<Type> type,
- std::unique_ptr<TypePath> trait, Location locus)
+ std::unique_ptr<TypePath> trait, location_t locus)
: type (std::move (type)), trait (std::move (trait)), locus (locus),
mappings (mappings)
{}
class QualifiedPathInExpression : public PathPattern, public PathExpr
{
QualifiedPathType path_type;
- Location locus;
+ location_t locus;
public:
std::string as_string () const override;
QualifiedPathInExpression (Analysis::NodeMapping mappings,
QualifiedPathType qual_path_type,
std::vector<PathExprSegment> path_segments,
- Location locus = UNDEF_LOCATION,
+ location_t locus = UNDEF_LOCATION,
std::vector<AST::Attribute> outer_attrs
= std::vector<AST::Attribute> ())
: PathPattern (std::move (path_segments)),
Analysis::NodeMapping mappings, QualifiedPathType qual_path_type,
std::unique_ptr<TypePathSegment> associated_segment,
std::vector<std::unique_ptr<TypePathSegment> > path_segments,
- Location locus = UNDEF_LOCATION)
+ location_t locus = UNDEF_LOCATION)
: TypeNoBounds (mappings, locus), path_type (std::move (qual_path_type)),
associated_segment (std::move (associated_segment)),
segments (std::move (path_segments))
{
std::vector<SimplePathSegment> segments;
Analysis::NodeMapping mappings;
- Location locus;
+ location_t locus;
public:
SimplePath (std::vector<SimplePathSegment> segments,
- Analysis::NodeMapping mappings, Location locus)
+ Analysis::NodeMapping mappings, location_t locus)
: segments (std::move (segments)), mappings (mappings), locus (locus)
{}
class LiteralPattern : public Pattern
{
Literal lit;
- Location locus;
+ location_t locus;
Analysis::NodeMapping mappings;
public:
std::string as_string () const override;
// Constructor for a literal pattern
- LiteralPattern (Analysis::NodeMapping mappings, Literal lit, Location locus)
+ LiteralPattern (Analysis::NodeMapping mappings, Literal lit, location_t locus)
: lit (std::move (lit)), locus (locus), mappings (mappings)
{}
LiteralPattern (Analysis::NodeMapping mappings, std::string val,
- Literal::LitType type, Location locus)
+ Literal::LitType type, location_t locus)
: lit (Literal (std::move (val), type, PrimitiveCoreType::CORETYPE_STR)),
locus (locus), mappings (mappings)
{}
bool is_ref;
Mutability mut;
std::unique_ptr<Pattern> to_bind;
- Location locus;
+ location_t locus;
Analysis::NodeMapping mappings;
public:
// Constructor
IdentifierPattern (Analysis::NodeMapping mappings, Identifier ident,
- Location locus, bool is_ref = false,
+ location_t locus, bool is_ref = false,
Mutability mut = Mutability::Imm,
std::unique_ptr<Pattern> to_bind = nullptr)
: variable_ident (std::move (ident)), is_ref (is_ref), mut (mut),
// HIR node for using the '_' wildcard "match any value" pattern
class WildcardPattern : public Pattern
{
- Location locus;
+ location_t locus;
Analysis::NodeMapping mappings;
public:
std::string as_string () const override { return std::string (1, '_'); }
- WildcardPattern (Analysis::NodeMapping mappings, Location locus)
+ WildcardPattern (Analysis::NodeMapping mappings, location_t locus)
: locus (locus), mappings (mappings)
{}
// Minus prefixed to literal (if integer or floating-point)
bool has_minus;
- Location locus;
+ location_t locus;
public:
// Constructor
- RangePatternBoundLiteral (Literal literal, Location locus,
+ RangePatternBoundLiteral (Literal literal, location_t locus,
bool has_minus = false)
: literal (literal), has_minus (has_minus), locus (locus)
{}
/* location only stored to avoid a dereference - lower pattern should give
* correct location so maybe change in future */
- Location locus;
+ location_t locus;
Analysis::NodeMapping mappings;
public:
// Constructor
RangePattern (Analysis::NodeMapping mappings,
std::unique_ptr<RangePatternBound> lower,
- std::unique_ptr<RangePatternBound> upper, Location locus,
+ std::unique_ptr<RangePatternBound> upper, location_t locus,
bool has_ellipsis_syntax = false)
: lower (std::move (lower)), upper (std::move (upper)),
has_ellipsis_syntax (has_ellipsis_syntax), locus (locus),
{
Mutability mut;
std::unique_ptr<Pattern> pattern;
- Location locus;
+ location_t locus;
Analysis::NodeMapping mappings;
public:
ReferencePattern (Analysis::NodeMapping mappings,
std::unique_ptr<Pattern> pattern, Mutability reference_mut,
- Location locus)
+ location_t locus)
: mut (reference_mut), pattern (std::move (pattern)), locus (locus),
mappings (mappings)
{}
class StructPatternField
{
AST::AttrVec outer_attrs;
- Location locus;
+ location_t locus;
Analysis::NodeMapping mappings;
public:
protected:
StructPatternField (Analysis::NodeMapping mappings,
- AST::AttrVec outer_attribs, Location locus)
+ AST::AttrVec outer_attribs, location_t locus)
: outer_attrs (std::move (outer_attribs)), locus (locus),
mappings (mappings)
{}
public:
StructPatternFieldTuplePat (Analysis::NodeMapping mappings, TupleIndex index,
std::unique_ptr<Pattern> tuple_pattern,
- AST::AttrVec outer_attribs, Location locus)
+ AST::AttrVec outer_attribs, location_t locus)
: StructPatternField (mappings, std::move (outer_attribs), locus),
index (index), tuple_pattern (std::move (tuple_pattern))
{}
public:
StructPatternFieldIdentPat (Analysis::NodeMapping mappings, Identifier ident,
std::unique_ptr<Pattern> ident_pattern,
- AST::AttrVec outer_attrs, Location locus)
+ AST::AttrVec outer_attrs, location_t locus)
: StructPatternField (mappings, std::move (outer_attrs), locus),
ident (std::move (ident)), ident_pattern (std::move (ident_pattern))
{}
public:
StructPatternFieldIdent (Analysis::NodeMapping mappings, Identifier ident,
bool is_ref, Mutability mut,
- AST::AttrVec outer_attrs, Location locus)
+ AST::AttrVec outer_attrs, location_t locus)
: StructPatternField (mappings, std::move (outer_attrs), locus),
has_ref (is_ref), mut (mut), ident (std::move (ident))
{}
class TuplePattern : public Pattern
{
std::unique_ptr<TuplePatternItems> items;
- Location locus;
+ location_t locus;
Analysis::NodeMapping mappings;
public:
bool has_tuple_pattern_items () const { return items != nullptr; }
TuplePattern (Analysis::NodeMapping mappings,
- std::unique_ptr<TuplePatternItems> items, Location locus)
+ std::unique_ptr<TuplePatternItems> items, location_t locus)
: items (std::move (items)), locus (locus), mappings (mappings)
{}
class SlicePattern : public Pattern
{
std::vector<std::unique_ptr<Pattern>> items;
- Location locus;
+ location_t locus;
Analysis::NodeMapping mappings;
public:
std::string as_string () const override;
SlicePattern (Analysis::NodeMapping mappings,
- std::vector<std::unique_ptr<Pattern>> items, Location locus)
+ std::vector<std::unique_ptr<Pattern>> items, location_t locus)
: items (std::move (items)), locus (locus), mappings (mappings)
{}
class AltPattern : public Pattern
{
std::vector<std::unique_ptr<Pattern>> alts;
- Location locus;
+ location_t locus;
Analysis::NodeMapping mappings;
public:
std::string as_string () const override;
AltPattern (Analysis::NodeMapping mappings,
- std::vector<std::unique_ptr<Pattern>> alts, Location locus)
+ std::vector<std::unique_ptr<Pattern>> alts, location_t locus)
: alts (std::move (alts)), locus (locus), mappings (mappings)
{}
// Just a semi-colon, which apparently is a statement.
class EmptyStmt : public Stmt
{
- Location locus;
+ location_t locus;
public:
std::string as_string () const override { return std::string (1, ';'); }
- EmptyStmt (Analysis::NodeMapping mappings, Location locus)
+ EmptyStmt (Analysis::NodeMapping mappings, location_t locus)
: Stmt (std::move (mappings)), locus (locus)
{}
// bool has_init_expr;
std::unique_ptr<Expr> init_expr;
- Location locus;
+ location_t locus;
public:
// Returns whether let statement has outer attributes.
LetStmt (Analysis::NodeMapping mappings,
std::unique_ptr<Pattern> variables_pattern,
std::unique_ptr<Expr> init_expr, std::unique_ptr<Type> type,
- AST::AttrVec outer_attrs, Location locus)
+ AST::AttrVec outer_attrs, location_t locus)
: Stmt (std::move (mappings)), outer_attrs (std::move (outer_attrs)),
variables_pattern (std::move (variables_pattern)),
type (std::move (type)), init_expr (std::move (init_expr)), locus (locus)
class ExprStmt : public Stmt
{
std::unique_ptr<Expr> expr;
- Location locus;
+ location_t locus;
bool must_be_unit;
public:
ExprStmt (Analysis::NodeMapping mappings, std::unique_ptr<Expr> expr,
- Location locus, bool must_be_unit)
+ location_t locus, bool must_be_unit)
: Stmt (std::move (mappings)), expr (std::move (expr)), locus (locus),
must_be_unit (must_be_unit)
{}
ExprStmt (Analysis::NodeMapping mappings, std::unique_ptr<Expr> expr,
- Location locus)
+ location_t locus)
: ExprStmt (std::move (mappings), std::move (expr), locus, false)
{}
bool opening_question_mark;
std::vector<LifetimeParam> for_lifetimes;
TypePath type_path;
- Location locus;
+ location_t locus;
Analysis::NodeMapping mappings;
// Returns whether trait bound has "for" lifetimes
bool has_for_lifetimes () const { return !for_lifetimes.empty (); }
- TraitBound (Analysis::NodeMapping mapping, TypePath type_path, Location locus,
- bool in_parens = false, bool opening_question_mark = false,
+ TraitBound (Analysis::NodeMapping mapping, TypePath type_path,
+ location_t locus, bool in_parens = false,
+ bool opening_question_mark = false,
std::vector<LifetimeParam> for_lifetimes
= std::vector<LifetimeParam> ())
: in_parens (in_parens), opening_question_mark (opening_question_mark),
public:
ImplTraitType (Analysis::NodeMapping mappings,
std::vector<std::unique_ptr<TypeParamBound>> type_param_bounds,
- Location locus)
+ location_t locus)
: Type (mappings, locus), type_param_bounds (std::move (type_param_bounds))
{}
TraitObjectType (
Analysis::NodeMapping mappings,
std::vector<std::unique_ptr<TypeParamBound>> type_param_bounds,
- Location locus, bool is_dyn_dispatch)
+ location_t locus, bool is_dyn_dispatch)
: Type (mappings, locus), has_dyn (is_dyn_dispatch),
type_param_bounds (std::move (type_param_bounds))
{}
public:
// Constructor uses Type pointer for polymorphism
ParenthesisedType (Analysis::NodeMapping mappings,
- std::unique_ptr<Type> type_inside_parens, Location locus)
+ std::unique_ptr<Type> type_inside_parens, location_t locus)
: TypeNoBounds (mappings, locus),
type_in_parens (std::move (type_inside_parens))
{}
public:
ImplTraitTypeOneBound (Analysis::NodeMapping mappings, TraitBound trait_bound,
- Location locus)
+ location_t locus)
: TypeNoBounds (mappings, locus), trait_bound (std::move (trait_bound))
{}
bool is_unit_type () const { return elems.empty (); }
TupleType (Analysis::NodeMapping mappings,
- std::vector<std::unique_ptr<Type>> elems, Location locus)
+ std::vector<std::unique_ptr<Type>> elems, location_t locus)
: TypeNoBounds (mappings, locus), elems (std::move (elems))
{}
}
public:
- NeverType (Analysis::NodeMapping mappings, Location locus)
+ NeverType (Analysis::NodeMapping mappings, location_t locus)
: TypeNoBounds (mappings, locus)
{}
public:
// Constructor requires pointer for polymorphism reasons
RawPointerType (Analysis::NodeMapping mappings, Mutability mut,
- std::unique_ptr<Type> type, Location locus)
+ std::unique_ptr<Type> type, location_t locus)
: TypeNoBounds (mappings, locus), mut (mut), type (std::move (type))
{}
// Constructor
ReferenceType (Analysis::NodeMapping mappings, Mutability mut,
- std::unique_ptr<Type> type_no_bounds, Location locus,
+ std::unique_ptr<Type> type_no_bounds, location_t locus,
Lifetime lifetime)
: TypeNoBounds (mappings, locus), lifetime (std::move (lifetime)),
mut (mut), type (std::move (type_no_bounds))
public:
// Constructor requires pointers for polymorphism
ArrayType (Analysis::NodeMapping mappings, std::unique_ptr<Type> type,
- std::unique_ptr<Expr> array_size, Location locus)
+ std::unique_ptr<Expr> array_size, location_t locus)
: TypeNoBounds (mappings, locus), elem_type (std::move (type)),
size (std::move (array_size))
{}
public:
// Constructor requires pointer for polymorphism
SliceType (Analysis::NodeMapping mappings, std::unique_ptr<Type> type,
- Location locus)
+ location_t locus)
: TypeNoBounds (mappings, locus), elem_type (std::move (type))
{}
}
public:
- InferredType (Analysis::NodeMapping mappings, Location locus)
+ InferredType (Analysis::NodeMapping mappings, location_t locus)
: TypeNoBounds (mappings, locus)
{}
ParamKind param_kind;
Identifier name; // technically, can be an identifier or '_'
- Location locus;
+ location_t locus;
public:
MaybeNamedParam (Identifier name, ParamKind param_kind,
- std::unique_ptr<Type> param_type, Location locus)
+ std::unique_ptr<Type> param_type, location_t locus)
: param_type (std::move (param_type)), param_kind (param_kind),
name (std::move (name)), locus (locus)
{}
std::vector<LifetimeParam> lifetime_params,
FunctionQualifiers qualifiers,
std::vector<MaybeNamedParam> named_params, bool is_variadic,
- std::unique_ptr<Type> type, Location locus)
+ std::unique_ptr<Type> type, location_t locus)
: TypeNoBounds (mappings, locus),
for_lifetimes (std::move (lifetime_params)),
function_qualifiers (std::move (qualifiers)),
}
// kind of a HACK to get locus depending on opening scope resolution
- Location locus = UNKNOWN_LOCATION;
+ location_t locus = UNKNOWN_LOCATION;
if (with_opening_scope_resolution)
{
locus = simple_segments[0].get_locus () - 2; // minus 2 chars for ::
virtual Location get_locus () const { return locus; }
protected:
- Type (Analysis::NodeMapping mappings, Location locus)
+ Type (Analysis::NodeMapping mappings, location_t locus)
: mappings (mappings), locus (locus)
{}
virtual Type *clone_type_impl () const = 0;
Analysis::NodeMapping mappings;
- Location locus;
+ location_t locus;
};
// A type without parentheses? - abstract
}
protected:
- TypeNoBounds (Analysis::NodeMapping mappings, Location locus)
+ TypeNoBounds (Analysis::NodeMapping mappings, location_t locus)
: Type (mappings, locus)
{}
private:
AST::Lifetime::LifetimeType lifetime_type;
std::string lifetime_name;
- Location locus;
+ location_t locus;
Analysis::NodeMapping mappings;
public:
// Constructor
Lifetime (Analysis::NodeMapping mapping, AST::Lifetime::LifetimeType type,
- std::string name, Location locus)
+ std::string name, location_t locus)
: lifetime_type (type), lifetime_name (std::move (name)), locus (locus),
mappings (mapping)
{}
// std::unique_ptr<Attribute> outer_attr;
AST::Attribute outer_attr;
- Location locus;
+ location_t locus;
public:
Lifetime get_lifetime () { return lifetime; }
// Constructor
LifetimeParam (Analysis::NodeMapping mappings, Lifetime lifetime,
- Location locus = UNDEF_LOCATION,
+ location_t locus = UNDEF_LOCATION,
std::vector<Lifetime> lifetime_bounds
= std::vector<Lifetime> (),
AST::Attribute outer_attr = AST::Attribute::create_empty ())
public:
ConstGenericParam (std::string name, std::unique_ptr<Type> type,
std::unique_ptr<Expr> default_expression,
- Analysis::NodeMapping mapping, Location locus)
+ Analysis::NodeMapping mapping, location_t locus)
: GenericParam (mapping, GenericKind::CONST), name (std::move (name)),
type (std::move (type)),
default_expression (std::move (default_expression)), locus (locus)
/* Optional - can be a null pointer if there is no default expression */
std::unique_ptr<Expr> default_expression;
- Location locus;
+ location_t locus;
};
// Item used in trait declarations - abstract base class
// Token kind.
TokenId token_id;
// Token location.
- Location locus;
+ location_t locus;
// Associated text (if any) of token.
std::unique_ptr<std::string> str;
// TODO: maybe remove issues and just store std::string as value?
* private constructor */
// Makes and returns a new TokenPtr (with null string).
- static TokenPtr make (TokenId token_id, Location locus)
+ static TokenPtr make (TokenId token_id, location_t locus)
{
// return std::make_shared<Token> (token_id, locus);
return TokenPtr (new Token (token_id, locus));
}
// Makes and returns a new TokenPtr of type IDENTIFIER.
- static TokenPtr make_identifier (Location locus, std::string &&str)
+ static TokenPtr make_identifier (location_t locus, std::string &&str)
{
// return std::make_shared<Token> (IDENTIFIER, locus, str);
return TokenPtr (new Token (IDENTIFIER, locus, std::move (str)));
}
// Makes and returns a new TokenPtr of type INT_LITERAL.
- static TokenPtr make_int (Location locus, std::string &&str,
+ static TokenPtr make_int (location_t locus, std::string &&str,
PrimitiveCoreType type_hint = CORETYPE_UNKNOWN)
{
// return std::make_shared<Token> (INT_LITERAL, locus, str, type_hint);
}
// Makes and returns a new TokenPtr of type FLOAT_LITERAL.
- static TokenPtr make_float (Location locus, std::string &&str,
+ static TokenPtr make_float (location_t locus, std::string &&str,
PrimitiveCoreType type_hint = CORETYPE_UNKNOWN)
{
// return std::make_shared<Token> (FLOAT_LITERAL, locus, str, type_hint);
}
// Makes and returns a new TokenPtr of type STRING_LITERAL.
- static TokenPtr make_string (Location locus, std::string &&str)
+ static TokenPtr make_string (location_t locus, std::string &&str)
{
// return std::make_shared<Token> (STRING_LITERAL, locus, str,
// CORETYPE_STR);
}
// Makes and returns a new TokenPtr of type CHAR_LITERAL.
- static TokenPtr make_char (Location locus, Codepoint char_lit)
+ static TokenPtr make_char (location_t locus, Codepoint char_lit)
{
// return std::make_shared<Token> (CHAR_LITERAL, locus, char_lit);
return TokenPtr (new Token (CHAR_LITERAL, locus, char_lit));
}
// Makes and returns a new TokenPtr of type BYTE_CHAR_LITERAL.
- static TokenPtr make_byte_char (Location locus, char byte_char)
+ static TokenPtr make_byte_char (location_t locus, char byte_char)
{
// return std::make_shared<Token> (BYTE_CHAR_LITERAL, locus, byte_char);
return TokenPtr (new Token (BYTE_CHAR_LITERAL, locus, byte_char));
}
// Makes and returns a new TokenPtr of type BYTE_STRING_LITERAL (fix).
- static TokenPtr make_byte_string (Location locus, std::string &&str)
+ static TokenPtr make_byte_string (location_t locus, std::string &&str)
{
// return std::make_shared<Token> (BYTE_STRING_LITERAL, locus, str);
return TokenPtr (new Token (BYTE_STRING_LITERAL, locus, std::move (str)));
}
// Makes and returns a new TokenPtr of type INNER_DOC_COMMENT.
- static TokenPtr make_inner_doc_comment (Location locus, std::string &&str)
+ static TokenPtr make_inner_doc_comment (location_t locus, std::string &&str)
{
return TokenPtr (new Token (INNER_DOC_COMMENT, locus, std::move (str)));
}
// Makes and returns a new TokenPtr of type OUTER_DOC_COMMENT.
- static TokenPtr make_outer_doc_comment (Location locus, std::string &&str)
+ static TokenPtr make_outer_doc_comment (location_t locus, std::string &&str)
{
return TokenPtr (new Token (OUTER_DOC_COMMENT, locus, std::move (str)));
}
// Makes and returns a new TokenPtr of type LIFETIME.
- static TokenPtr make_lifetime (Location locus, std::string &&str)
+ static TokenPtr make_lifetime (location_t locus, std::string &&str)
{
// return std::make_shared<Token> (LIFETIME, locus, str);
return TokenPtr (new Token (LIFETIME, locus, std::move (str)));
Location get_locus () const { return locus; }
// Set location of the token.
- void set_locus (Location locus) { this->locus = locus; }
+ void set_locus (location_t locus) { this->locus = locus; }
// Gets string description of the token.
const std::string &
}
bool
-ExternCrate::load (Location locus)
+ExternCrate::load (location_t locus)
{
// match header
import_stream.require_bytes (locus, Metadata::kMagicHeader,
// Turn a string into a integer with appropriate error handling.
bool
-ExternCrate::string_to_int (Location locus, const std::string &s,
+ExternCrate::string_to_int (location_t locus, const std::string &s,
bool is_neg_ok, int *ret)
{
char *end;
bool ok () const;
- bool load (Location locus);
+ bool load (location_t locus);
const std::string &get_crate_name () const;
const std::string &get_metadata () const;
- static bool string_to_int (Location locus, const std::string &s,
+ static bool string_to_int (location_t locus, const std::string &s,
bool is_neg_ok, int *ret);
private:
Parser<ManagedTokenSource>::parse_doc_comment ()
{
const_TokenPtr token = lexer.peek_token ();
- Location locus = token->get_locus ();
+ location_t locus = token->get_locus ();
AST::SimplePathSegment segment ("doc", locus);
std::vector<AST::SimplePathSegment> segments;
segments.push_back (std::move (segment));
std::tuple<AST::SimplePath, std::unique_ptr<AST::AttrInput>, Location>
Parser<ManagedTokenSource>::parse_attribute_body ()
{
- Location locus = lexer.peek_token ()->get_locus ();
+ location_t locus = lexer.peek_token ()->get_locus ();
AST::SimplePath attr_path = parse_simple_path ();
// ensure path is valid to parse attribute input
Parser<ManagedTokenSource>::parse_simple_path ()
{
bool has_opening_scope_resolution = false;
- Location locus = UNKNOWN_LOCATION;
+ location_t locus = UNKNOWN_LOCATION;
// don't parse anything if not a path upfront
if (!is_simple_path_segment (lexer.peek_token ()->get_id ())
// e.g. `macro foo($e:expr) {}`
// parse macro matcher
- Location locus = lexer.peek_token ()->get_locus ();
+ location_t locus = lexer.peek_token ()->get_locus ();
AST::MacroMatcher matcher = parse_macro_matcher ();
if (matcher.is_error ())
return nullptr;
AST::MacroRule
Parser<ManagedTokenSource>::parse_macro_rule ()
{
- Location locus = lexer.peek_token ()->get_locus ();
+ location_t locus = lexer.peek_token ()->get_locus ();
// parse macro matcher
AST::MacroMatcher matcher = parse_macro_matcher ();
// Map tokens to DelimType
const_TokenPtr t = lexer.peek_token ();
- Location locus = t->get_locus ();
+ location_t locus = t->get_locus ();
switch (t->get_id ())
{
case LEFT_PAREN:
Parser<ManagedTokenSource>::parse_module (AST::Visibility vis,
AST::AttrVec outer_attrs)
{
- Location locus = lexer.peek_token ()->get_locus ();
+ location_t locus = lexer.peek_token ()->get_locus ();
skip_token (MOD);
const_TokenPtr module_name = expect_token (IDENTIFIER);
Parser<ManagedTokenSource>::parse_extern_crate (AST::Visibility vis,
AST::AttrVec outer_attrs)
{
- Location locus = lexer.peek_token ()->get_locus ();
+ location_t locus = lexer.peek_token ()->get_locus ();
if (!skip_token (EXTERN_TOK))
{
skip_after_semicolon ();
Parser<ManagedTokenSource>::parse_use_decl (AST::Visibility vis,
AST::AttrVec outer_attrs)
{
- Location locus = lexer.peek_token ()->get_locus ();
+ location_t locus = lexer.peek_token ()->get_locus ();
if (!skip_token (USE))
{
skip_after_semicolon ();
// TODO: I think this function is too complex, probably should split it
- Location locus = lexer.peek_token ()->get_locus ();
+ location_t locus = lexer.peek_token ()->get_locus ();
// bool has_path = false;
AST::SimplePath path = parse_simple_path ();
Parser<ManagedTokenSource>::parse_function (AST::Visibility vis,
AST::AttrVec outer_attrs)
{
- Location locus = lexer.peek_token ()->get_locus ();
+ location_t locus = lexer.peek_token ()->get_locus ();
// Get qualifiers for function if they exist
AST::FunctionQualifiers qualifiers = parse_function_qualifiers ();
// Check in order of const, unsafe, then extern
const_TokenPtr t = lexer.peek_token ();
- Location locus = t->get_locus ();
+ location_t locus = t->get_locus ();
switch (t->get_id ())
{
case CONST:
AST::AttrVec outer_attrs = parse_outer_attributes ();
// TODO: should saved location be at start of outer attributes or pattern?
- Location locus = lexer.peek_token ()->get_locus ();
+ location_t locus = lexer.peek_token ()->get_locus ();
std::unique_ptr<AST::Pattern> param_pattern = parse_pattern ();
// create error function param if it doesn't exist
std::vector<AST::Lifetime> lifetime_bounds = parse_lifetime_bounds ();
// TODO: have end token passed in?
- Location locus = lifetime.get_locus ();
+ location_t locus = lifetime.get_locus ();
return std::unique_ptr<AST::LifetimeWhereClauseItem> (
new AST::LifetimeWhereClauseItem (std::move (lifetime),
std::vector<std::unique_ptr<AST::TypeParamBound>> type_param_bounds
= parse_type_param_bounds ();
- Location locus = lexer.peek_token ()->get_locus ();
+ location_t locus = lexer.peek_token ()->get_locus ();
return std::unique_ptr<AST::TypeBoundWhereClauseItem> (
new AST::TypeBoundWhereClauseItem (std::move (for_lifetimes),
bool has_parens = false;
bool has_question_mark = false;
- Location locus = lexer.peek_token ()->get_locus ();
+ location_t locus = lexer.peek_token ()->get_locus ();
// handle trait bound being in parentheses
if (lexer.peek_token ()->get_id () == LEFT_PAREN)
AST::Lifetime
Parser<ManagedTokenSource>::lifetime_from_token (const_TokenPtr tok)
{
- Location locus = tok->get_locus ();
+ location_t locus = tok->get_locus ();
std::string lifetime_ident = tok->get_str ();
if (lifetime_ident == "'static")
Parser<ManagedTokenSource>::parse_external_type_item (AST::Visibility vis,
AST::AttrVec outer_attrs)
{
- Location locus = lexer.peek_token ()->get_locus ();
+ location_t locus = lexer.peek_token ()->get_locus ();
skip_token (TYPE);
const_TokenPtr alias_name_tok = expect_token (IDENTIFIER);
Parser<ManagedTokenSource>::parse_type_alias (AST::Visibility vis,
AST::AttrVec outer_attrs)
{
- Location locus = lexer.peek_token ()->get_locus ();
+ location_t locus = lexer.peek_token ()->get_locus ();
skip_token (TYPE);
// TODO: use this token for identifier when finished that
* struct_fields? '}' | ';' ) */
/* Tuple struct <- 'struct' IDENTIFIER generic_params? '(' tuple_fields? ')'
* where_clause? ';' */
- Location locus = lexer.peek_token ()->get_locus ();
+ location_t locus = lexer.peek_token ()->get_locus ();
skip_token (STRUCT_TOK);
// parse struct name
// parse visibility, if it exists
AST::Visibility vis = parse_visibility ();
- Location locus = lexer.peek_token ()->get_locus ();
+ location_t locus = lexer.peek_token ()->get_locus ();
// parse field name
const_TokenPtr field_name_tok = lexer.peek_token ();
// parse visibility if it exists
AST::Visibility vis = parse_visibility ();
- Location locus = lexer.peek_token ()->get_locus ();
+ location_t locus = lexer.peek_token ()->get_locus ();
// parse type, which is required
std::unique_ptr<AST::Type> field_type = parse_type ();
Parser<ManagedTokenSource>::parse_enum (AST::Visibility vis,
AST::AttrVec outer_attrs)
{
- Location locus = lexer.peek_token ()->get_locus ();
+ location_t locus = lexer.peek_token ()->get_locus ();
skip_token (ENUM_TOK);
// parse enum name
* item switch) */
const_TokenPtr union_keyword = expect_token (IDENTIFIER);
rust_assert (union_keyword->get_str () == "union");
- Location locus = union_keyword->get_locus ();
+ location_t locus = union_keyword->get_locus ();
// parse actual union name
const_TokenPtr union_name_tok = expect_token (IDENTIFIER);
Parser<ManagedTokenSource>::parse_const_item (AST::Visibility vis,
AST::AttrVec outer_attrs)
{
- Location locus = lexer.peek_token ()->get_locus ();
+ location_t locus = lexer.peek_token ()->get_locus ();
skip_token (CONST);
/* get constant identifier - this is either a proper identifier or the _
Parser<ManagedTokenSource>::parse_static_item (AST::Visibility vis,
AST::AttrVec outer_attrs)
{
- Location locus = lexer.peek_token ()->get_locus ();
+ location_t locus = lexer.peek_token ()->get_locus ();
skip_token (STATIC_TOK);
// determine whether static item is mutable
Parser<ManagedTokenSource>::parse_trait (AST::Visibility vis,
AST::AttrVec outer_attrs)
{
- Location locus = lexer.peek_token ()->get_locus ();
+ location_t locus = lexer.peek_token ()->get_locus ();
bool is_unsafe = false;
bool is_auto_trait = false;
std::unique_ptr<AST::TraitItemType>
Parser<ManagedTokenSource>::parse_trait_type (AST::AttrVec outer_attrs)
{
- Location locus = lexer.peek_token ()->get_locus ();
+ location_t locus = lexer.peek_token ()->get_locus ();
skip_token (TYPE);
const_TokenPtr ident_tok = expect_token (IDENTIFIER);
std::unique_ptr<AST::TraitItemConst>
Parser<ManagedTokenSource>::parse_trait_const (AST::AttrVec outer_attrs)
{
- Location locus = lexer.peek_token ()->get_locus ();
+ location_t locus = lexer.peek_token ()->get_locus ();
skip_token (CONST);
// parse constant item name
/* Note that only trait impls are allowed to be unsafe. So if unsafe, it
* must be a trait impl. However, this isn't enough for full disambiguation,
* so don't branch here. */
- Location locus = lexer.peek_token ()->get_locus ();
+ location_t locus = lexer.peek_token ()->get_locus ();
bool is_unsafe = false;
if (lexer.peek_token ()->get_id () == UNSAFE)
{
Parser<ManagedTokenSource>::parse_inherent_impl_function_or_method (
AST::Visibility vis, AST::AttrVec outer_attrs)
{
- Location locus = lexer.peek_token ()->get_locus ();
+ location_t locus = lexer.peek_token ()->get_locus ();
// parse function or method qualifiers
AST::FunctionQualifiers qualifiers = parse_function_qualifiers ();
// this shares virtually all logic with
// parse_inherent_impl_function_or_method
// - template?
- Location locus = lexer.peek_token ()->get_locus ();
+ location_t locus = lexer.peek_token ()->get_locus ();
auto is_default = false;
auto t = lexer.peek_token ();
Parser<ManagedTokenSource>::parse_extern_block (AST::Visibility vis,
AST::AttrVec outer_attrs)
{
- Location locus = lexer.peek_token ()->get_locus ();
+ location_t locus = lexer.peek_token ()->get_locus ();
skip_token (EXTERN_TOK);
// detect optional abi name
// parse optional outer attributes
AST::AttrVec outer_attrs = parse_outer_attributes ();
- Location locus = lexer.peek_token ()->get_locus ();
+ location_t locus = lexer.peek_token ()->get_locus ();
// parse optional visibility
AST::Visibility vis = parse_visibility ();
Parser<ManagedTokenSource>::parse_let_stmt (AST::AttrVec outer_attrs,
ParseRestrictions restrictions)
{
- Location locus = lexer.peek_token ()->get_locus ();
+ location_t locus = lexer.peek_token ()->get_locus ();
skip_token (LET);
// parse pattern (required)
Parser<ManagedTokenSource>::parse_type_path ()
{
bool has_opening_scope_resolution = false;
- Location locus = lexer.peek_token ()->get_locus ();
+ location_t locus = lexer.peek_token ()->get_locus ();
if (lexer.peek_token ()->get_id () == SCOPE_RESOLUTION)
{
has_opening_scope_resolution = true;
std::vector<AST::Lifetime> lifetime_args;
const_TokenPtr t = lexer.peek_token ();
- Location locus = t->get_locus ();
+ location_t locus = t->get_locus ();
while (!is_right_angle_tok (t->get_id ()))
{
AST::Lifetime lifetime = parse_lifetime ();
std::unique_ptr<AST::TypePathSegment>
Parser<ManagedTokenSource>::parse_type_path_segment ()
{
- Location locus = lexer.peek_token ()->get_locus ();
+ location_t locus = lexer.peek_token ()->get_locus ();
// parse ident segment part
AST::PathIdentSegment ident_segment = parse_path_ident_segment ();
if (ident_segment.is_error ())
AST::PathInExpression
Parser<ManagedTokenSource>::parse_path_in_expression ()
{
- Location locus = UNKNOWN_LOCATION;
+ location_t locus = UNKNOWN_LOCATION;
bool has_opening_scope_resolution = false;
if (lexer.peek_token ()->get_id () == SCOPE_RESOLUTION)
{
AST::PathExprSegment
Parser<ManagedTokenSource>::parse_path_expr_segment ()
{
- Location locus = lexer.peek_token ()->get_locus ();
+ location_t locus = lexer.peek_token ()->get_locus ();
// parse ident segment
AST::PathIdentSegment ident = parse_path_ident_segment ();
if (ident.is_error ())
// TODO: should this create a parse error?
return AST::QualifiedPathInExpression::create_error ();
}
- Location locus = qual_path_type.get_locus ();
+ location_t locus = qual_path_type.get_locus ();
// parse path segments
std::vector<AST::PathExprSegment> segments;
Parser<ManagedTokenSource>::parse_qualified_path_type (
Location pratt_parsed_loc)
{
- Location locus = pratt_parsed_loc;
+ location_t locus = pratt_parsed_loc;
/* TODO: should this actually be error? is there anywhere where this could
* be valid? */
if (locus == UNKNOWN_LOCATION)
AST::QualifiedPathInType
Parser<ManagedTokenSource>::parse_qualified_path_in_type ()
{
- Location locus = lexer.peek_token ()->get_locus ();
+ location_t locus = lexer.peek_token ()->get_locus ();
// parse the qualified path type (required)
AST::QualifiedPathType qual_path_type = parse_qualified_path_type ();
if (qual_path_type.is_error ())
bool has_reference = false;
AST::Lifetime lifetime = AST::Lifetime::error ();
- Location locus = lexer.peek_token ()->get_locus ();
+ location_t locus = lexer.peek_token ()->get_locus ();
// test if self is a reference parameter
if (lexer.peek_token ()->get_id () == AMP)
AST::Method
Parser<ManagedTokenSource>::parse_method ()
{
- Location locus = lexer.peek_token ()->get_locus ();
+ location_t locus = lexer.peek_token ()->get_locus ();
/* Note: as a result of the above, this will not attempt to disambiguate a
* function parse qualifiers */
AST::FunctionQualifiers qualifiers = parse_function_qualifiers ();
Parser<ManagedTokenSource>::parse_expr_stmt (AST::AttrVec outer_attrs,
ParseRestrictions restrictions)
{
- Location locus = lexer.peek_token ()->get_locus ();
+ location_t locus = lexer.peek_token ()->get_locus ();
std::unique_ptr<AST::Expr> expr;
Parser<ManagedTokenSource>::parse_block_expr (AST::AttrVec outer_attrs,
Location pratt_parsed_loc)
{
- Location locus = pratt_parsed_loc;
+ location_t locus = pratt_parsed_loc;
if (locus == UNKNOWN_LOCATION)
{
locus = lexer.peek_token ()->get_locus ();
std::unique_ptr<AST::GroupedExpr>
Parser<ManagedTokenSource>::parse_grouped_expr (AST::AttrVec outer_attrs)
{
- Location locus = lexer.peek_token ()->get_locus ();
+ location_t locus = lexer.peek_token ()->get_locus ();
skip_token (LEFT_PAREN);
AST::AttrVec inner_attrs = parse_inner_attributes ();
std::unique_ptr<AST::ClosureExpr>
Parser<ManagedTokenSource>::parse_closure_expr (AST::AttrVec outer_attrs)
{
- Location locus = lexer.peek_token ()->get_locus ();
+ location_t locus = lexer.peek_token ()->get_locus ();
// detect optional "move"
bool has_move = false;
if (lexer.peek_token ()->get_id () == MOVE)
Parser<ManagedTokenSource>::parse_return_expr (AST::AttrVec outer_attrs,
Location pratt_parsed_loc)
{
- Location locus = pratt_parsed_loc;
+ location_t locus = pratt_parsed_loc;
if (locus == UNKNOWN_LOCATION)
{
locus = lexer.peek_token ()->get_locus ();
Parser<ManagedTokenSource>::parse_break_expr (AST::AttrVec outer_attrs,
Location pratt_parsed_loc)
{
- Location locus = pratt_parsed_loc;
+ location_t locus = pratt_parsed_loc;
if (locus == UNKNOWN_LOCATION)
{
locus = lexer.peek_token ()->get_locus ();
Parser<ManagedTokenSource>::parse_continue_expr (AST::AttrVec outer_attrs,
Location pratt_parsed_loc)
{
- Location locus = pratt_parsed_loc;
+ location_t locus = pratt_parsed_loc;
if (locus == UNKNOWN_LOCATION)
{
locus = lexer.peek_token ()->get_locus ();
Location pratt_parsed_loc)
{
// TODO: make having outer attributes an error?
- Location locus = pratt_parsed_loc;
+ location_t locus = pratt_parsed_loc;
if (locus == UNKNOWN_LOCATION)
{
locus = lexer.peek_token ()->get_locus ();
Location pratt_parsed_loc)
{
// TODO: make having outer attributes an error?
- Location locus = pratt_parsed_loc;
+ location_t locus = pratt_parsed_loc;
if (locus == UNKNOWN_LOCATION)
{
locus = lexer.peek_token ()->get_locus ();
AST::LoopLabel label,
Location pratt_parsed_loc)
{
- Location locus = pratt_parsed_loc;
+ location_t locus = pratt_parsed_loc;
if (locus == UNKNOWN_LOCATION)
{
if (label.is_error ())
AST::LoopLabel label,
Location pratt_parsed_loc)
{
- Location locus = pratt_parsed_loc;
+ location_t locus = pratt_parsed_loc;
if (locus == UNKNOWN_LOCATION)
{
if (label.is_error ())
Parser<ManagedTokenSource>::parse_while_let_loop_expr (AST::AttrVec outer_attrs,
AST::LoopLabel label)
{
- Location locus = UNKNOWN_LOCATION;
+ location_t locus = UNKNOWN_LOCATION;
if (label.is_error ())
locus = lexer.peek_token ()->get_locus ();
else
Parser<ManagedTokenSource>::parse_for_loop_expr (AST::AttrVec outer_attrs,
AST::LoopLabel label)
{
- Location locus = UNKNOWN_LOCATION;
+ location_t locus = UNKNOWN_LOCATION;
if (label.is_error ())
locus = lexer.peek_token ()->get_locus ();
else
Parser<ManagedTokenSource>::parse_match_expr (AST::AttrVec outer_attrs,
Location pratt_parsed_loc)
{
- Location locus = pratt_parsed_loc;
+ location_t locus = pratt_parsed_loc;
if (locus == UNKNOWN_LOCATION)
{
locus = lexer.peek_token ()->get_locus ();
std::unique_ptr<AST::AsyncBlockExpr>
Parser<ManagedTokenSource>::parse_async_block_expr (AST::AttrVec outer_attrs)
{
- Location locus = lexer.peek_token ()->get_locus ();
+ location_t locus = lexer.peek_token ()->get_locus ();
skip_token (ASYNC);
// detect optional move token
Parser<ManagedTokenSource>::parse_unsafe_block_expr (AST::AttrVec outer_attrs,
Location pratt_parsed_loc)
{
- Location locus = pratt_parsed_loc;
+ location_t locus = pratt_parsed_loc;
if (locus == UNKNOWN_LOCATION)
{
locus = lexer.peek_token ()->get_locus ();
Parser<ManagedTokenSource>::parse_array_expr (AST::AttrVec outer_attrs,
Location pratt_parsed_loc)
{
- Location locus = pratt_parsed_loc;
+ location_t locus = pratt_parsed_loc;
if (locus == UNKNOWN_LOCATION)
{
locus = lexer.peek_token ()->get_locus ();
AST::AttrVec outer_attrs, Location pratt_parsed_loc)
{
// adjustment to allow Pratt parsing to reuse function without copy-paste
- Location locus = pratt_parsed_loc;
+ location_t locus = pratt_parsed_loc;
if (locus == UNKNOWN_LOCATION)
{
locus = lexer.peek_token ()->get_locus ();
return nullptr;
}
- Location locus = path.get_locus ();
+ location_t locus = path.get_locus ();
// branch on next token
t = lexer.peek_token ();
return nullptr;
}
- Location locus = t->get_locus ();
+ location_t locus = t->get_locus ();
// short cut if next token isn't '+'
t = lexer.peek_token ();
template <typename ManagedTokenSource>
std::unique_ptr<AST::ReferenceType>
-Parser<ManagedTokenSource>::parse_reference_type_inner (Location locus)
+Parser<ManagedTokenSource>::parse_reference_type_inner (location_t locus)
{
// parse optional lifetime
AST::Lifetime lifetime = AST::Lifetime::error ();
std::unique_ptr<AST::RawPointerType>
Parser<ManagedTokenSource>::parse_raw_pointer_type ()
{
- Location locus = lexer.peek_token ()->get_locus ();
+ location_t locus = lexer.peek_token ()->get_locus ();
skip_token (ASTERISK);
AST::RawPointerType::PointerType kind = AST::RawPointerType::CONST;
std::unique_ptr<AST::TypeNoBounds>
Parser<ManagedTokenSource>::parse_slice_or_array_type ()
{
- Location locus = lexer.peek_token ()->get_locus ();
+ location_t locus = lexer.peek_token ()->get_locus ();
skip_token (LEFT_SQUARE);
// parse inner type (required)
return nullptr;
}
- Location locus = path.get_locus ();
+ location_t locus = path.get_locus ();
// branch on next token
t = lexer.peek_token ();
return nullptr;
}
- Location locus = t->get_locus ();
+ location_t locus = t->get_locus ();
// ensure not a trait with multiple bounds
t = lexer.peek_token ();
return nullptr;
}
- Location locus = t->get_locus ();
+ location_t locus = t->get_locus ();
// detect error with plus as next token
t = lexer.peek_token ();
std::unique_ptr<AST::IdentifierPattern>
Parser<ManagedTokenSource>::parse_identifier_pattern ()
{
- Location locus = lexer.peek_token ()->get_locus ();
+ location_t locus = lexer.peek_token ()->get_locus ();
bool has_ref = false;
if (lexer.peek_token ()->get_id () == REF)
return nullptr;
// TODO: check types. actually, do so during semantic analysis
- Location locus = left->get_locus ();
+ location_t locus = left->get_locus ();
return std::unique_ptr<AST::ArithmeticOrLogicalExpr> (
new AST::ArithmeticOrLogicalExpr (std::move (left), std::move (right),
return nullptr;
// TODO: check types. actually, do so during semantic analysis
- Location locus = left->get_locus ();
+ location_t locus = left->get_locus ();
return std::unique_ptr<AST::ArithmeticOrLogicalExpr> (
new AST::ArithmeticOrLogicalExpr (std::move (left), std::move (right),
return nullptr;
// TODO: check types. actually, do so during semantic analysis
- Location locus = left->get_locus ();
+ location_t locus = left->get_locus ();
return std::unique_ptr<AST::ArithmeticOrLogicalExpr> (
new AST::ArithmeticOrLogicalExpr (std::move (left), std::move (right),
return nullptr;
// TODO: check types. actually, do so during semantic analysis
- Location locus = left->get_locus ();
+ location_t locus = left->get_locus ();
return std::unique_ptr<AST::ArithmeticOrLogicalExpr> (
new AST::ArithmeticOrLogicalExpr (std::move (left), std::move (right),
return nullptr;
// TODO: check types. actually, do so during semantic analysis
- Location locus = left->get_locus ();
+ location_t locus = left->get_locus ();
return std::unique_ptr<AST::ArithmeticOrLogicalExpr> (
new AST::ArithmeticOrLogicalExpr (std::move (left), std::move (right),
return nullptr;
// TODO: check types. actually, do so during semantic analysis
- Location locus = left->get_locus ();
+ location_t locus = left->get_locus ();
return std::unique_ptr<AST::ArithmeticOrLogicalExpr> (
new AST::ArithmeticOrLogicalExpr (std::move (left), std::move (right),
return nullptr;
// TODO: check types. actually, do so during semantic analysis
- Location locus = left->get_locus ();
+ location_t locus = left->get_locus ();
return std::unique_ptr<AST::ArithmeticOrLogicalExpr> (
new AST::ArithmeticOrLogicalExpr (std::move (left), std::move (right),
return nullptr;
// TODO: check types. actually, do so during semantic analysis
- Location locus = left->get_locus ();
+ location_t locus = left->get_locus ();
return std::unique_ptr<AST::ArithmeticOrLogicalExpr> (
new AST::ArithmeticOrLogicalExpr (std::move (left), std::move (right),
return nullptr;
// TODO: check types. actually, do so during semantic analysis
- Location locus = left->get_locus ();
+ location_t locus = left->get_locus ();
return std::unique_ptr<AST::ArithmeticOrLogicalExpr> (
new AST::ArithmeticOrLogicalExpr (std::move (left), std::move (right),
return nullptr;
// TODO: check types. actually, do so during semantic analysis
- Location locus = left->get_locus ();
+ location_t locus = left->get_locus ();
return std::unique_ptr<AST::ArithmeticOrLogicalExpr> (
new AST::ArithmeticOrLogicalExpr (std::move (left), std::move (right),
return nullptr;
// TODO: check types. actually, do so during semantic analysis
- Location locus = left->get_locus ();
+ location_t locus = left->get_locus ();
return std::unique_ptr<AST::ArithmeticOrLogicalExpr> (
new AST::ArithmeticOrLogicalExpr (std::move (left), std::move (right),
return nullptr;
// TODO: check types. actually, do so during semantic analysis
- Location locus = left->get_locus ();
+ location_t locus = left->get_locus ();
return std::unique_ptr<AST::ComparisonExpr> (
new AST::ComparisonExpr (std::move (left), std::move (right), expr_type,
return nullptr;
// TODO: check types. actually, do so during semantic analysis
- Location locus = left->get_locus ();
+ location_t locus = left->get_locus ();
return std::unique_ptr<AST::ComparisonExpr> (
new AST::ComparisonExpr (std::move (left), std::move (right),
return nullptr;
// TODO: check types. actually, do so during semantic analysis
- Location locus = left->get_locus ();
+ location_t locus = left->get_locus ();
return std::unique_ptr<AST::ComparisonExpr> (
new AST::ComparisonExpr (std::move (left), std::move (right),
return nullptr;
// TODO: check types. actually, do so during semantic analysis
- Location locus = left->get_locus ();
+ location_t locus = left->get_locus ();
return std::unique_ptr<AST::ComparisonExpr> (
new AST::ComparisonExpr (std::move (left), std::move (right),
return nullptr;
// TODO: check types. actually, do so during semantic analysis
- Location locus = left->get_locus ();
+ location_t locus = left->get_locus ();
return std::unique_ptr<AST::ComparisonExpr> (
new AST::ComparisonExpr (std::move (left), std::move (right),
return nullptr;
// TODO: check types. actually, do so during semantic analysis
- Location locus = left->get_locus ();
+ location_t locus = left->get_locus ();
return std::unique_ptr<AST::ComparisonExpr> (
new AST::ComparisonExpr (std::move (left), std::move (right),
return nullptr;
// TODO: check types. actually, do so during semantic analysis
- Location locus = left->get_locus ();
+ location_t locus = left->get_locus ();
return std::unique_ptr<AST::ComparisonExpr> (
new AST::ComparisonExpr (std::move (left), std::move (right),
return nullptr;
// TODO: check types. actually, do so during semantic analysis
- Location locus = left->get_locus ();
+ location_t locus = left->get_locus ();
return std::unique_ptr<AST::LazyBooleanExpr> (
new AST::LazyBooleanExpr (std::move (left), std::move (right),
return nullptr;
// TODO: check types. actually, do so during semantic analysis
- Location locus = left->get_locus ();
+ location_t locus = left->get_locus ();
return std::unique_ptr<AST::LazyBooleanExpr> (
new AST::LazyBooleanExpr (std::move (left), std::move (right),
// FIXME: how do I get precedence put in here?
// TODO: check types. actually, do so during semantic analysis
- Location locus = expr_to_cast->get_locus ();
+ location_t locus = expr_to_cast->get_locus ();
return std::unique_ptr<AST::TypeCastExpr> (
new AST::TypeCastExpr (std::move (expr_to_cast), std::move (type), locus));
// FIXME: ensure right-associativity for this - 'LBP - 1' may do this?
// TODO: check types. actually, do so during semantic analysis
- Location locus = left->get_locus ();
+ location_t locus = left->get_locus ();
return std::unique_ptr<AST::AssignmentExpr> (
new AST::AssignmentExpr (std::move (left), std::move (right),
// FIXME: ensure right-associativity for this - 'LBP - 1' may do this?
// TODO: check types. actually, do so during semantic analysis
- Location locus = left->get_locus ();
+ location_t locus = left->get_locus ();
return std::unique_ptr<AST::CompoundAssignmentExpr> (
new AST::CompoundAssignmentExpr (std::move (left), std::move (right),
// FIXME: ensure right-associativity for this - 'LBP - 1' may do this?
// TODO: check types. actually, do so during semantic analysis
- Location locus = left->get_locus ();
+ location_t locus = left->get_locus ();
return std::unique_ptr<AST::CompoundAssignmentExpr> (
new AST::CompoundAssignmentExpr (std::move (left), std::move (right),
// FIXME: ensure right-associativity for this - 'LBP - 1' may do this?
// TODO: check types. actually, do so during semantic analysis
- Location locus = left->get_locus ();
+ location_t locus = left->get_locus ();
return std::unique_ptr<AST::CompoundAssignmentExpr> (
new AST::CompoundAssignmentExpr (std::move (left), std::move (right),
// FIXME: ensure right-associativity for this - 'LBP - 1' may do this?
// TODO: check types. actually, do so during semantic analysis
- Location locus = left->get_locus ();
+ location_t locus = left->get_locus ();
return std::unique_ptr<AST::CompoundAssignmentExpr> (
new AST::CompoundAssignmentExpr (std::move (left), std::move (right),
// FIXME: ensure right-associativity for this - 'LBP - 1' may do this?
// TODO: check types. actually, do so during semantic analysis
- Location locus = left->get_locus ();
+ location_t locus = left->get_locus ();
return std::unique_ptr<AST::CompoundAssignmentExpr> (
new AST::CompoundAssignmentExpr (std::move (left), std::move (right),
// FIXME: ensure right-associativity for this - 'LBP - 1' may do this?
// TODO: check types. actually, do so during semantic analysis
- Location locus = left->get_locus ();
+ location_t locus = left->get_locus ();
return std::unique_ptr<AST::CompoundAssignmentExpr> (
new AST::CompoundAssignmentExpr (std::move (left), std::move (right),
// FIXME: ensure right-associativity for this - 'LBP - 1' may do this?
// TODO: check types. actually, do so during semantic analysis
- Location locus = left->get_locus ();
+ location_t locus = left->get_locus ();
return std::unique_ptr<AST::CompoundAssignmentExpr> (
new AST::CompoundAssignmentExpr (std::move (left), std::move (right),
// FIXME: ensure right-associativity for this - 'LBP - 1' may do this?
// TODO: check types. actually, do so during semantic analysis
- Location locus = left->get_locus ();
+ location_t locus = left->get_locus ();
return std::unique_ptr<AST::CompoundAssignmentExpr> (
new AST::CompoundAssignmentExpr (std::move (left), std::move (right),
// FIXME: ensure right-associativity for this - 'LBP - 1' may do this?
// TODO: check types. actually, do so during semantic analysis
- Location locus = left->get_locus ();
+ location_t locus = left->get_locus ();
return std::unique_ptr<AST::CompoundAssignmentExpr> (
new AST::CompoundAssignmentExpr (std::move (left), std::move (right),
// FIXME: ensure right-associativity for this - 'LBP - 1' may do this?
// TODO: check types. actually, do so during semantic analysis
- Location locus = left->get_locus ();
+ location_t locus = left->get_locus ();
return std::unique_ptr<AST::CompoundAssignmentExpr> (
new AST::CompoundAssignmentExpr (std::move (left), std::move (right),
// FIXME: ensure right-associativity for this - 'LBP - 1' may do this?
// TODO: check types. actually, do so during semantic analysis
- Location locus = left->get_locus ();
+ location_t locus = left->get_locus ();
return std::unique_ptr<AST::CompoundAssignmentExpr> (
new AST::CompoundAssignmentExpr (std::move (left), std::move (right),
}
// TODO: check inside async block in semantic analysis
- Location locus = expr_to_await->get_locus ();
+ location_t locus = expr_to_await->get_locus ();
return std::unique_ptr<AST::AwaitExpr> (
new AST::AwaitExpr (std::move (expr_to_await), std::move (outer_attrs),
std::unique_ptr<AST::Expr> right
= parse_expr (LBP_DOT_DOT, AST::AttrVec (), restrictions);
- Location locus = left->get_locus ();
+ location_t locus = left->get_locus ();
if (right == nullptr)
{
std::unique_ptr<AST::Expr> right
= parse_expr (LBP_DOT_DOT, AST::AttrVec (), restrictions);
- Location locus = tok->get_locus ();
+ location_t locus = tok->get_locus ();
if (right == nullptr)
{
// FIXME: make non-associative
// TODO: check types. actually, do so during semantic analysis
- Location locus = left->get_locus ();
+ location_t locus = left->get_locus ();
return std::unique_ptr<AST::RangeFromToInclExpr> (
new AST::RangeFromToInclExpr (std::move (left), std::move (right), locus));
}
int index_int = atoi (index.c_str ());
- Location locus = tuple_expr->get_locus ();
+ location_t locus = tuple_expr->get_locus ();
return std::unique_ptr<AST::TupleIndexExpr> (
new AST::TupleIndexExpr (std::move (tuple_expr), index_int,
}
// TODO: check types. actually, do so during semantic analysis
- Location locus = array_expr->get_locus ();
+ location_t locus = array_expr->get_locus ();
return std::unique_ptr<AST::ArrayIndexExpr> (
new AST::ArrayIndexExpr (std::move (array_expr), std::move (index_expr),
Identifier ident{ident_tok};
- Location locus = struct_expr->get_locus ();
+ location_t locus = struct_expr->get_locus ();
// TODO: check types. actually, do so during semantic analysis
return std::unique_ptr<AST::FieldAccessExpr> (
}
// TODO: check types. actually do so in semantic analysis pass.
- Location locus = receiver_expr->get_locus ();
+ location_t locus = receiver_expr->get_locus ();
return std::unique_ptr<AST::MethodCallExpr> (
new AST::MethodCallExpr (std::move (receiver_expr), std::move (segment),
}
// TODO: check types. actually, do so during semantic analysis
- Location locus = function_expr->get_locus ();
+ location_t locus = function_expr->get_locus ();
return std::unique_ptr<AST::CallExpr> (
new AST::CallExpr (std::move (function_expr), std::move (params),
{
// TODO: does this need pratt parsing (for precedence)? probably not, but
// idk
- Location locus = tok->get_locus ();
+ location_t locus = tok->get_locus ();
bool has_move = false;
if (tok->get_id () == MOVE)
{
// get int from string
int index = atoi (index_str.c_str ());
- Location locus = tuple_expr->get_locus ();
+ location_t locus = tuple_expr->get_locus ();
return std::unique_ptr<AST::TupleIndexExpr> (
new AST::TupleIndexExpr (std::move (tuple_expr), index,
AST::GenericArg parse_generic_arg ();
AST::GenericArgs parse_path_generic_args ();
AST::GenericArgsBinding parse_generic_args_binding ();
- AST::TypePathFunction parse_type_path_function (Location locus);
+ AST::TypePathFunction parse_type_path_function (location_t locus);
AST::PathExprSegment parse_path_expr_segment ();
AST::QualifiedPathInExpression
// When given a pratt_parsed_loc, use it as the location of the
std::unique_ptr<AST::TypeNoBounds> parse_slice_or_array_type ();
std::unique_ptr<AST::RawPointerType> parse_raw_pointer_type ();
std::unique_ptr<AST::ReferenceType>
- parse_reference_type_inner (Location locus);
+ parse_reference_type_inner (location_t locus);
std::unique_ptr<AST::ReferenceType> parse_reference_type ();
std::unique_ptr<AST::BareFunctionType>
parse_bare_function_type (std::vector<AST::LifetimeParam> for_lifetimes);
resolver->get_label_scope ().insert (
CanonicalPath::new_seg (expr.get_node_id (), label_name),
label_lifetime_node_id, label.get_locus (), false, Rib::ItemType::Label,
- [&] (const CanonicalPath &, NodeId, Location locus) -> void {
+ [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
rust_error_at (label.get_locus (), "label redefined multiple times");
rust_error_at (locus, "was defined here");
});
resolver->get_label_scope ().insert (
CanonicalPath::new_seg (label.get_node_id (), label_name),
label_lifetime_node_id, label.get_locus (), false, Rib::ItemType::Label,
- [&] (const CanonicalPath &, NodeId, Location locus) -> void {
+ [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
rust_error_at (label.get_locus (), "label redefined multiple times");
rust_error_at (locus, "was defined here");
});
resolver->get_label_scope ().insert (
CanonicalPath::new_seg (label.get_node_id (), label_name),
label_lifetime_node_id, label.get_locus (), false, Rib::ItemType::Label,
- [&] (const CanonicalPath &, NodeId, Location locus) -> void {
+ [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
rust_error_at (label.get_locus (), "label redefined multiple times");
rust_error_at (locus, "was defined here");
});
resolver->get_type_scope ().insert (
path, type.get_node_id (), type.get_locus (), false, Rib::ItemType::Type,
- [&] (const CanonicalPath &, NodeId, Location locus) -> void {
+ [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
rich_location r (line_table, type.get_locus ());
r.add_range (locus);
rust_error_at (r, "redefined multiple times");
resolver->get_name_scope ().insert (
path, constant.get_node_id (), constant.get_locus (), false,
Rib::ItemType::Const,
- [&] (const CanonicalPath &, NodeId, Location locus) -> void {
+ [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
rich_location r (line_table, constant.get_locus ());
r.add_range (locus);
rust_error_at (r, "redefined multiple times");
resolver->get_name_scope ().insert (
path, function.get_node_id (), function.get_locus (), false,
Rib::ItemType::Function,
- [&] (const CanonicalPath &, NodeId, Location locus) -> void {
+ [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
rich_location r (line_table, function.get_locus ());
r.add_range (locus);
rust_error_at (r, "redefined multiple times");
resolver->get_name_scope ().insert (
path, method.get_node_id (), method.get_locus (), false,
Rib::ItemType::Function,
- [&] (const CanonicalPath &, NodeId, Location locus) -> void {
+ [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
rich_location r (line_table, method.get_locus ());
r.add_range (locus);
rust_error_at (r, "redefined multiple times");
resolver->get_name_scope ().insert (
path, function.get_node_id (), function.get_locus (), false,
Rib::ItemType::Function,
- [&] (const CanonicalPath &, NodeId, Location locus) -> void {
+ [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
rich_location r (line_table, function.get_locus ());
r.add_range (locus);
rust_error_at (r, "redefined multiple times");
resolver->get_name_scope ().insert (
path, method.get_node_id (), method.get_locus (), false,
Rib::ItemType::Function,
- [&] (const CanonicalPath &, NodeId, Location locus) -> void {
+ [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
rich_location r (line_table, method.get_locus ());
r.add_range (locus);
rust_error_at (r, "redefined multiple times");
resolver->get_name_scope ().insert (
path, constant.get_node_id (), constant.get_locus (), false,
Rib::ItemType::Const,
- [&] (const CanonicalPath &, NodeId, Location locus) -> void {
+ [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
rich_location r (line_table, constant.get_locus ());
r.add_range (locus);
rust_error_at (r, "redefined multiple times");
resolver->get_type_scope ().insert (
path, type.get_node_id (), type.get_locus (), false, Rib::ItemType::Type,
- [&] (const CanonicalPath &, NodeId, Location locus) -> void {
+ [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
rich_location r (line_table, type.get_locus ());
r.add_range (locus);
rust_error_at (r, "redefined multiple times");
resolver->get_name_scope ().insert (
path, function.get_node_id (), function.get_locus (), false,
Rib::ItemType::Function,
- [&] (const CanonicalPath &, NodeId, Location locus) -> void {
+ [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
rich_location r (line_table, function.get_locus ());
r.add_range (locus);
rust_error_at (r, "redefined multiple times");
resolver->get_name_scope ().insert (
path, item.get_node_id (), item.get_locus (), false,
Rib::ItemType::Static,
- [&] (const CanonicalPath &, NodeId, Location locus) -> void {
+ [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
rich_location r (line_table, item.get_locus ());
r.add_range (locus);
rust_error_at (r, "redefined multiple times");
{
Mutability mut;
bool is_ref;
- Location locus;
+ location_t locus;
public:
- BindingTypeInfo (Mutability mut, bool is_ref, Location locus)
+ BindingTypeInfo (Mutability mut, bool is_ref, location_t locus)
: mut (mut), is_ref (is_ref), locus (locus)
{}
resolver->get_name_scope ().insert (
path, constant.get_node_id (), constant.get_locus (), false,
Rib::ItemType::Const,
- [&] (const CanonicalPath &, NodeId, Location locus) -> void {
+ [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
rich_location r (line_table, constant.get_locus ());
r.add_range (locus);
rust_error_at (r, "redefined multiple times");
resolver->get_type_scope ().insert (
path, struct_decl.get_node_id (), struct_decl.get_locus (), false,
Rib::ItemType::Type,
- [&] (const CanonicalPath &, NodeId, Location locus) -> void {
+ [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
rich_location r (line_table, struct_decl.get_locus ());
r.add_range (locus);
rust_error_at (r, "redefined multiple times");
resolver->get_type_scope ().insert (
path, enum_decl.get_node_id (), enum_decl.get_locus (), false,
Rib::ItemType::Type,
- [&] (const CanonicalPath &, NodeId, Location locus) -> void {
+ [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
rich_location r (line_table, enum_decl.get_locus ());
r.add_range (locus);
rust_error_at (r, "redefined multiple times");
resolver->get_type_scope ().insert (
path, item.get_node_id (), item.get_locus (), false, Rib::ItemType::Type,
- [&] (const CanonicalPath &, NodeId, Location locus) -> void {
+ [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
rich_location r (line_table, item.get_locus ());
r.add_range (locus);
rust_error_at (r, "redefined multiple times");
resolver->get_type_scope ().insert (
path, item.get_node_id (), item.get_locus (), false, Rib::ItemType::Type,
- [&] (const CanonicalPath &, NodeId, Location locus) -> void {
+ [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
rich_location r (line_table, item.get_locus ());
r.add_range (locus);
rust_error_at (r, "redefined multiple times");
resolver->get_type_scope ().insert (
path, item.get_node_id (), item.get_locus (), false, Rib::ItemType::Type,
- [&] (const CanonicalPath &, NodeId, Location locus) -> void {
+ [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
rich_location r (line_table, item.get_locus ());
r.add_range (locus);
rust_error_at (r, "redefined multiple times");
resolver->get_type_scope ().insert (
path, item.get_node_id (), item.get_locus (), false, Rib::ItemType::Type,
- [&] (const CanonicalPath &, NodeId, Location locus) -> void {
+ [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
rich_location r (line_table, item.get_locus ());
r.add_range (locus);
rust_error_at (r, "redefined multiple times");
resolver->get_type_scope ().insert (
path, struct_decl.get_node_id (), struct_decl.get_locus (), false,
Rib::ItemType::Type,
- [&] (const CanonicalPath &, NodeId, Location locus) -> void {
+ [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
rich_location r (line_table, struct_decl.get_locus ());
r.add_range (locus);
rust_error_at (r, "redefined multiple times");
resolver->get_type_scope ().insert (
path, union_decl.get_node_id (), union_decl.get_locus (), false,
Rib::ItemType::Type,
- [&] (const CanonicalPath &, NodeId, Location locus) -> void {
+ [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
rich_location r (line_table, union_decl.get_locus ());
r.add_range (locus);
rust_error_at (r, "redefined multiple times");
resolver->get_name_scope ().insert (
path, function.get_node_id (), function.get_locus (), false,
Rib::ItemType::Function,
- [&] (const CanonicalPath &, NodeId, Location locus) -> void {
+ [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
rich_location r (line_table, function.get_locus ());
r.add_range (locus);
rust_error_at (r, "redefined multiple times");
resolver->get_name_scope ().insert (
path, module.get_node_id (), module.get_locus (), false,
Rib::ItemType::Module,
- [&] (const CanonicalPath &, NodeId, Location locus) -> void {
+ [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
rich_location r (line_table, module.get_locus ());
r.add_range (locus);
rust_error_at (r, "redefined multiple times");
resolver->get_type_scope ().insert (
path, alias.get_node_id (), alias.get_locus (), false,
Rib::ItemType::Type,
- [&] (const CanonicalPath &, NodeId, Location locus) -> void {
+ [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
rich_location r (line_table, alias.get_locus ());
r.add_range (locus);
rust_error_at (r, "redefined multiple times");
resolver->get_type_scope ().insert (
path, struct_decl.get_node_id (), struct_decl.get_locus (), false,
Rib::ItemType::Type,
- [&] (const CanonicalPath &, NodeId, Location locus) -> void {
+ [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
rich_location r (line_table, struct_decl.get_locus ());
r.add_range (locus);
rust_error_at (r, "redefined multiple times");
resolver->get_type_scope ().insert (
path, enum_decl.get_node_id (), enum_decl.get_locus (), false,
Rib::ItemType::Type,
- [&] (const CanonicalPath &, NodeId, Location locus) -> void {
+ [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
rich_location r (line_table, enum_decl.get_locus ());
r.add_range (locus);
rust_error_at (r, "redefined multiple times");
resolver->get_type_scope ().insert (
path, item.get_node_id (), item.get_locus (), false, Rib::ItemType::Type,
- [&] (const CanonicalPath &, NodeId, Location locus) -> void {
+ [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
rich_location r (line_table, item.get_locus ());
r.add_range (locus);
rust_error_at (r, "redefined multiple times");
resolver->get_type_scope ().insert (
path, item.get_node_id (), item.get_locus (), false, Rib::ItemType::Type,
- [&] (const CanonicalPath &, NodeId, Location locus) -> void {
+ [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
rich_location r (line_table, item.get_locus ());
r.add_range (locus);
rust_error_at (r, "redefined multiple times");
resolver->get_type_scope ().insert (
path, item.get_node_id (), item.get_locus (), false, Rib::ItemType::Type,
- [&] (const CanonicalPath &, NodeId, Location locus) -> void {
+ [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
rich_location r (line_table, item.get_locus ());
r.add_range (locus);
rust_error_at (r, "redefined multiple times");
resolver->get_type_scope ().insert (
path, item.get_node_id (), item.get_locus (), false, Rib::ItemType::Type,
- [&] (const CanonicalPath &, NodeId, Location locus) -> void {
+ [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
rich_location r (line_table, item.get_locus ());
r.add_range (locus);
rust_error_at (r, "redefined multiple times");
resolver->get_type_scope ().insert (
path, struct_decl.get_node_id (), struct_decl.get_locus (), false,
Rib::ItemType::Type,
- [&] (const CanonicalPath &, NodeId, Location locus) -> void {
+ [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
rich_location r (line_table, struct_decl.get_locus ());
r.add_range (locus);
rust_error_at (r, "redefined multiple times");
resolver->get_type_scope ().insert (
path, union_decl.get_node_id (), union_decl.get_locus (), false,
Rib::ItemType::Type,
- [&] (const CanonicalPath &, NodeId, Location locus) -> void {
+ [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
rich_location r (line_table, union_decl.get_locus ());
r.add_range (locus);
rust_error_at (r, "redefined multiple times");
resolver->get_name_scope ().insert (
path, var.get_node_id (), var.get_locus (), false, Rib::ItemType::Static,
- [&] (const CanonicalPath &, NodeId, Location locus) -> void {
+ [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
rich_location r (line_table, var.get_locus ());
r.add_range (locus);
rust_error_at (r, "redefined multiple times");
resolver->get_name_scope ().insert (
path, constant.get_node_id (), constant.get_locus (), false,
Rib::ItemType::Const,
- [&] (const CanonicalPath &, NodeId, Location locus) -> void {
+ [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
rich_location r (line_table, constant.get_locus ());
r.add_range (locus);
rust_error_at (r, "redefined multiple times");
resolver->get_name_scope ().insert (
path, function.get_node_id (), function.get_locus (), false,
Rib::ItemType::Function,
- [&] (const CanonicalPath &, NodeId, Location locus) -> void {
+ [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
rich_location r (line_table, function.get_locus ());
r.add_range (locus);
rust_error_at (r, "redefined multiple times");
resolver->get_name_scope ().insert (
impl_prefix, impl_block.get_node_id (), impl_block.get_locus (), false,
Rib::ItemType::TraitImpl,
- [&] (const CanonicalPath &, NodeId, Location locus) -> void {
+ [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
rich_location r (line_table, impl_block.get_locus ());
r.add_range (locus);
rust_error_at (r, "redefined multiple times");
resolver->get_type_scope ().insert (
path, trait.get_node_id (), trait.get_locus (), false,
Rib::ItemType::Trait,
- [&] (const CanonicalPath &, NodeId, Location locus) -> void {
+ [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
rich_location r (line_table, trait.get_locus ());
r.add_range (locus);
rust_error_at (r, "redefined multiple times");
resolver->get_type_scope ().insert (
decl, resolved_crate, extern_crate.get_locus (), false,
Rib::ItemType::ExternCrate,
- [&] (const CanonicalPath &, NodeId, Location locus) -> void {
+ [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
rich_location r (line_table, extern_crate.get_locus ());
r.add_range (locus);
rust_error_at (r, "redefined multiple times");
param.get_type_representation ().as_string ());
resolver->get_type_scope ().insert (
seg, param.get_node_id (), param.get_locus (), false, Rib::ItemType::Type,
- [&] (const CanonicalPath &, NodeId, Location locus) -> void {
+ [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
rust_error_at (param.get_locus (),
"generic param redefined multiple times");
rust_error_at (locus, "was defined here");
void
Rib::insert_name (
- const CanonicalPath &path, NodeId id, Location locus, bool shadow,
+ const CanonicalPath &path, NodeId id, location_t locus, bool shadow,
ItemType type,
std::function<void (const CanonicalPath &, NodeId, Location)> dup_cb)
{
void
Scope::insert (
- const CanonicalPath &ident, NodeId id, Location locus, bool shadow,
+ const CanonicalPath &ident, NodeId id, location_t locus, bool shadow,
Rib::ItemType type,
std::function<void (const CanonicalPath &, NodeId, Location)> dup_cb)
{
}
void
-Scope::insert (const CanonicalPath &ident, NodeId id, Location locus,
+Scope::insert (const CanonicalPath &ident, NodeId id, location_t locus,
Rib::ItemType type)
{
peek ()->insert_name (ident, id, locus, true, type,
// this takes the relative paths of items within a compilation unit for lookup
void insert_name (
- const CanonicalPath &path, NodeId id, Location locus, bool shadow,
+ const CanonicalPath &path, NodeId id, location_t locus, bool shadow,
ItemType type,
std::function<void (const CanonicalPath &, NodeId, Location)> dup_cb);
Scope (CrateNum crate_num);
void
- insert (const CanonicalPath &ident, NodeId id, Location locus, bool shadow,
+ insert (const CanonicalPath &ident, NodeId id, location_t locus, bool shadow,
Rib::ItemType type,
std::function<void (const CanonicalPath &, NodeId, Location)> dup_cb);
- void insert (const CanonicalPath &ident, NodeId id, Location locus,
+ void insert (const CanonicalPath &ident, NodeId id, location_t locus,
Rib::ItemType type = Rib::ItemType::Unknown);
bool lookup (const CanonicalPath &ident, NodeId *id);
bool lookup_decl_type (NodeId id, Rib::ItemType *type);
* This function takes ownership of `args` and calls `va_end` on it
*/
static Error
-va_constructor (Error::Kind kind, Location locus, const char *fmt, va_list args)
- RUST_ATTRIBUTE_GCC_DIAG (3, 0);
+va_constructor (Error::Kind kind, location_t locus, const char *fmt,
+ va_list args) RUST_ATTRIBUTE_GCC_DIAG (3, 0);
static Error
-va_constructor (Error::Kind kind, Location locus, const char *fmt, va_list args)
+va_constructor (Error::Kind kind, location_t locus, const char *fmt,
+ va_list args)
{
std::string message = expand_message (fmt, args);
message.shrink_to_fit ();
};
Kind kind;
- Location locus;
+ location_t locus;
std::string message;
// TODO: store more stuff? e.g. node id?
- Error (Kind kind, Location locus, std::string message)
+ Error (Kind kind, location_t locus, std::string message)
: kind (kind), locus (locus), message (std::move (message))
{
message.shrink_to_fit ();
}
- Error (Location locus, std::string message)
+ Error (location_t locus, std::string message)
{
Error (Kind::Err, locus, std::move (message));
}
- static Error Hint (Location locus, std::string message)
+ static Error Hint (location_t locus, std::string message)
{
return Error (Kind::Hint, locus, std::move (message));
}
- static Error Fatal (Location locus, std::string message)
+ static Error Fatal (location_t locus, std::string message)
{
return Error (Kind::FatalErr, locus, std::move (message));
}
// TODO: the attribute part might be incorrect
- Error (Location locus, const char *fmt,
+ Error (location_t locus, const char *fmt,
...) /*RUST_ATTRIBUTE_GCC_DIAG (2, 3)*/ RUST_ATTRIBUTE_GCC_DIAG (3, 4);
/**
* printf-like overload of Error::Hint
*/
- static Error Hint (Location locus, const char *fmt, ...)
+ static Error Hint (location_t locus, const char *fmt, ...)
RUST_ATTRIBUTE_GCC_DIAG (2, 3);
/**
* printf-like overload of Error::Fatal
*/
- static Error Fatal (Location locus, const char *fmt, ...)
+ static Error Fatal (location_t locus, const char *fmt, ...)
RUST_ATTRIBUTE_GCC_DIAG (2, 3);
void emit () const
tree assignment_statement (tree lhs, tree rhs, Location);
- tree return_statement (tree fndecl, tree val, Location locus);
+ tree return_statement (tree fndecl, tree val, location_t locus);
tree if_statement (tree, tree condition, tree then_block, tree else_block,
Location);
tree
Gcc_backend::array_initializer (tree fndecl, tree block, tree array_type,
tree length, tree value, tree *tmp,
- Location locus)
+ location_t locus)
{
std::vector<tree> stmts;
// Loops
tree
-Gcc_backend::loop_expression (tree body, Location locus)
+Gcc_backend::loop_expression (tree body, location_t locus)
{
return fold_build1_loc (locus, LOOP_EXPR, void_type_node, body);
}
tree
-Gcc_backend::exit_expression (tree cond_tree, Location locus)
+Gcc_backend::exit_expression (tree cond_tree, location_t locus)
{
return fold_build1_loc (locus, EXIT_EXPR, void_type_node, cond_tree);
}
// imports
NodeId
-Session::load_extern_crate (const std::string &crate_name, Location locus)
+Session::load_extern_crate (const std::string &crate_name, location_t locus)
{
// has it already been loaded?
CrateNum found_crate_num = UNKNOWN_CREATENUM;
return extra_files.back ().c_str ();
}
- NodeId load_extern_crate (const std::string &crate_name, Location locus);
+ NodeId load_extern_crate (const std::string &crate_name, location_t locus);
private:
void compile_crate (const char *filename);
namespace Rust {
namespace Resolver {
-TypeCastRules::TypeCastRules (Location locus, TyTy::TyWithLocation from,
+TypeCastRules::TypeCastRules (location_t locus, TyTy::TyWithLocation from,
TyTy::TyWithLocation to)
: locus (locus), from (from), to (to)
{}
TypeCoercionRules::CoercionResult
-TypeCastRules::resolve (Location locus, TyTy::TyWithLocation from,
+TypeCastRules::resolve (location_t locus, TyTy::TyWithLocation from,
TyTy::TyWithLocation to)
{
TypeCastRules cast_rules (locus, from, to);
class TypeCastRules
{
public:
- static TypeCoercionRules::CoercionResult
- resolve (Location locus, TyTy::TyWithLocation from, TyTy::TyWithLocation to);
+ static TypeCoercionRules::CoercionResult resolve (location_t locus,
+ TyTy::TyWithLocation from,
+ TyTy::TyWithLocation to);
protected:
TypeCoercionRules::CoercionResult check ();
void emit_cast_error () const;
protected:
- TypeCastRules (Location locus, TyTy::TyWithLocation from,
+ TypeCastRules (location_t locus, TyTy::TyWithLocation from,
TyTy::TyWithLocation to);
- Location locus;
+ location_t locus;
TyTy::TyWithLocation from;
TyTy::TyWithLocation to;
};
TypeCoercionRules::CoercionResult
TypeCoercionRules::Coerce (TyTy::BaseType *receiver, TyTy::BaseType *expected,
- Location locus, bool allow_autoderef,
+ location_t locus, bool allow_autoderef,
bool is_cast_site)
{
TypeCoercionRules resolver (expected, locus, true, allow_autoderef, false,
TypeCoercionRules::CoercionResult
TypeCoercionRules::TryCoerce (TyTy::BaseType *receiver,
- TyTy::BaseType *expected, Location locus,
+ TyTy::BaseType *expected, location_t locus,
bool allow_autoderef, bool is_cast_site)
{
TypeCoercionRules resolver (expected, locus, false, allow_autoderef, true,
return ok ? resolver.try_result : CoercionResult::get_error ();
}
-TypeCoercionRules::TypeCoercionRules (TyTy::BaseType *expected, Location locus,
- bool emit_errors, bool allow_autoderef,
- bool try_flag, bool is_cast_site)
+TypeCoercionRules::TypeCoercionRules (TyTy::BaseType *expected,
+ location_t locus, bool emit_errors,
+ bool allow_autoderef, bool try_flag,
+ bool is_cast_site)
: AutoderefCycle (!allow_autoderef), mappings (Analysis::Mappings::get ()),
context (TypeCheckContext::get ()), expected (expected), locus (locus),
try_result (CoercionResult::get_error ()), emit_errors (emit_errors),
// here, we would coerce from `!` to `?T`.
if (expected->has_subsititions_defined () && !expected->is_concrete ())
{
- Location locus = mappings->lookup_location (receiver->get_ref ());
+ location_t locus = mappings->lookup_location (receiver->get_ref ());
TyTy::TyVar implicit_var
= TyTy::TyVar::get_implicit_infer_var (locus);
try_result = CoercionResult{{}, implicit_var.get_tyty ()};
};
static CoercionResult Coerce (TyTy::BaseType *receiver,
- TyTy::BaseType *expected, Location locus,
+ TyTy::BaseType *expected, location_t locus,
bool allow_autoderef,
bool is_cast_site = false);
static CoercionResult TryCoerce (TyTy::BaseType *receiver,
- TyTy::BaseType *expected, Location locus,
+ TyTy::BaseType *expected, location_t locus,
bool allow_autoderef,
bool is_cast_site = false);
void object_unsafe_error (Location expr_locus, Location lhs, Location rhs);
protected:
- TypeCoercionRules (TyTy::BaseType *expected, Location locus, bool emit_errors,
- bool allow_autoderef, bool try_flag, bool is_cast_site);
+ TypeCoercionRules (TyTy::BaseType *expected, location_t locus,
+ bool emit_errors, bool allow_autoderef, bool try_flag,
+ bool is_cast_site);
bool select (TyTy::BaseType &autoderefed) override;
// search
TyTy::BaseType *expected;
- Location locus;
+ location_t locus;
// mutable fields
CoercionResult try_result;
{}
PathProbeCandidate::PathProbeCandidate (CandidateType type, TyTy::BaseType *ty,
- Location locus,
+ location_t locus,
EnumItemCandidate enum_field)
: type (type), ty (ty), locus (locus), item (enum_field)
{}
PathProbeCandidate::PathProbeCandidate (CandidateType type, TyTy::BaseType *ty,
- Location locus, ImplItemCandidate impl)
+ location_t locus,
+ ImplItemCandidate impl)
: type (type), ty (ty), locus (locus), item (impl)
{}
PathProbeCandidate::PathProbeCandidate (CandidateType type, TyTy::BaseType *ty,
- Location locus,
+ location_t locus,
TraitItemCandidate trait)
: type (type), ty (ty), locus (locus), item (trait)
{}
CandidateType type;
TyTy::BaseType *ty;
- Location locus;
+ location_t locus;
union Candidate
{
EnumItemCandidate enum_field;
Candidate (TraitItemCandidate trait);
} item;
- PathProbeCandidate (CandidateType type, TyTy::BaseType *ty, Location locus,
+ PathProbeCandidate (CandidateType type, TyTy::BaseType *ty, location_t locus,
EnumItemCandidate enum_field);
- PathProbeCandidate (CandidateType type, TyTy::BaseType *ty, Location locus,
+ PathProbeCandidate (CandidateType type, TyTy::BaseType *ty, location_t locus,
ImplItemCandidate impl);
- PathProbeCandidate (CandidateType type, TyTy::BaseType *ty, Location locus,
+ PathProbeCandidate (CandidateType type, TyTy::BaseType *ty, location_t locus,
TraitItemCandidate trait);
std::string as_string () const;
}
bool
-TraitReference::is_object_safe (bool emit_error, Location locus) const
+TraitReference::is_object_safe (bool emit_error, location_t locus) const
{
// https: // doc.rust-lang.org/reference/items/traits.html#object-safety
std::vector<const TraitReference *> non_object_super_traits;
TraitItemReference (std::string identifier, bool optional, TraitItemType type,
HIR::TraitItem *hir_trait_item, TyTy::BaseType *self,
std::vector<TyTy::SubstitutionParamMapping> substitutions,
- Location locus);
+ location_t locus);
TraitItemReference (TraitItemReference const &other);
TraitItemType type;
HIR::TraitItem *hir_trait_item;
std::vector<TyTy::SubstitutionParamMapping> inherited_substitutions;
- Location locus;
+ location_t locus;
TyTy::BaseType
*self; // this is the implict Self TypeParam required for methods
const std::vector<const TraitReference *> get_super_traits () const;
- bool is_object_safe (bool emit_error, Location locus) const;
+ bool is_object_safe (bool emit_error, location_t locus) const;
bool trait_has_generics () const;
ResolveTraitItemToRef::visit (HIR::TraitItemType &type)
{
// create trait-item-ref
- Location locus = type.get_locus ();
+ location_t locus = type.get_locus ();
bool is_optional = false;
std::string identifier = type.get_name ().as_string ();
ResolveTraitItemToRef::visit (HIR::TraitItemConst &cst)
{
// create trait-item-ref
- Location locus = cst.get_locus ();
+ location_t locus = cst.get_locus ();
bool is_optional = cst.has_expr ();
std::string identifier = cst.get_name ().as_string ();
ResolveTraitItemToRef::visit (HIR::TraitItemFunc &fn)
{
// create trait-item-ref
- Location locus = fn.get_locus ();
+ location_t locus = fn.get_locus ();
bool is_optional = fn.has_block_defined ();
std::string identifier = fn.get_decl ().get_function_name ().as_string ();
// generate inference variables for these bound arguments so we can compute
// their values
- Location locus = UNKNOWN_LOCATION;
+ location_t locus = UNKNOWN_LOCATION;
std::vector<TyTy::SubstitutionArg> subst_args;
for (auto &p : substitutions)
{
bool used = constrained_symbols.find (sym) != constrained_symbols.end ();
if (!used)
{
- Location locus = symbol_to_location.at (sym);
+ location_t locus = symbol_to_location.at (sym);
rust_error_at (locus, "unconstrained type parameter");
unconstrained = true;
}
TyTy::BaseType *
TypeCheckBase::resolve_literal (const Analysis::NodeMapping &expr_mappings,
- HIR::Literal &literal, Location locus)
+ HIR::Literal &literal, location_t locus)
{
TyTy::BaseType *infered = nullptr;
switch (literal.get_lit_type ())
}
TyTy::ADTType::ReprOptions
-TypeCheckBase::parse_repr_options (const AST::AttrVec &attrs, Location locus)
+TypeCheckBase::parse_repr_options (const AST::AttrVec &attrs, location_t locus)
{
TyTy::ADTType::ReprOptions repr;
repr.pack = 0;
const TyTy::BaseType *reference);
TyTy::BaseType *resolve_literal (const Analysis::NodeMapping &mappings,
- HIR::Literal &literal, Location locus);
+ HIR::Literal &literal, location_t locus);
TyTy::ADTType::ReprOptions parse_repr_options (const AST::AttrVec &attrs,
- Location locus);
+ location_t locus);
void resolve_generic_params (
const std::vector<std::unique_ptr<HIR::GenericParam> > &generic_params,
TyTy::BaseType *
TypeCheckItem::ResolveImplBlockSelfWithInference (
- HIR::ImplBlock &impl, Location locus,
+ HIR::ImplBlock &impl, location_t locus,
TyTy::SubstitutionArgumentMappings *infer_arguments)
{
TypeCheckItem resolver;
static TyTy::BaseType *ResolveImplBlockSelf (HIR::ImplBlock &impl_block);
static TyTy::BaseType *ResolveImplBlockSelfWithInference (
- HIR::ImplBlock &impl, Location locus,
+ HIR::ImplBlock &impl, location_t locus,
TyTy::SubstitutionArgumentMappings *infer_arguments);
void visit (HIR::Module &module) override;
}
else if (tyseg->needs_generic_substitutions () && !reciever_is_generic)
{
- Location locus = seg.get_locus ();
+ location_t locus = seg.get_locus ();
tyseg = SubstMapper::InferSubst (tyseg, locus);
if (tyseg->get_kind () == TyTy::TypeKind::ERROR)
return;
rust_assert (resolved_node_id != UNKNOWN_NODEID);
if (tyseg->needs_generic_substitutions () && !reciever_is_generic)
{
- Location locus = segments.back ().get_locus ();
+ location_t locus = segments.back ().get_locus ();
tyseg = SubstMapper::InferSubst (tyseg, locus);
if (tyseg->get_kind () == TyTy::TypeKind::ERROR)
return;
TyTy::BaseType *
TypeCheckPattern::typecheck_range_pattern_bound (
std::unique_ptr<Rust::HIR::RangePatternBound> &bound,
- Analysis::NodeMapping mappings, Location locus)
+ Analysis::NodeMapping mappings, location_t locus)
{
TyTy::BaseType *resolved_bound = nullptr;
switch (bound->get_bound_type ())
TyTy::BaseType *typecheck_range_pattern_bound (
std::unique_ptr<Rust::HIR::RangePatternBound> &bound,
- Analysis::NodeMapping mappings, Location locus);
+ Analysis::NodeMapping mappings, location_t locus);
void emit_pattern_size_error (const HIR::Pattern &pattern,
size_t expected_field_count,
context->insert_receiver (expr_mappings.get_hirid (), prev_segment);
if (tyseg->needs_generic_substitutions ())
{
- // Location locus = segments.back ()->get_locus ();
+ // location_t locus = segments.back ()->get_locus ();
if (!prev_segment->needs_generic_substitutions ())
{
auto used_args_in_prev_segment
void visit (HIR::TypePathSegmentGeneric &generic);
private:
- TypeCheckResolveGenericArguments (Location locus)
+ TypeCheckResolveGenericArguments (location_t locus)
: TypeCheckBase (), args (HIR::GenericArgs::create_empty (locus))
{}
TraitItemReference::TraitItemReference (
std::string identifier, bool optional, TraitItemType type,
HIR::TraitItem *hir_trait_item, TyTy::BaseType *self,
- std::vector<TyTy::SubstitutionParamMapping> substitutions, Location locus)
+ std::vector<TyTy::SubstitutionParamMapping> substitutions, location_t locus)
: identifier (identifier), optional_flag (optional), type (type),
hir_trait_item (hir_trait_item),
inherited_substitutions (std::move (substitutions)), locus (locus),
void iterate (std::function<bool (HirId, TyTy::BaseType *)> cb);
bool have_loop_context () const;
- void push_new_loop_context (HirId id, Location locus);
+ void push_new_loop_context (HirId id, location_t locus);
void push_new_while_loop_context (HirId id);
TyTy::BaseType *peek_loop_context ();
TyTy::BaseType *pop_loop_context ();
namespace Rust {
namespace Resolver {
-SubstMapper::SubstMapper (HirId ref, HIR::GenericArgs *generics, Location locus)
+SubstMapper::SubstMapper (HirId ref, HIR::GenericArgs *generics,
+ location_t locus)
: resolved (new TyTy::ErrorType (ref)), generics (generics), locus (locus)
{}
TyTy::BaseType *
-SubstMapper::Resolve (TyTy::BaseType *base, Location locus,
+SubstMapper::Resolve (TyTy::BaseType *base, location_t locus,
HIR::GenericArgs *generics)
{
SubstMapper mapper (base->get_ref (), generics, locus);
}
TyTy::BaseType *
-SubstMapper::InferSubst (TyTy::BaseType *base, Location locus)
+SubstMapper::InferSubst (TyTy::BaseType *base, location_t locus)
{
return SubstMapper::Resolve (base, locus, nullptr);
}
class SubstMapper : public TyTy::TyVisitor
{
public:
- static TyTy::BaseType *Resolve (TyTy::BaseType *base, Location locus,
+ static TyTy::BaseType *Resolve (TyTy::BaseType *base, location_t locus,
HIR::GenericArgs *generics = nullptr);
- static TyTy::BaseType *InferSubst (TyTy::BaseType *base, Location locus);
+ static TyTy::BaseType *InferSubst (TyTy::BaseType *base, location_t locus);
bool have_generic_args () const;
void visit (TyTy::ClosureType &) override { rust_unreachable (); }
private:
- SubstMapper (HirId ref, HIR::GenericArgs *generics, Location locus);
+ SubstMapper (HirId ref, HIR::GenericArgs *generics, location_t locus);
TyTy::BaseType *resolved;
HIR::GenericArgs *generics;
- Location locus;
+ location_t locus;
};
class SubstMapperInternal : public TyTy::TyVisitor
TyTy::BaseType *
coercion_site (HirId id, TyTy::TyWithLocation lhs, TyTy::TyWithLocation rhs,
- Location locus)
+ location_t locus)
{
TyTy::BaseType *expected = lhs.get_ty ();
TyTy::BaseType *expr = rhs.get_ty ();
TyTy::BaseType *
try_coercion (HirId id, TyTy::TyWithLocation lhs, TyTy::TyWithLocation rhs,
- Location locus)
+ location_t locus)
{
TyTy::BaseType *expected = lhs.get_ty ();
TyTy::BaseType *expr = rhs.get_ty ();
}
void
-TypeCheckContext::push_new_loop_context (HirId id, Location locus)
+TypeCheckContext::push_new_loop_context (HirId id, location_t locus)
{
TyTy::BaseType *infer_var
= new TyTy::InferType (id, TyTy::InferType::InferTypeKind::GENERAL,
namespace TyTy {
TypeBoundPredicate::TypeBoundPredicate (
- const Resolver::TraitReference &trait_reference, Location locus)
+ const Resolver::TraitReference &trait_reference, location_t locus)
: SubstitutionRef ({}, SubstitutionArgumentMappings::empty ()),
reference (trait_reference.get_mappings ().get_defid ()), locus (locus),
error_flag (false)
}
TypeBoundPredicate::TypeBoundPredicate (
- DefId reference, std::vector<SubstitutionParamMapping> subst, Location locus)
+ DefId reference, std::vector<SubstitutionParamMapping> subst,
+ location_t locus)
: SubstitutionRef ({}, SubstitutionArgumentMappings::empty ()),
reference (reference), locus (locus), error_flag (false)
{
}
bool
-TypeBoundPredicate::is_object_safe (bool emit_error, Location locus) const
+TypeBoundPredicate::is_object_safe (bool emit_error, location_t locus) const
{
const Resolver::TraitReference *trait = get ();
rust_assert (trait != nullptr);
{
public:
Argument (Analysis::NodeMapping mapping, BaseType *argument_type,
- Location locus)
+ location_t locus)
: mapping (mapping), argument_type (argument_type), locus (locus)
{}
private:
Analysis::NodeMapping mapping;
BaseType *argument_type;
- Location locus;
+ location_t locus;
};
class TypeCheckMethodCallExpr
bool
SubstitutionParamMapping::fill_param_ty (
- SubstitutionArgumentMappings &subst_mappings, Location locus)
+ SubstitutionArgumentMappings &subst_mappings, location_t locus)
{
SubstitutionArg arg = SubstitutionArg::error ();
bool ok = subst_mappings.get_argument_for_symbol (get_param_ty (), &arg);
SubstitutionArgumentMappings::SubstitutionArgumentMappings (
std::vector<SubstitutionArg> mappings,
- std::map<std::string, BaseType *> binding_args, Location locus,
+ std::map<std::string, BaseType *> binding_args, location_t locus,
ParamSubstCb param_subst_cb, bool trait_item_flag, bool error_flag)
: mappings (mappings), binding_args (binding_args), locus (locus),
param_subst_cb (param_subst_cb), trait_item_flag (trait_item_flag),
}
BaseType *
-SubstitutionRef::infer_substitions (Location locus)
+SubstitutionRef::infer_substitions (location_t locus)
{
std::vector<SubstitutionArg> args;
std::map<std::string, BaseType *> argument_mappings;
std::string as_string () const;
bool fill_param_ty (SubstitutionArgumentMappings &subst_mappings,
- Location locus);
+ location_t locus);
SubstitutionParamMapping clone () const;
public:
SubstitutionArgumentMappings (std::vector<SubstitutionArg> mappings,
std::map<std::string, BaseType *> binding_args,
- Location locus,
+ location_t locus,
ParamSubstCb param_subst_cb = nullptr,
bool trait_item_flag = false,
bool error_flag = false);
private:
std::vector<SubstitutionArg> mappings;
std::map<std::string, BaseType *> binding_args;
- Location locus;
+ location_t locus;
ParamSubstCb param_subst_cb;
bool trait_item_flag;
bool error_flag;
//
// This function will inject implicit inference variables for the type
// parameters X and Y
- BaseType *infer_substitions (Location locus);
+ BaseType *infer_substitions (location_t locus);
// this clears any possible projections from higher ranked trait bounds which
// could be hanging around from a previous resolution
}
TyVar
-TyVar::get_implicit_infer_var (Location locus)
+TyVar::get_implicit_infer_var (location_t locus)
{
auto mappings = Analysis::Mappings::get ();
auto context = Resolver::TypeCheckContext::get ();
return TyVar (c->get_ref ());
}
-TyWithLocation::TyWithLocation (BaseType *ty, Location locus)
+TyWithLocation::TyWithLocation (BaseType *ty, location_t locus)
: ty (ty), locus (locus)
{}
TyVar monomorphized_clone () const;
- static TyVar get_implicit_infer_var (Location locus);
+ static TyVar get_implicit_infer_var (location_t locus);
static TyVar subst_covariant_var (TyTy::BaseType *orig,
TyTy::BaseType *subst);
class TyWithLocation
{
public:
- explicit TyWithLocation (BaseType *ty, Location locus);
+ explicit TyWithLocation (BaseType *ty, location_t locus);
explicit TyWithLocation (BaseType *ty);
BaseType *get_ty () const { return ty; }
private:
BaseType *ty;
- Location locus;
+ location_t locus;
};
} // namespace TyTy
}
bool
-BaseType::bounds_compatible (const BaseType &other, Location locus,
+BaseType::bounds_compatible (const BaseType &other, location_t locus,
bool emit_error) const
{
std::vector<std::reference_wrapper<const TypeBoundPredicate>>
// InferType
InferType::InferType (HirId ref, InferTypeKind infer_kind, TypeHint hint,
- Location locus, std::set<HirId> refs)
+ location_t locus, std::set<HirId> refs)
: BaseType (ref, ref, TypeKind::INFER,
{Resolver::CanonicalPath::create_empty (), locus}, refs),
infer_kind (infer_kind), default_hint (hint)
{}
InferType::InferType (HirId ref, HirId ty_ref, InferTypeKind infer_kind,
- TypeHint hint, Location locus, std::set<HirId> refs)
+ TypeHint hint, location_t locus, std::set<HirId> refs)
: BaseType (ref, ty_ref, TypeKind::INFER,
{Resolver::CanonicalPath::create_empty (), locus}, refs),
infer_kind (infer_kind), default_hint (hint)
// Struct Field type
StructFieldType::StructFieldType (HirId ref, std::string name, BaseType *ty,
- Location locus)
+ location_t locus)
: ref (ref), name (name), ty (ty), locus (locus)
{}
// TupleType
-TupleType::TupleType (HirId ref, Location locus, std::vector<TyVar> fields,
+TupleType::TupleType (HirId ref, location_t locus, std::vector<TyVar> fields,
std::set<HirId> refs)
: BaseType (ref, ref, TypeKind::TUPLE,
{Resolver::CanonicalPath::create_empty (), locus}, refs),
fields (fields)
{}
-TupleType::TupleType (HirId ref, HirId ty_ref, Location locus,
+TupleType::TupleType (HirId ref, HirId ty_ref, location_t locus,
std::vector<TyVar> fields, std::set<HirId> refs)
: BaseType (ref, ty_ref, TypeKind::TUPLE,
{Resolver::CanonicalPath::create_empty (), locus}, refs),
// PARAM Type
-ParamType::ParamType (std::string symbol, Location locus, HirId ref,
+ParamType::ParamType (std::string symbol, location_t locus, HirId ref,
HIR::GenericParam ¶m,
std::vector<TypeBoundPredicate> specified_bounds,
std::set<HirId> refs)
is_trait_self (false), symbol (symbol), param (param)
{}
-ParamType::ParamType (bool is_trait_self, std::string symbol, Location locus,
+ParamType::ParamType (bool is_trait_self, std::string symbol, location_t locus,
HirId ref, HirId ty_ref, HIR::GenericParam ¶m,
std::vector<TypeBoundPredicate> specified_bounds,
std::set<HirId> refs)
bool satisfies_bound (const TypeBoundPredicate &predicate,
bool emit_error) const;
- bool bounds_compatible (const BaseType &other, Location locus,
+ bool bounds_compatible (const BaseType &other, location_t locus,
bool emit_error) const;
void inherit_bounds (const BaseType &other);
void inherit_bounds (
}
};
- InferType (HirId ref, InferTypeKind infer_kind, TypeHint hint, Location locus,
- std::set<HirId> refs = std::set<HirId> ());
+ InferType (HirId ref, InferTypeKind infer_kind, TypeHint hint,
+ location_t locus, std::set<HirId> refs = std::set<HirId> ());
InferType (HirId ref, HirId ty_ref, InferTypeKind infer_kind, TypeHint hint,
- Location locus, std::set<HirId> refs = std::set<HirId> ());
+ location_t locus, std::set<HirId> refs = std::set<HirId> ());
void accept_vis (TyVisitor &vis) override;
void accept_vis (TyConstVisitor &vis) const override;
class ParamType : public BaseType
{
public:
- ParamType (std::string symbol, Location locus, HirId ref,
+ ParamType (std::string symbol, location_t locus, HirId ref,
HIR::GenericParam ¶m,
std::vector<TypeBoundPredicate> specified_bounds,
std::set<HirId> refs = std::set<HirId> ());
- ParamType (bool is_trait_self, std::string symbol, Location locus, HirId ref,
- HirId ty_ref, HIR::GenericParam ¶m,
+ ParamType (bool is_trait_self, std::string symbol, location_t locus,
+ HirId ref, HirId ty_ref, HIR::GenericParam ¶m,
std::vector<TypeBoundPredicate> specified_bounds,
std::set<HirId> refs = std::set<HirId> ());
class StructFieldType
{
public:
- StructFieldType (HirId ref, std::string name, BaseType *ty, Location locus);
+ StructFieldType (HirId ref, std::string name, BaseType *ty, location_t locus);
HirId get_ref () const;
HirId ref;
std::string name;
BaseType *ty;
- Location locus;
+ location_t locus;
};
class TupleType : public BaseType
{
public:
- TupleType (HirId ref, Location locus,
+ TupleType (HirId ref, location_t locus,
std::vector<TyVar> fields = std::vector<TyVar> (),
std::set<HirId> refs = std::set<HirId> ());
- TupleType (HirId ref, HirId ty_ref, Location locus,
+ TupleType (HirId ref, HirId ty_ref, location_t locus,
std::vector<TyVar> fields = std::vector<TyVar> (),
std::set<HirId> refs = std::set<HirId> ());
{
public:
TypeBoundPredicate (const Resolver::TraitReference &trait_reference,
- Location locus);
+ location_t locus);
TypeBoundPredicate (DefId reference,
std::vector<SubstitutionParamMapping> substitutions,
- Location locus);
+ location_t locus);
TypeBoundPredicate (const TypeBoundPredicate &other);
// check that this predicate is object-safe see:
// https://doc.rust-lang.org/reference/items/traits.html#object-safety
- bool is_object_safe (bool emit_error, Location locus) const;
+ bool is_object_safe (bool emit_error, location_t locus) const;
void apply_generic_arguments (HIR::GenericArgs *generic_args,
bool has_associated_self);
private:
DefId reference;
- Location locus;
+ location_t locus;
bool error_flag;
};
class FnPtr : public BaseType
{
public:
- FnPtr (HirId ref, Location locus, std::vector<TyVar> params,
+ FnPtr (HirId ref, location_t locus, std::vector<TyVar> params,
TyVar result_type, std::set<HirId> refs = std::set<HirId> ())
: BaseType (ref, ref, TypeKind::FNPTR,
{Resolver::CanonicalPath::create_empty (), locus}, refs),
params (std::move (params)), result_type (result_type)
{}
- FnPtr (HirId ref, HirId ty_ref, Location locus, std::vector<TyVar> params,
+ FnPtr (HirId ref, HirId ty_ref, location_t locus, std::vector<TyVar> params,
TyVar result_type, std::set<HirId> refs = std::set<HirId> ())
: BaseType (ref, ty_ref, TypeKind::FNPTR,
{Resolver::CanonicalPath::create_empty (), locus}, refs),
class ArrayType : public BaseType
{
public:
- ArrayType (HirId ref, Location locus, HIR::Expr &capacity_expr, TyVar base,
+ ArrayType (HirId ref, location_t locus, HIR::Expr &capacity_expr, TyVar base,
std::set<HirId> refs = std::set<HirId> ())
: BaseType (ref, ref, TypeKind::ARRAY,
{Resolver::CanonicalPath::create_empty (), locus}, refs),
element_type (base), capacity_expr (capacity_expr)
{}
- ArrayType (HirId ref, HirId ty_ref, Location locus, HIR::Expr &capacity_expr,
- TyVar base, std::set<HirId> refs = std::set<HirId> ())
+ ArrayType (HirId ref, HirId ty_ref, location_t locus,
+ HIR::Expr &capacity_expr, TyVar base,
+ std::set<HirId> refs = std::set<HirId> ())
: BaseType (ref, ty_ref, TypeKind::ARRAY,
{Resolver::CanonicalPath::create_empty (), locus}, refs),
element_type (base), capacity_expr (capacity_expr)
class SliceType : public BaseType
{
public:
- SliceType (HirId ref, Location locus, TyVar base,
+ SliceType (HirId ref, location_t locus, TyVar base,
std::set<HirId> refs = std::set<HirId> ())
: BaseType (ref, ref, TypeKind::SLICE,
{Resolver::CanonicalPath::create_empty (), locus}, refs),
element_type (base)
{}
- SliceType (HirId ref, HirId ty_ref, Location locus, TyVar base,
+ SliceType (HirId ref, HirId ty_ref, location_t locus, TyVar base,
std::set<HirId> refs = std::set<HirId> ())
: BaseType (ref, ty_ref, TypeKind::SLICE,
{Resolver::CanonicalPath::create_empty (), locus}, refs),
namespace Resolver {
UnifyRules::UnifyRules (TyTy::TyWithLocation lhs, TyTy::TyWithLocation rhs,
- Location locus, bool commit_flag, bool emit_error,
+ location_t locus, bool commit_flag, bool emit_error,
bool infer, std::vector<CommitSite> &commits,
std::vector<InferenceSite> &infers)
: lhs (lhs), rhs (rhs), locus (locus), commit_flag (commit_flag),
TyTy::BaseType *
UnifyRules::Resolve (TyTy::TyWithLocation lhs, TyTy::TyWithLocation rhs,
- Location locus, bool commit_flag, bool emit_error,
+ location_t locus, bool commit_flag, bool emit_error,
bool infer, std::vector<CommitSite> &commits,
std::vector<InferenceSite> &infers)
{
};
static TyTy::BaseType *Resolve (TyTy::TyWithLocation lhs,
- TyTy::TyWithLocation rhs, Location locus,
+ TyTy::TyWithLocation rhs, location_t locus,
bool commit_flag, bool emit_error, bool infer,
std::vector<CommitSite> &commits,
std::vector<InferenceSite> &infers);
private:
UnifyRules (TyTy::TyWithLocation lhs, TyTy::TyWithLocation rhs,
- Location locus, bool commit_flag, bool emit_error, bool infer,
+ location_t locus, bool commit_flag, bool emit_error, bool infer,
std::vector<CommitSite> &commits,
std::vector<InferenceSite> &infers);
TyTy::TyWithLocation lhs;
TyTy::TyWithLocation rhs;
- Location locus;
+ location_t locus;
bool commit_flag;
bool emit_error;
bool infer_flag;
}
void
-Mappings::insert_location (HirId id, Location locus)
+Mappings::insert_location (HirId id, location_t locus)
{
locations[id] = locus;
}
bool lookup_node_to_hir (NodeId id, HirId *ref);
bool lookup_hir_to_node (HirId id, NodeId *ref);
- void insert_location (HirId id, Location locus);
+ void insert_location (HirId id, location_t locus);
Location lookup_location (HirId id);
bool resolve_nodeid_to_stmt (NodeId id, HIR::Stmt **stmt);
struct RustIdent
{
Resolver::CanonicalPath path;
- Location locus;
+ location_t locus;
- RustIdent (const Resolver::CanonicalPath &path, Location locus)
+ RustIdent (const Resolver::CanonicalPath &path, location_t locus)
: path (path), locus (locus)
{}