keriwarr / orangejoos

JOOS1W Compiler, written in Crystal
0 stars 1 forks source link

VTable base implementation. #85

Closed slnt closed 6 years ago

slnt commented 6 years ago

This is a prototype VTable implementation. This only gathers all the data that will back each VTable column, but does not create the ASM. It also needs an interface to be used by the code generator for deciding the offset of each method.

slnt commented 6 years ago

example VTable

; === class: pkg.Foo
; === source: test/codegen/Interfaces/pkg/Foo.java

  SECTION .data

  GLOBAL  VTABLE$pkg$Foo
  VTABLE$pkg$Foo:
    ; [ INTERFACES ]
    DD METHOD$pkg$Foo$foo#              ; IFACE$pkg.stuff$Fooer$foo#
    DD 0                                ; IFACE$pkg$Unused$noop#
    DD METHOD$pkg.stuff$Bar$hello#      ; IFACE$pkg.stuff$Greeter$hello#
    DD METHOD$pkg.stuff$Bar$goodbye#    ; IFACE$pkg.stuff$Greeter$goodbye#
    DD METHOD$pkg$Foo$foo#              ; IFACE$pkg.stuff$Greeter$foo#
    ; [ METHODS ]
    DD METHOD$pkg.stuff$Bar$walk_into_bar#
    DD METHOD$pkg$Foo$foobar#

  SECTION .text

  GLOBAL  METHOD$pkg$Foo$chidori#
  METHOD$pkg$Foo$chidori#:
keriwarr commented 6 years ago

if you could delete run and move the tests I think this is ready to merge