-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scaffolding for gradual migration to AST::Expression
#240
base: prism
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -156,7 +156,7 @@ unique_ptr<parser::Node> runPrismParser(core::GlobalState &gs, core::FileRef fil | |
return std::unique_ptr<parser::Node>(); | ||
} | ||
|
||
return Prism::Translator(parser, gs).translate(std::move(root)); | ||
return Prism::Translator(std::move(parser), gs).translate(std::move(root)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This just saves one reference count bump on the |
||
} | ||
|
||
ast::ExpressionPtr runDesugar(core::GlobalState &gs, core::FileRef file, unique_ptr<parser::Node> parseTree, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
#ifndef SORBET_PARSER_NODE_H | ||
#define SORBET_PARSER_NODE_H | ||
|
||
#include "ast/Trees.h" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needed for |
||
#include "common/common.h" | ||
#include "core/core.h" | ||
#include <memory> | ||
|
@@ -22,6 +23,15 @@ class Node { | |
virtual std::string toJSONWithLocs(const core::GlobalState &gs, core::FileRef file, int tabs = 0) = 0; | ||
virtual std::string toWhitequark(const core::GlobalState &gs, int tabs = 0) = 0; | ||
virtual std::string nodeName() = 0; | ||
|
||
virtual ast::ExpressionPtr getCachedDesugaredExpr() { | ||
return nullptr; | ||
} | ||
|
||
virtual void cacheDesugaredExpr(ast::ExpressionPtr expr) { | ||
// no-op, except for the override in NodeAndExpr | ||
} | ||
|
||
core::LocOffsets loc; | ||
|
||
protected: | ||
|
@@ -40,7 +50,7 @@ template <class To> To *cast_node(Node *what) { | |
static_assert(!std::is_pointer<To>::value, "To has to be a pointer"); | ||
static_assert(std::is_assignable<Node *&, To *>::value, "Ill Formed To, has to be a subclass of Expression"); | ||
#if __cplusplus >= 201402L | ||
static_assert(std::is_final<To>::value, "To is not final"); | ||
// static_assert(std::is_final<To>::value, "To is not final"); | ||
Comment on lines
-43
to
+53
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had to temporarily disable this, since the classes we're checking against are no longer |
||
#elif __has_feature(is_final) | ||
static_assert(__is_final(To), "To is not final"); | ||
#else | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The translations we implement in the
Translator
will fill this in, which we can use here to short-circuit the logic below.Thinking goes that once we've implemented it for all nodes, none of the code below will be used anymore, and we can just delete and inline all this stuff.