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