Skip to content

Commit

Permalink
Merge pull request #17 from katsyoshi/refactoring-rbs-file
Browse files Browse the repository at this point in the history
Refactoring rbs file
  • Loading branch information
katsyoshi authored Jun 4, 2023
2 parents c3e6bb8 + 1f75ffe commit 8245dfe
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 62 deletions.
10 changes: 0 additions & 10 deletions lib/vaporware/compiler/generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,6 @@ def method(method, node, output)
nil
end

def args(node, output)
node.children.each do |child|
name = "arg_#{child.children.first}".to_sym rescue binding.irb
lvar(name, output)
output.puts " pop rax"
output.puts " mov rax, [rax]"
output.puts " push rax"
end
end

def call_method(node, output, method_tree)
output.puts " mov rax, rsp"
output.puts " mov rdi, 16"
Expand Down
2 changes: 1 addition & 1 deletion rbs_collection.lock.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
sources:
- type: git
name: ruby/gem_rbs_collection
revision: 12631190e75c631eca0908ecc8c03bcfd78c0c99
revision: 28208148c7e64a25e9b86b9723b4c3a2cef14e81
remote: https://github.com/ruby/gem_rbs_collection.git
repo_dir: gems
path: ".gem_rbs_collection"
Expand Down
1 change: 0 additions & 1 deletion rbs_collection.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,5 @@ gems:
ignore: true
- name: vaporware
ignore: true
- name: parser
- name: set
ignore: true
50 changes: 0 additions & 50 deletions sig/vaporware.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,54 +3,4 @@ module Vaporware
# See the writing guide of rbs: https://github.com/ruby/rbs#guides
class Error
end
class Compiler
# class methods
def self.compile: (String, ?compiler: String, ?dest: String, ?debug: bool, ?compiler_options: Array[String], ?shared: bool) -> nil
def initialize: (String, ?_precompile: String, ?debug: bool, ?shared: bool) -> untyped

@generator: Vaporware::Compiler::Generator
# instance methods
def compile: (?compiler: String, ?compiler_options: Array[String]) -> nil
class Generator
REGISTER: Array[String]

# attr_accessor and define instance variables
@main: bool
attr_accessor main (): bool

# attr_reader for instance variables
attr_reader debug: bool
attr_reader doned: Set[Symbol]
attr_reader defined_methods: Set[Symbol]
attr_reader defined_variables: Set[Symbol]
attr_reader precompile: String
attr_reader seq: Integer
attr_reader shared: bool

# temporarily using untyped types since parser.gem's rbs information is unchecked.
attr_reader ast: RubyVM::AbstractSyntaxTree::Node

# class methods
def initialize: (String, precompile: String, debug: bool, shared: bool) -> untyped

# instance private methods
def already_build_methods?: -> bool
def args: (untyped, File) -> nil
def call_compiler: (?output: String, ?compiler: String, ?compiler_options: Array[String]) -> nil
def call_method: (untyped, File, bool) -> nil
def comp: (String, File) -> nil
def compile_shared_option: () -> Array[String]
def define_method_prologue: (untyped, File) -> nil
def epilogue: (File) -> nil
def lvar: (untyped, File) -> nil
def lvar_offset: (Symbol | nil) -> Integer
def method: (Symbol, untyped, File) -> nil
def prologue: (untyped, File) -> nil
def prologue_methods: (File) -> nil
def register_var_and_method: (RubyVM::AbstractSyntaxTree::Node) -> nil
def ret: (File) -> nil
def to_asm: (untyped, File, ?bool) -> nil
def variable_or_method?: (Symbol) -> bool
end
end
end
10 changes: 10 additions & 0 deletions sig/vaporware/compiler.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class Vaporware::Compiler
# class methods
def self.compile: (String, ?compiler: String, ?dest: String, ?debug: bool, ?compiler_options: Array[String], ?shared: bool) -> void
def initialize: (String, ?_precompile: String, ?debug: bool, ?shared: bool) -> void

@generator: Vaporware::Compiler::Generator
# instance methods
def compile: (?compiler: String, ?compiler_options: Array[String]) -> void
end

40 changes: 40 additions & 0 deletions sig/vaporware/compiler/generator.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
class Vaporware::Compiler::Generator
REGISTER: Array[String]

# attr_accessor and define instance variables
@main: bool
attr_accessor main (): bool

# attr_reader for instance variables
attr_reader debug: bool
attr_reader doned: Set[Symbol]
attr_reader defined_methods: Set[Symbol]
attr_reader defined_variables: Set[Symbol]
attr_reader precompile: String
attr_reader seq: Integer
attr_reader shared: bool

# temporarily using untyped types since parser.gem's rbs information is unchecked.
attr_reader ast: RubyVM::AbstractSyntaxTree::Node

# class methods
def initialize: (String, precompile: String, debug: bool, shared: bool) -> void

# instance private methods
def already_build_methods?: -> bool
def call_compiler: (?output: String, ?compiler: String, ?compiler_options: Array[String]) -> void
def call_method: (RubyVM::AbstractSyntaxTree::Node, File, bool) -> void
def comp: (String, File) -> void
def compile_shared_option: () -> Array[String]
def define_method_prologue: (RubyVM::AbstractSyntaxTree::Node, File) -> void
def epilogue: (File) -> void
def lvar: (Symbol, File) -> void
def lvar_offset: (Symbol | nil) -> Integer
def method: (Symbol, RubyVM::AbstractSyntaxTree::Node, File) -> void
def prologue: (RubyVM::AbstractSyntaxTree::Node, File) -> void
def prologue_methods: (File) -> void
def register_var_and_method: (RubyVM::AbstractSyntaxTree::Node) -> void
def ret: (File) -> void
def to_asm: (RubyVM::AbstractSyntaxTree::Node, File, ?bool) -> void
def variable_or_method?: (Symbol) -> bool
end

0 comments on commit 8245dfe

Please sign in to comment.