@@ -249,36 +249,50 @@ class MetaItemLitExpr : public MetaItemInner
249249 }
250250};
251251
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
254254{
255255 SimplePath path;
256- LiteralExpr lit ;
256+ std::unique_ptr<Expr> expr ;
257257
258258public:
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 ())
261265 {}
262266
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+
263279 SimplePath get_path () const { return path; }
264280
265281 SimplePath &get_path () { return path; }
266282
267- LiteralExpr get_literal () const { return lit; }
268-
269- LiteralExpr &get_literal () { return lit; }
283+ Expr &get_expr () { return *expr; }
270284
271285 std::string as_string () const override
272286 {
273- return path.as_string () + " = " + lit. as_string ();
287+ return path.as_string () + " = " + expr-> as_string ();
274288 }
275289
276290 MetaItem::ItemKind get_item_kind () const override
277291 {
278- return MetaItem::ItemKind::PathLit ;
292+ return MetaItem::ItemKind::PathExpr ;
279293 }
280294
281- // There are two Locations in MetaItemPathLit (path and lit_expr ),
295+ // There are two Locations in MetaItemPathExpr (path and expr ),
282296 // we have no idea use which of them, just simply return UNKNOWN_LOCATION
283297 // now.
284298 // Maybe we will figure out when we really need the location in the future.
@@ -294,9 +308,9 @@ class MetaItemPathLit : public MetaItem
294308
295309protected:
296310 // 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
298312 {
299- return new MetaItemPathLit (*this );
313+ return new MetaItemPathExpr (*this );
300314 }
301315};
302316
0 commit comments