writing-a-compiler-in-ruby
writing-a-compiler-in-ruby copied to clipboard
Code from my series on writing a Ruby compiler in Ruby
``` class Foo attr_accessor :seq end ``` the attr_accessor bit turns into: ``` # callm :self.:attr_accessor subl $20, %esp movl $2, %ebx movl Foo, %eax movl %eax, (%esp) movl $3481,...
ClassScope should inherity from ModuleScope. ModuleScope needs to hold constants. "Global" constants should be held in a module scope - either make GlobalScope inherit from ModuleScope too, or introduce a...
The parser will treat "foo" by itself as a local variable because it initially doesn't know if it's a local variable or a method call. When we have identified the...
MRI uses type tagging for those. Need to decide whether to do type tagging (more complex code) or do what Python does (memoize small integers) - the benefit of the...
gcc will not compile variable references that start with an at-sign (@). need to change names of instance and class variables to something else, for example: @var = __classname__instance__var @@var...
Example: ``` bignum_value.should == 0x8000_0000_0000_0000 ```