зеркало из https://github.com/github/ruby.git
Rename YARP symbols to prism
This commit is contained in:
Родитель
4f73a7c2f7
Коммит
3d0a46796b
2
NEWS.md
2
NEWS.md
|
@ -93,6 +93,7 @@ The following default gems are updated.
|
|||
* nkf 0.1.3
|
||||
* openssl 3.2.0
|
||||
* optparse 0.4.0.pre.1
|
||||
* prism 0.12.0
|
||||
* psych 5.1.0
|
||||
* reline 0.3.8
|
||||
* stringio 3.0.9
|
||||
|
@ -101,7 +102,6 @@ The following default gems are updated.
|
|||
* time 0.2.2
|
||||
* timeout 0.4.0
|
||||
* uri 0.12.2
|
||||
* yarp 0.12.0
|
||||
|
||||
The following bundled gems are updated.
|
||||
|
||||
|
|
2388
common.mk
2388
common.mk
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
22
compile.c
22
compile.c
|
@ -43,7 +43,7 @@
|
|||
#include "builtin.h"
|
||||
#include "insns.inc"
|
||||
#include "insns_info.inc"
|
||||
#include "yarp/yarp.h"
|
||||
#include "prism/prism.h"
|
||||
|
||||
#undef RUBY_UNTYPED_DATA_WARNING
|
||||
#define RUBY_UNTYPED_DATA_WARNING 0
|
||||
|
@ -856,17 +856,17 @@ rb_iseq_compile_node(rb_iseq_t *iseq, const NODE *node)
|
|||
return iseq_setup(iseq, ret);
|
||||
}
|
||||
|
||||
typedef struct yp_compile_context {
|
||||
yp_parser_t *parser;
|
||||
struct yp_compile_context *previous;
|
||||
typedef struct pm_compile_context {
|
||||
pm_parser_t *parser;
|
||||
struct pm_compile_context *previous;
|
||||
ID *constants;
|
||||
st_table *index_lookup_table;
|
||||
} yp_compile_context_t;
|
||||
} pm_compile_context_t;
|
||||
|
||||
static VALUE rb_translate_yarp(rb_iseq_t *iseq, const yp_node_t *node, LINK_ANCHOR *const ret, yp_compile_context_t *compile_context);
|
||||
static VALUE rb_translate_prism(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret, pm_compile_context_t *compile_context);
|
||||
|
||||
VALUE
|
||||
rb_iseq_compile_yarp_node(rb_iseq_t * iseq, const yp_node_t *yarp_pointer, yp_parser_t *parser)
|
||||
rb_iseq_compile_prism_node(rb_iseq_t * iseq, const pm_node_t *node, pm_parser_t *parser)
|
||||
{
|
||||
DECL_ANCHOR(ret);
|
||||
INIT_ANCHOR(ret);
|
||||
|
@ -875,20 +875,20 @@ rb_iseq_compile_yarp_node(rb_iseq_t * iseq, const yp_node_t *yarp_pointer, yp_pa
|
|||
rb_encoding *encoding = rb_enc_find(parser->encoding.name);
|
||||
|
||||
for (size_t index = 0; index < parser->constant_pool.capacity; index++) {
|
||||
yp_constant_t constant = parser->constant_pool.constants[index];
|
||||
pm_constant_t constant = parser->constant_pool.constants[index];
|
||||
|
||||
if (constant.id != 0) {
|
||||
constants[constant.id - 1] = rb_intern3((const char *) constant.start, constant.length, encoding);
|
||||
}
|
||||
}
|
||||
|
||||
yp_compile_context_t compile_context = {
|
||||
pm_compile_context_t compile_context = {
|
||||
.parser = parser,
|
||||
.previous = NULL,
|
||||
.constants = constants
|
||||
};
|
||||
|
||||
CHECK(rb_translate_yarp(iseq, yarp_pointer, ret, &compile_context));
|
||||
CHECK(rb_translate_prism(iseq, node, ret, &compile_context));
|
||||
free(constants);
|
||||
|
||||
CHECK(iseq_setup_insn(iseq, ret));
|
||||
|
@ -13369,4 +13369,4 @@ rb_iseq_ibf_load_extra_data(VALUE str)
|
|||
return extra_str;
|
||||
}
|
||||
|
||||
#include "yarp/yarp_compiler.c"
|
||||
#include "prism/prism_compiler.c"
|
||||
|
|
2
inits.c
2
inits.c
|
@ -76,7 +76,7 @@ rb_call_inits(void)
|
|||
CALL(ast);
|
||||
CALL(gc_stress);
|
||||
CALL(shape);
|
||||
CALL(YARP);
|
||||
CALL(Prism);
|
||||
|
||||
// enable builtin loading
|
||||
CALL(builtin);
|
||||
|
|
45
iseq.c
45
iseq.c
|
@ -43,7 +43,7 @@
|
|||
#include "builtin.h"
|
||||
#include "insns.inc"
|
||||
#include "insns_info.inc"
|
||||
#include "yarp/yarp.h"
|
||||
#include "prism/prism.h"
|
||||
|
||||
VALUE rb_cISeq;
|
||||
static VALUE iseqw_new(const rb_iseq_t *iseq);
|
||||
|
@ -939,10 +939,10 @@ rb_iseq_new_with_opt(const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE rea
|
|||
return iseq_translate(iseq);
|
||||
}
|
||||
|
||||
VALUE rb_iseq_compile_yarp_node(rb_iseq_t * iseq, const yp_node_t * yarp_pointer, yp_parser_t *parser);
|
||||
VALUE rb_iseq_compile_prism_node(rb_iseq_t * iseq, const pm_node_t *node, pm_parser_t *parser);
|
||||
|
||||
rb_iseq_t *
|
||||
yp_iseq_new_with_opt(yp_node_t *node, yp_parser_t *parser, VALUE name, VALUE path, VALUE realpath,
|
||||
pm_iseq_new_with_opt(pm_node_t *node, pm_parser_t *parser, VALUE name, VALUE path, VALUE realpath,
|
||||
int first_lineno, const rb_iseq_t *parent, int isolated_depth,
|
||||
enum rb_iseq_type type, const rb_compile_option_t *option)
|
||||
{
|
||||
|
@ -953,17 +953,18 @@ yp_iseq_new_with_opt(yp_node_t *node, yp_parser_t *parser, VALUE name, VALUE pat
|
|||
if (!option) option = &COMPILE_OPTION_DEFAULT;
|
||||
|
||||
if (node) {
|
||||
yp_line_column_t start_line_col = yp_newline_list_line_column(&(parser->newline_list), node->location.start);
|
||||
yp_line_column_t end_line_col= yp_newline_list_line_column(&(parser->newline_list), node->location.end);
|
||||
pm_line_column_t start_line_col = pm_newline_list_line_column(&parser->newline_list, node->location.start);
|
||||
pm_line_column_t end_line_col = pm_newline_list_line_column(&parser->newline_list, node->location.end);
|
||||
|
||||
code_loc = (rb_code_location_t) {
|
||||
.beg_pos = {
|
||||
.lineno = (int)start_line_col.line,
|
||||
.column = (int)start_line_col.column
|
||||
.lineno = (int) start_line_col.line,
|
||||
.column = (int) start_line_col.column
|
||||
},
|
||||
.end_pos = {
|
||||
.lineno = (int) end_line_col.line,
|
||||
.column = (int) end_line_col.column
|
||||
},
|
||||
.end_pos = {
|
||||
.lineno = (int)end_line_col.line,
|
||||
.column = (int)end_line_col.column
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -972,7 +973,7 @@ yp_iseq_new_with_opt(yp_node_t *node, yp_parser_t *parser, VALUE name, VALUE pat
|
|||
prepare_iseq_build(iseq, name, path, realpath, first_lineno, &code_loc, node_id,
|
||||
parent, isolated_depth, type, script_lines, option);
|
||||
|
||||
rb_iseq_compile_yarp_node(iseq, node, parser);
|
||||
rb_iseq_compile_prism_node(iseq, node, parser);
|
||||
|
||||
finish_iseq_build(iseq);
|
||||
|
||||
|
@ -1387,7 +1388,7 @@ iseqw_s_compile(int argc, VALUE *argv, VALUE self)
|
|||
}
|
||||
|
||||
static VALUE
|
||||
iseqw_s_compile_yarp(int argc, VALUE *argv, VALUE self)
|
||||
iseqw_s_compile_prism(int argc, VALUE *argv, VALUE self)
|
||||
{
|
||||
VALUE src, file = Qnil, path = Qnil, line = Qnil, opt = Qnil;
|
||||
int i;
|
||||
|
@ -1410,17 +1411,17 @@ iseqw_s_compile_yarp(int argc, VALUE *argv, VALUE self)
|
|||
|
||||
rb_iseq_t *iseq = iseq_alloc();
|
||||
|
||||
yp_parser_t parser;
|
||||
pm_parser_t parser;
|
||||
size_t len = RSTRING_LEN(src);
|
||||
VALUE name = rb_fstring_lit("<compiled>");
|
||||
|
||||
yp_parser_init(&parser, (const uint8_t *) RSTRING_PTR(src), len, "");
|
||||
pm_parser_init(&parser, (const uint8_t *) RSTRING_PTR(src), len, "");
|
||||
|
||||
yp_node_t *node = yp_parse(&parser);
|
||||
pm_node_t *node = pm_parse(&parser);
|
||||
|
||||
int first_lineno = NUM2INT(line);
|
||||
yp_line_column_t start_loc = yp_newline_list_line_column(&parser.newline_list, node->location.start);
|
||||
yp_line_column_t end_loc = yp_newline_list_line_column(&parser.newline_list, node->location.end);
|
||||
pm_line_column_t start_loc = pm_newline_list_line_column(&parser.newline_list, node->location.start);
|
||||
pm_line_column_t end_loc = pm_newline_list_line_column(&parser.newline_list, node->location.end);
|
||||
|
||||
rb_code_location_t node_location;
|
||||
node_location.beg_pos.lineno = (int)start_loc.line;
|
||||
|
@ -1439,11 +1440,11 @@ iseqw_s_compile_yarp(int argc, VALUE *argv, VALUE self)
|
|||
prepare_iseq_build(iseq, name, file, path, first_lineno, &node_location, node_id,
|
||||
parent, 0, (enum rb_iseq_type)iseq_type, Qnil, &option);
|
||||
|
||||
rb_iseq_compile_yarp_node(iseq, node, &parser);
|
||||
rb_iseq_compile_prism_node(iseq, node, &parser);
|
||||
|
||||
finish_iseq_build(iseq);
|
||||
yp_node_destroy(&parser, node);
|
||||
yp_parser_free(&parser);
|
||||
pm_node_destroy(&parser, node);
|
||||
pm_parser_free(&parser);
|
||||
|
||||
return iseqw_new(iseq);
|
||||
}
|
||||
|
@ -4020,7 +4021,7 @@ Init_ISeq(void)
|
|||
(void)iseq_s_load;
|
||||
|
||||
rb_define_singleton_method(rb_cISeq, "compile", iseqw_s_compile, -1);
|
||||
rb_define_singleton_method(rb_cISeq, "compile_yarp", iseqw_s_compile_yarp, -1);
|
||||
rb_define_singleton_method(rb_cISeq, "compile_prism", iseqw_s_compile_prism, -1);
|
||||
rb_define_singleton_method(rb_cISeq, "new", iseqw_s_compile, -1);
|
||||
rb_define_singleton_method(rb_cISeq, "compile_file", iseqw_s_compile_file, -1);
|
||||
rb_define_singleton_method(rb_cISeq, "compile_option", iseqw_s_compile_option_get, 0);
|
||||
|
|
|
@ -1,166 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require "cgi"
|
||||
require "json"
|
||||
require "uri"
|
||||
|
||||
module YARP
|
||||
# YARP additionally ships with a language server conforming to the
|
||||
# language server protocol. It can be invoked by running the yarp-lsp
|
||||
# bin script (bin/yarp-lsp)
|
||||
class LanguageServer
|
||||
GITHUB_TEMPLATE = <<~TEMPLATE
|
||||
Reporting issue with error `%{error}`.
|
||||
|
||||
## Expected behavior
|
||||
<!-- TODO: Briefly explain what the expected behavior should be on this example. -->
|
||||
|
||||
## Actual behavior
|
||||
<!-- TODO: Describe here what actually happened. -->
|
||||
|
||||
## Steps to reproduce the problem
|
||||
<!-- TODO: Describe how we can reproduce the problem. -->
|
||||
|
||||
## Additional information
|
||||
<!-- TODO: Include any additional information, such as screenshots. -->
|
||||
|
||||
TEMPLATE
|
||||
|
||||
attr_reader :input, :output
|
||||
|
||||
def initialize(
|
||||
input: $stdin,
|
||||
output: $stdout
|
||||
)
|
||||
@input = input.binmode
|
||||
@output = output.binmode
|
||||
end
|
||||
|
||||
# rubocop:disable Layout/LineLength
|
||||
def run
|
||||
store =
|
||||
Hash.new do |hash, uri|
|
||||
filepath = CGI.unescape(URI.parse(uri).path)
|
||||
File.exist?(filepath) ? (hash[uri] = File.read(filepath)) : nil
|
||||
end
|
||||
|
||||
while (headers = input.gets("\r\n\r\n"))
|
||||
source = input.read(headers[/Content-Length: (\d+)/i, 1].to_i)
|
||||
request = JSON.parse(source, symbolize_names: true)
|
||||
|
||||
# stree-ignore
|
||||
case request
|
||||
in { method: "initialize", id: }
|
||||
store.clear
|
||||
write(id: id, result: { capabilities: capabilities })
|
||||
in { method: "initialized" }
|
||||
# ignored
|
||||
in { method: "shutdown" } # tolerate missing ID to be a good citizen
|
||||
store.clear
|
||||
write(id: request[:id], result: {})
|
||||
in { method: "exit"}
|
||||
return
|
||||
in { method: "textDocument/didChange", params: { textDocument: { uri: }, contentChanges: [{ text: }, *] } }
|
||||
store[uri] = text
|
||||
in { method: "textDocument/didOpen", params: { textDocument: { uri:, text: } } }
|
||||
store[uri] = text
|
||||
in { method: "textDocument/didClose", params: { textDocument: { uri: } } }
|
||||
store.delete(uri)
|
||||
in { method: "textDocument/diagnostic", id:, params: { textDocument: { uri: } } }
|
||||
contents = store[uri]
|
||||
write(id: id, result: contents ? diagnostics(contents) : nil)
|
||||
in { method: "textDocument/codeAction", id:, params: { textDocument: { uri: }, context: { diagnostics: }}}
|
||||
contents = store[uri]
|
||||
write(id: id, result: contents ? code_actions(contents, diagnostics) : nil)
|
||||
in { method: %r{\$/.+} }
|
||||
# ignored
|
||||
end
|
||||
end
|
||||
end
|
||||
# rubocop:enable Layout/LineLength
|
||||
|
||||
private
|
||||
|
||||
def capabilities
|
||||
{
|
||||
codeActionProvider: {
|
||||
codeActionKinds: [
|
||||
'quickfix',
|
||||
],
|
||||
},
|
||||
diagnosticProvider: {
|
||||
interFileDependencies: false,
|
||||
workspaceDiagnostics: false,
|
||||
},
|
||||
textDocumentSync: {
|
||||
change: 1,
|
||||
openClose: true
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
def code_actions(source, diagnostics)
|
||||
diagnostics.map do |diagnostic|
|
||||
message = diagnostic[:message]
|
||||
issue_content = URI.encode_www_form_component(GITHUB_TEMPLATE % {error: message})
|
||||
issue_link = "https://github.com/ruby/yarp/issues/new?&labels=Bug&body=#{issue_content}"
|
||||
|
||||
{
|
||||
title: "Report incorrect error: `#{diagnostic[:message]}`",
|
||||
kind: "quickfix",
|
||||
diagnostics: [diagnostic],
|
||||
command: {
|
||||
title: "Report incorrect error",
|
||||
command: "vscode.open",
|
||||
arguments: [issue_link]
|
||||
}
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
def diagnostics(source)
|
||||
offsets = Hash.new do |hash, key|
|
||||
slice = source.byteslice(...key)
|
||||
lineno = slice.count("\n")
|
||||
|
||||
char = slice.length
|
||||
newline = source.rindex("\n", [char - 1, 0].max) || -1
|
||||
hash[key] = { line: lineno, character: char - newline - 1 }
|
||||
end
|
||||
|
||||
parse_output = YARP.parse(source)
|
||||
|
||||
{
|
||||
kind: "full",
|
||||
items: [
|
||||
*parse_output.errors.map do |error|
|
||||
{
|
||||
range: {
|
||||
start: offsets[error.location.start_offset],
|
||||
end: offsets[error.location.end_offset],
|
||||
},
|
||||
message: error.message,
|
||||
severity: 1,
|
||||
}
|
||||
end,
|
||||
*parse_output.warnings.map do |warning|
|
||||
{
|
||||
range: {
|
||||
start: offsets[warning.location.start_offset],
|
||||
end: offsets[warning.location.end_offset],
|
||||
},
|
||||
message: warning.message,
|
||||
severity: 2,
|
||||
}
|
||||
end,
|
||||
]
|
||||
}
|
||||
end
|
||||
|
||||
def write(value)
|
||||
response = value.merge(jsonrpc: "2.0").to_json
|
||||
output.print("Content-Length: #{response.bytesize}\r\n\r\n#{response}")
|
||||
output.flush
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,5 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module YARP
|
||||
VERSION = "0.8.0"
|
||||
end
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,9 +1,9 @@
|
|||
#include "yarp/extension.h"
|
||||
#include "prism/extension.h"
|
||||
|
||||
void ruby_init_ext(const char *name, void (*init)(void));
|
||||
|
||||
void
|
||||
Init_YARP(void)
|
||||
Init_Prism(void)
|
||||
{
|
||||
ruby_init_ext("yarp/yarp.so", Init_yarp);
|
||||
ruby_init_ext("prism/prism.so", Init_prism);
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module YARP
|
||||
module Prism
|
||||
class ISeqTest < Test::Unit::TestCase
|
||||
def test_empty_program
|
||||
test_yarp_eval("")
|
||||
test_prism_eval("")
|
||||
end
|
||||
|
||||
############################################################################
|
||||
|
@ -11,47 +11,47 @@ module YARP
|
|||
############################################################################
|
||||
|
||||
def test_FalseNode
|
||||
test_yarp_eval("false")
|
||||
test_prism_eval("false")
|
||||
end
|
||||
|
||||
def test_FloatNode
|
||||
test_yarp_eval("1.2")
|
||||
test_yarp_eval("1.2e3")
|
||||
test_yarp_eval("+1.2e+3")
|
||||
test_yarp_eval("-1.2e-3")
|
||||
test_prism_eval("1.2")
|
||||
test_prism_eval("1.2e3")
|
||||
test_prism_eval("+1.2e+3")
|
||||
test_prism_eval("-1.2e-3")
|
||||
end
|
||||
|
||||
def test_ImaginaryNode
|
||||
test_yarp_eval("1i")
|
||||
test_yarp_eval("+1.0i")
|
||||
test_yarp_eval("1ri")
|
||||
test_prism_eval("1i")
|
||||
test_prism_eval("+1.0i")
|
||||
test_prism_eval("1ri")
|
||||
end
|
||||
|
||||
def test_IntegerNode
|
||||
test_yarp_eval("1")
|
||||
test_yarp_eval("+1")
|
||||
test_yarp_eval("-1")
|
||||
test_yarp_eval("0x10")
|
||||
test_yarp_eval("0b10")
|
||||
test_yarp_eval("0o10")
|
||||
test_yarp_eval("010")
|
||||
test_prism_eval("1")
|
||||
test_prism_eval("+1")
|
||||
test_prism_eval("-1")
|
||||
test_prism_eval("0x10")
|
||||
test_prism_eval("0b10")
|
||||
test_prism_eval("0o10")
|
||||
test_prism_eval("010")
|
||||
end
|
||||
|
||||
def test_NilNode
|
||||
test_yarp_eval("nil")
|
||||
test_prism_eval("nil")
|
||||
end
|
||||
|
||||
def test_RationalNode
|
||||
test_yarp_eval("1.2r")
|
||||
test_yarp_eval("+1.2r")
|
||||
test_prism_eval("1.2r")
|
||||
test_prism_eval("+1.2r")
|
||||
end
|
||||
|
||||
def test_SelfNode
|
||||
test_yarp_eval("self")
|
||||
test_prism_eval("self")
|
||||
end
|
||||
|
||||
def test_TrueNode
|
||||
test_yarp_eval("true")
|
||||
test_prism_eval("true")
|
||||
end
|
||||
|
||||
############################################################################
|
||||
|
@ -59,27 +59,27 @@ module YARP
|
|||
############################################################################
|
||||
|
||||
def test_ClassVariableReadNode
|
||||
test_yarp_eval("class YARP::ISeqTest; @@yct = 1; @@yct; end")
|
||||
test_prism_eval("class Prism::ISeqTest; @@pit = 1; @@pit; end")
|
||||
end
|
||||
|
||||
def test_ConstantPathNode
|
||||
test_yarp_eval("YARP::ISeqTest")
|
||||
test_prism_eval("Prism::ISeqTest")
|
||||
end
|
||||
|
||||
def test_ConstantReadNode
|
||||
test_yarp_eval("YARP")
|
||||
test_prism_eval("Prism")
|
||||
end
|
||||
|
||||
def test_GlobalVariableReadNode
|
||||
test_yarp_eval("$yct = 1; $yct")
|
||||
test_prism_eval("$pit = 1; $pit")
|
||||
end
|
||||
|
||||
def test_InstanceVariableReadNode
|
||||
test_yarp_eval("class YARP::ISeqTest; @yct = 1; @yct; end")
|
||||
test_prism_eval("class Prism::ISeqTest; @pit = 1; @pit; end")
|
||||
end
|
||||
|
||||
def test_LocalVariableReadNode
|
||||
test_yarp_eval("yct = 1; yct")
|
||||
test_prism_eval("pit = 1; pit")
|
||||
end
|
||||
|
||||
############################################################################
|
||||
|
@ -87,49 +87,49 @@ module YARP
|
|||
############################################################################
|
||||
|
||||
def test_ClassVariableTargetNode
|
||||
test_yarp_eval("class YARP::ISeqTest; @@yct, @@yct1 = 1; end")
|
||||
test_prism_eval("class Prism::ISeqTest; @@pit, @@pit1 = 1; end")
|
||||
end
|
||||
|
||||
def test_ClassVariableWriteNode
|
||||
test_yarp_eval("class YARP::ISeqTest; @@yct = 1; end")
|
||||
test_prism_eval("class Prism::ISeqTest; @@pit = 1; end")
|
||||
end
|
||||
|
||||
def test_ClassVariableAndWriteNode
|
||||
test_yarp_eval("class YARP::ISeqTest; @@yct = 0; @@yct &&= 1; end")
|
||||
test_prism_eval("class Prism::ISeqTest; @@pit = 0; @@pit &&= 1; end")
|
||||
end
|
||||
|
||||
def test_ClassVariableOrWriteNode
|
||||
test_yarp_eval("class YARP::ISeqTest; @@yct = 1; @@yct ||= 0; end")
|
||||
test_yarp_eval("class YARP::ISeqTest; @@yct = nil; @@yct ||= 1; end")
|
||||
test_prism_eval("class Prism::ISeqTest; @@pit = 1; @@pit ||= 0; end")
|
||||
test_prism_eval("class Prism::ISeqTest; @@pit = nil; @@pit ||= 1; end")
|
||||
end
|
||||
|
||||
def test_ClassVariableOperatorWriteNode
|
||||
test_yarp_eval("class YARP::ISeqTest; @@yct = 0; @@yct += 1; end")
|
||||
test_prism_eval("class Prism::ISeqTest; @@pit = 0; @@pit += 1; end")
|
||||
end
|
||||
|
||||
def test_ConstantTargetNode
|
||||
# We don't call test_yarp_eval directly in this case becuase we
|
||||
# We don't call test_prism_eval directly in this case becuase we
|
||||
# don't want to assign the constant mutliple times if we run
|
||||
# with `--repeat-count`
|
||||
# Instead, we eval manually here, and remove the constant to
|
||||
constant_names = ["YCT", "YCT2"]
|
||||
source = "#{constant_names.join(",")} = 1"
|
||||
yarp_eval = RubyVM::InstructionSequence.compile_yarp(source).eval
|
||||
assert_equal yarp_eval, 1
|
||||
prism_eval = RubyVM::InstructionSequence.compile_prism(source).eval
|
||||
assert_equal prism_eval, 1
|
||||
constant_names.map { |name|
|
||||
Object.send(:remove_const, name)
|
||||
}
|
||||
end
|
||||
|
||||
def test_ConstantWriteNode
|
||||
# We don't call test_yarp_eval directly in this case becuase we
|
||||
# We don't call test_prism_eval directly in this case becuase we
|
||||
# don't want to assign the constant mutliple times if we run
|
||||
# with `--repeat-count`
|
||||
# Instead, we eval manually here, and remove the constant to
|
||||
constant_name = "YCT"
|
||||
source = "#{constant_name} = 1"
|
||||
yarp_eval = RubyVM::InstructionSequence.compile_yarp(source).eval
|
||||
assert_equal yarp_eval, 1
|
||||
prism_eval = RubyVM::InstructionSequence.compile_prism(source).eval
|
||||
assert_equal prism_eval, 1
|
||||
Object.send(:remove_const, constant_name)
|
||||
end
|
||||
|
||||
|
@ -141,11 +141,11 @@ module YARP
|
|||
|
||||
constant_names = ["MyBar", "MyFoo::Bar", "MyFoo::Bar::Baz"]
|
||||
source = "#{constant_names.join(",")} = Object"
|
||||
iseq = RubyVM::InstructionSequence.compile_yarp(source)
|
||||
iseq = RubyVM::InstructionSequence.compile_prism(source)
|
||||
$VERBOSE = nil
|
||||
yarp_eval = iseq.eval
|
||||
prism_eval = iseq.eval
|
||||
$VERBOSE = verbose
|
||||
assert_equal yarp_eval, Object
|
||||
assert_equal prism_eval, Object
|
||||
|
||||
ensure
|
||||
## Teardown temp constants
|
||||
|
@ -156,67 +156,67 @@ module YARP
|
|||
end
|
||||
|
||||
def test_ConstantPathWriteNode
|
||||
# test_yarp_eval("YARP::YCT = 1")
|
||||
# test_prism_eval("Prism::YCT = 1")
|
||||
end
|
||||
|
||||
def test_GlobalVariableTargetNode
|
||||
test_yarp_eval("$yct, $yct1 = 1")
|
||||
test_prism_eval("$pit, $pit1 = 1")
|
||||
end
|
||||
|
||||
def test_GlobalVariableWriteNode
|
||||
test_yarp_eval("$yct = 1")
|
||||
test_prism_eval("$pit = 1")
|
||||
end
|
||||
|
||||
def test_GlobalVariableAndWriteNode
|
||||
test_yarp_eval("$yct = 0; $yct &&= 1")
|
||||
test_prism_eval("$pit = 0; $pit &&= 1")
|
||||
end
|
||||
|
||||
def test_GlobalVariableOrWriteNode
|
||||
test_yarp_eval("$yct ||= 1")
|
||||
test_prism_eval("$pit ||= 1")
|
||||
end
|
||||
|
||||
def test_GlobalVariableOperatorWriteNode
|
||||
test_yarp_eval("$yct = 0; $yct += 1")
|
||||
test_prism_eval("$pit = 0; $pit += 1")
|
||||
end
|
||||
|
||||
def test_InstanceVariableTargetNode
|
||||
test_yarp_eval("class YARP::ISeqTest; @yct, @yct1 = 1; end")
|
||||
test_prism_eval("class Prism::ISeqTest; @pit, @pit1 = 1; end")
|
||||
end
|
||||
|
||||
def test_InstanceVariableWriteNode
|
||||
test_yarp_eval("class YARP::ISeqTest; @yct = 1; end")
|
||||
test_prism_eval("class Prism::ISeqTest; @pit = 1; end")
|
||||
end
|
||||
|
||||
def test_InstanceVariableAndWriteNode
|
||||
test_yarp_eval("@yct = 0; @yct &&= 1")
|
||||
test_prism_eval("@pit = 0; @pit &&= 1")
|
||||
end
|
||||
|
||||
def test_InstanceVariableOrWriteNode
|
||||
test_yarp_eval("@yct ||= 1")
|
||||
test_prism_eval("@pit ||= 1")
|
||||
end
|
||||
|
||||
def test_InstanceVariableOperatorWriteNode
|
||||
test_yarp_eval("@yct = 0; @yct += 1")
|
||||
test_prism_eval("@pit = 0; @pit += 1")
|
||||
end
|
||||
|
||||
def test_LocalVariableTargetNode
|
||||
test_yarp_eval("yct, yct1 = 1")
|
||||
test_prism_eval("pit, pit1 = 1")
|
||||
end
|
||||
|
||||
def test_LocalVariableWriteNode
|
||||
test_yarp_eval("yct = 1")
|
||||
test_prism_eval("pit = 1")
|
||||
end
|
||||
|
||||
def test_LocalVariableAndWriteNode
|
||||
test_yarp_eval("yct = 0; yct &&= 1")
|
||||
test_prism_eval("pit = 0; pit &&= 1")
|
||||
end
|
||||
|
||||
def test_LocalVariableOrWriteNode
|
||||
test_yarp_eval("yct ||= 1")
|
||||
test_prism_eval("pit ||= 1")
|
||||
end
|
||||
|
||||
def test_LocalVariableOperatorWriteNode
|
||||
test_yarp_eval("yct = 0; yct += 1")
|
||||
test_prism_eval("pit = 0; pit += 1")
|
||||
end
|
||||
|
||||
############################################################################
|
||||
|
@ -224,60 +224,60 @@ module YARP
|
|||
############################################################################
|
||||
|
||||
def test_EmbeddedVariableNode
|
||||
# test_yarp_eval('class YARP::ISeqTest; @yct = 1; "#@yct"; end')
|
||||
# test_yarp_eval('class YARP::ISeqTest; @@yct = 1; "#@@yct"; end')
|
||||
test_yarp_eval('$yct = 1; "#$yct"')
|
||||
# test_prism_eval('class Prism::ISeqTest; @pit = 1; "#@pit"; end')
|
||||
# test_prism_eval('class Prism::ISeqTest; @@pit = 1; "#@@pit"; end')
|
||||
test_prism_eval('$pit = 1; "#$pit"')
|
||||
end
|
||||
|
||||
def test_InterpolatedRegularExpressionNode
|
||||
test_yarp_eval('$yct = 1; /1 #$yct 1/')
|
||||
test_yarp_eval('/1 #{1 + 2} 1/')
|
||||
test_yarp_eval('/1 #{"2"} #{1 + 2} 1/')
|
||||
test_prism_eval('$pit = 1; /1 #$pit 1/')
|
||||
test_prism_eval('/1 #{1 + 2} 1/')
|
||||
test_prism_eval('/1 #{"2"} #{1 + 2} 1/')
|
||||
end
|
||||
|
||||
def test_InterpolatedStringNode
|
||||
test_yarp_eval('$yct = 1; "1 #$yct 1"')
|
||||
test_yarp_eval('"1 #{1 + 2} 1"')
|
||||
test_prism_eval('$pit = 1; "1 #$pit 1"')
|
||||
test_prism_eval('"1 #{1 + 2} 1"')
|
||||
end
|
||||
|
||||
def test_InterpolatedSymbolNode
|
||||
test_yarp_eval('$yct = 1; :"1 #$yct 1"')
|
||||
test_yarp_eval(':"1 #{1 + 2} 1"')
|
||||
test_prism_eval('$pit = 1; :"1 #$pit 1"')
|
||||
test_prism_eval(':"1 #{1 + 2} 1"')
|
||||
end
|
||||
|
||||
def test_InterpolatedXStringNode
|
||||
test_yarp_eval('`echo #{1}`')
|
||||
test_yarp_eval('`printf #{"100"}`')
|
||||
test_prism_eval('`echo #{1}`')
|
||||
test_prism_eval('`printf #{"100"}`')
|
||||
end
|
||||
|
||||
def test_RegularExpressionNode
|
||||
test_yarp_eval('/yct/')
|
||||
test_yarp_eval('/yct/i')
|
||||
test_yarp_eval('/yct/x')
|
||||
test_yarp_eval('/yct/m')
|
||||
test_yarp_eval('/yct/im')
|
||||
test_yarp_eval('/yct/mx')
|
||||
test_yarp_eval('/yct/xi')
|
||||
test_yarp_eval('/yct/ixm')
|
||||
test_prism_eval('/pit/')
|
||||
test_prism_eval('/pit/i')
|
||||
test_prism_eval('/pit/x')
|
||||
test_prism_eval('/pit/m')
|
||||
test_prism_eval('/pit/im')
|
||||
test_prism_eval('/pit/mx')
|
||||
test_prism_eval('/pit/xi')
|
||||
test_prism_eval('/pit/ixm')
|
||||
end
|
||||
|
||||
def test_StringConcatNode
|
||||
# test_yarp_eval('"YARP" "::" "ISeqTest"')
|
||||
# test_prism_eval('"Prism" "::" "ISeqTest"')
|
||||
end
|
||||
|
||||
def test_StringNode
|
||||
test_yarp_eval('"yct"')
|
||||
test_prism_eval('"pit"')
|
||||
end
|
||||
|
||||
def test_SymbolNode
|
||||
test_yarp_eval(":yct")
|
||||
test_prism_eval(":pit")
|
||||
end
|
||||
|
||||
def test_XStringNode
|
||||
# test_yarp_eval(<<~RUBY)
|
||||
# class YARP::ISeqTest
|
||||
# test_prism_eval(<<~RUBY)
|
||||
# class Prism::ISeqTest
|
||||
# def self.`(command) = command * 2
|
||||
# `yct`
|
||||
# `pit`
|
||||
# end
|
||||
# RUBY
|
||||
end
|
||||
|
@ -287,13 +287,13 @@ module YARP
|
|||
############################################################################
|
||||
|
||||
def test_AndNode
|
||||
test_yarp_eval("true && 1")
|
||||
test_yarp_eval("false && 1")
|
||||
test_prism_eval("true && 1")
|
||||
test_prism_eval("false && 1")
|
||||
end
|
||||
|
||||
def test_OrNode
|
||||
test_yarp_eval("true || 1")
|
||||
test_yarp_eval("false || 1")
|
||||
test_prism_eval("true || 1")
|
||||
test_prism_eval("false || 1")
|
||||
end
|
||||
|
||||
############################################################################
|
||||
|
@ -301,7 +301,7 @@ module YARP
|
|||
############################################################################
|
||||
|
||||
def test_BlockArgumentNode
|
||||
test_yarp_eval("1.then(&:to_s)")
|
||||
test_prism_eval("1.then(&:to_s)")
|
||||
end
|
||||
|
||||
############################################################################
|
||||
|
@ -309,20 +309,20 @@ module YARP
|
|||
############################################################################
|
||||
|
||||
def test_ParenthesesNode
|
||||
test_yarp_eval("()")
|
||||
test_yarp_eval("(1)")
|
||||
test_prism_eval("()")
|
||||
test_prism_eval("(1)")
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def compare_eval(source)
|
||||
ruby_eval = RubyVM::InstructionSequence.compile(source).eval
|
||||
yarp_eval = RubyVM::InstructionSequence.compile_yarp(source).eval
|
||||
prism_eval = RubyVM::InstructionSequence.compile_prism(source).eval
|
||||
|
||||
assert_equal ruby_eval, yarp_eval
|
||||
assert_equal ruby_eval, prism_eval
|
||||
end
|
||||
|
||||
def test_yarp_eval(source)
|
||||
def test_prism_eval(source)
|
||||
compare_eval(source)
|
||||
|
||||
begin
|
||||
|
|
|
@ -68,7 +68,7 @@ IO.foreach("|#{NM} #{ARGV.join(' ')}") do |line|
|
|||
next if n.include?(".")
|
||||
next if !so and n.start_with?("___asan_")
|
||||
case n
|
||||
when /\A(?:Init_|InitVM_|yp_|[Oo]nig|dln_|coroutine_)/
|
||||
when /\A(?:Init_|InitVM_|pm_|[Oo]nig|dln_|coroutine_)/
|
||||
next
|
||||
when /\Aruby_static_id_/
|
||||
next unless so
|
||||
|
|
|
@ -53,6 +53,7 @@ module SyncDefaultGems
|
|||
pathname: "ruby/pathname",
|
||||
pp: "ruby/pp",
|
||||
prettyprint: "ruby/prettyprint",
|
||||
prism: ["ruby/prism", "main"],
|
||||
pstore: "ruby/pstore",
|
||||
psych: 'ruby/psych',
|
||||
rdoc: 'ruby/rdoc',
|
||||
|
@ -79,7 +80,6 @@ module SyncDefaultGems
|
|||
weakref: "ruby/weakref",
|
||||
win32ole: "ruby/win32ole",
|
||||
yaml: "ruby/yaml",
|
||||
yarp: ["ruby/yarp", "main"],
|
||||
zlib: 'ruby/zlib',
|
||||
}.transform_keys(&:to_s)
|
||||
|
||||
|
@ -397,7 +397,7 @@ module SyncDefaultGems
|
|||
rm_rf(%w[spec/syntax_suggest libexec/syntax_suggest])
|
||||
cp_r("#{upstream}/spec", "spec/syntax_suggest")
|
||||
cp_r("#{upstream}/exe/syntax_suggest", "libexec/syntax_suggest")
|
||||
when "yarp"
|
||||
when "prism"
|
||||
# We don't want to remove prism-specific files that existing in ruby/ruby
|
||||
# that do not exist in ruby/prism, so we temporarily move them out of the
|
||||
# prism dir, wipe the prism dir, and then put them back.
|
||||
|
|
|
@ -150,13 +150,13 @@ FILES_NEED_VPATH = %w[
|
|||
enc/trans/utf8_mac.c
|
||||
enc/trans/utf_16_32.c
|
||||
|
||||
yarp/api_node.c
|
||||
yarp/ast.h
|
||||
yarp/node.c
|
||||
yarp/prettyprint.c
|
||||
yarp/serialize.c
|
||||
yarp/token_type.c
|
||||
yarp/version.h
|
||||
prism/api_node.c
|
||||
prism/ast.h
|
||||
prism/node.c
|
||||
prism/prettyprint.c
|
||||
prism/serialize.c
|
||||
prism/token_type.c
|
||||
prism/version.h
|
||||
]
|
||||
|
||||
# Multiple files with same filename.
|
||||
|
@ -184,7 +184,7 @@ def in_makefile(target, source)
|
|||
target = target.to_s
|
||||
source = source.to_s
|
||||
case target
|
||||
when %r{\A[^/]*\z}, %r{\Acoroutine/}, %r{\Ayarp/}
|
||||
when %r{\A[^/]*\z}, %r{\Acoroutine/}, %r{\Aprism/}
|
||||
target2 = "#{target.sub(/\.o\z/, '.$(OBJEXT)')}"
|
||||
case source
|
||||
when *FILES_IN_SOURCE_DIRECTORY then source2 = "$(top_srcdir)/#{source}"
|
||||
|
|
|
@ -1279,13 +1279,13 @@ $(ruby_pc): $(RBCONFIG)
|
|||
$(ECHO) assembling $(<:\=/)
|
||||
$(Q) $(AS) $(ASFLAGS) $(XCFLAGS) $(CPPFLAGS) $(COUTFLAG)$@ -c $(<:\=/)
|
||||
|
||||
{$(srcdir)/yarp}.c.obj:
|
||||
{$(srcdir)/prism}.c.obj:
|
||||
$(ECHO) compiling $(<:\=/)
|
||||
$(Q) $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$(<:\=/)
|
||||
{$(srcdir)/yarp/enc}.c.obj:
|
||||
{$(srcdir)/prism/enc}.c.obj:
|
||||
$(ECHO) compiling $(<:\=/)
|
||||
$(Q) $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$(<:\=/)
|
||||
{$(srcdir)/yarp/util}.c.obj:
|
||||
{$(srcdir)/prism/util}.c.obj:
|
||||
$(ECHO) compiling $(<:\=/)
|
||||
$(Q) $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$(<:\=/)
|
||||
{$(srcdir)/enc/trans}.c.obj:
|
||||
|
|
Загрузка…
Ссылка в новой задаче