Created
April 23, 2020 21:21
-
-
Save enebo/eb65c7d6651b772e3e1648843befec01 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/ast.c b/ast.c | |
index f0e8dd2eaf..df58006a96 100644 | |
--- a/ast.c | |
+++ b/ast.c | |
@@ -7,6 +7,8 @@ | |
#include "vm_core.h" | |
#include "iseq.h" | |
+#define RBOOL(v) ((v) ? Qtrue : Qfalse) | |
+ | |
static VALUE rb_mAST; | |
static VALUE rb_cNode; | |
@@ -731,6 +733,16 @@ rb_ast_node_inspect(VALUE self) | |
return str; | |
} | |
+static VALUE | |
+rb_ast_node_newline(VALUE self) | |
+{ | |
+ struct ASTNodeData *data; | |
+ TypedData_Get_Struct(self, struct ASTNodeData, &rb_node_type, data); | |
+ | |
+ return RBOOL(data->node->flags & NODE_FL_NEWLINE); | |
+} | |
+ | |
+ | |
void | |
Init_ast(void) | |
{ | |
@@ -756,5 +768,6 @@ Init_ast(void) | |
rb_define_method(rb_cNode, "last_lineno", rb_ast_node_last_lineno, 0); | |
rb_define_method(rb_cNode, "last_column", rb_ast_node_last_column, 0); | |
rb_define_method(rb_cNode, "children", rb_ast_node_children, 0); | |
+ rb_define_method(rb_cNode, "newline?", rb_ast_node_newline, 0); | |
rb_define_method(rb_cNode, "inspect", rb_ast_node_inspect, 0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment