@@ -249,36 +249,50 @@ class MetaItemLitExpr : public MetaItemInner
249
249
}
250
250
};
251
251
252
- // more generic meta item "path = lit " form
253
- class MetaItemPathLit : public MetaItem
252
+ // more generic meta item "path = expr " form
253
+ class MetaItemPathExpr : public MetaItem
254
254
{
255
255
SimplePath path;
256
- LiteralExpr lit ;
256
+ std::unique_ptr<Expr> expr ;
257
257
258
258
public:
259
- MetaItemPathLit (SimplePath path, LiteralExpr lit_expr)
260
- : path (std::move (path)), lit (std::move (lit_expr))
259
+ MetaItemPathExpr (SimplePath path, std::unique_ptr<Expr> expr)
260
+ : path (std::move (path)), expr (std::move (expr))
261
+ {}
262
+
263
+ MetaItemPathExpr (const MetaItemPathExpr &other)
264
+ : MetaItem (other), path (other.path), expr (other.expr->clone_expr ())
261
265
{}
262
266
267
+ MetaItemPathExpr (MetaItemPathExpr &&) = default;
268
+
269
+ MetaItemPathExpr &operator = (MetaItemPathExpr &&) = default ;
270
+
271
+ MetaItemPathExpr operator = (const MetaItemPathExpr &other)
272
+ {
273
+ MetaItem::operator = (other);
274
+ path = other.path ;
275
+ expr = other.expr ->clone_expr ();
276
+ return *this ;
277
+ }
278
+
263
279
SimplePath get_path () const { return path; }
264
280
265
281
SimplePath &get_path () { return path; }
266
282
267
- LiteralExpr get_literal () const { return lit; }
268
-
269
- LiteralExpr &get_literal () { return lit; }
283
+ Expr &get_expr () { return *expr; }
270
284
271
285
std::string as_string () const override
272
286
{
273
- return path.as_string () + " = " + lit. as_string ();
287
+ return path.as_string () + " = " + expr-> as_string ();
274
288
}
275
289
276
290
MetaItem::ItemKind get_item_kind () const override
277
291
{
278
- return MetaItem::ItemKind::PathLit ;
292
+ return MetaItem::ItemKind::PathExpr ;
279
293
}
280
294
281
- // There are two Locations in MetaItemPathLit (path and lit_expr ),
295
+ // There are two Locations in MetaItemPathExpr (path and expr ),
282
296
// we have no idea use which of them, just simply return UNKNOWN_LOCATION
283
297
// now.
284
298
// Maybe we will figure out when we really need the location in the future.
@@ -294,9 +308,9 @@ class MetaItemPathLit : public MetaItem
294
308
295
309
protected:
296
310
// Use covariance to implement clone function as returning this type
297
- MetaItemPathLit *clone_meta_item_inner_impl () const override
311
+ MetaItemPathExpr *clone_meta_item_inner_impl () const override
298
312
{
299
- return new MetaItemPathLit (*this );
313
+ return new MetaItemPathExpr (*this );
300
314
}
301
315
};
302
316
0 commit comments