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
module Visitable | |
def accept object | |
object.visit self | |
end | |
end | |
class Visitor | |
def visit thing | |
send(:"visit_#{thing.class.name}", thing) | |
end |
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
require "fiddle" | |
require "ffi" | |
require "jit_buffer" | |
require "hacks" | |
require "aarch64" | |
require "benchmark/ips" | |
module FJIT | |
C = RubyVM::RJIT.const_get(:C) | |
include AArch64::Registers |
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
require "set" | |
require "rbconfig" | |
class Wrapper | |
def initialize | |
@a = Set.new | |
@b = Set.new | |
end | |
def write_a |
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/tool/ruby_vm/views/_insn_entry.erb b/tool/ruby_vm/views/_insn_entry.erb | |
index 6ec33461c4..bc9a1d44b4 100644 | |
--- a/tool/ruby_vm/views/_insn_entry.erb | |
+++ b/tool/ruby_vm/views/_insn_entry.erb | |
@@ -64,7 +64,7 @@ INSN_ENTRY(<%= insn.name %>) | |
INC_SP(INSN_ATTR(sp_inc)); | |
% insn.rets.reverse_each.with_index do |ret, i| | |
TOPN(<%= i %>) = <%= insn.cast_to_VALUE ret %>; | |
- VM_ASSERT(!RB_TYPE_P(TOPN(<%= i %>), T_NONE)); | |
+ assert(!RB_TYPE_P(TOPN(<%= i %>), T_NONE)); |
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
require 'fiddle' | |
SIZEOF_HEAP_PAGE_HEADER_STRUCT = Fiddle::SIZEOF_VOIDP | |
SIZEOF_RVALUE = 40 | |
HEAP_PAGE_ALIGN_LOG = 14 | |
HEAP_PAGE_ALIGN = 1 << HEAP_PAGE_ALIGN_LOG # 2 ^ 14 | |
HEAP_PAGE_ALIGN_MASK = ~(~0 << HEAP_PAGE_ALIGN_LOG) # Mask for getting page address | |
REQUIRED_SIZE_BY_MALLOC = Fiddle::SIZEOF_SIZE_T * 5 # padding needed by malloc | |
HEAP_PAGE_SIZE = HEAP_PAGE_ALIGN - REQUIRED_SIZE_BY_MALLOC # Actual page size |
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
require "strscan" | |
class Scanner | |
TOK = [] | |
TOK["{".ord] = :LBRACE; TOK["}".ord] = :RBRACE; TOK[";".ord] = :SEMI | |
def initialize data | |
@scan = StringScanner.new data | |
@prev_pos = @scan.pos | |
end |
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
require "strscan" | |
class Lexer | |
IDENTIFIER = /[_A-Za-z][_0-9A-Za-z]*\b/ | |
IGNORE = %r{ | |
(?: | |
[, \c\r\n\t]+ | | |
\#.*$ | |
)* | |
}x |
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
require 'socket' | |
require 'openssl' | |
require 'puma/server' | |
require 'ds9' | |
class Server < DS9::Server | |
def initialize socket, app | |
@app = app | |
@read_streams = {} | |
@write_streams = {} |
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
require 'webrick' | |
require 'webrick/https' | |
require 'ds9' | |
class HTTP2Server < WEBrick::HTTPServer | |
SETTINGS = [ [DS9::Settings::MAX_CONCURRENT_STREAMS, 100] ] | |
class HTTP2Response < WEBrick::HTTPResponse | |
def initialize config, ctx, stream_id | |
@ctx = ctx |
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
#!/Users/aaron/.rubies/arm64/ruby-trunk/bin/ruby | |
# This is a demo language server for Ruby, written in Ruby. It just checks | |
# the syntax of Ruby programs when you save them. | |
# | |
# Configure this in Vim by adding the vim-lsp plugin, then doing this | |
# in your vimrc: | |
# | |
# au User lsp_setup | |
# \ lsp#register_server({ |
NewerOlder