Sha256: 5cb1cef76f52df1fbc78ff67e3823005bb890fe549e746de9caaf45e7ee9acc9

Contents?: true

Size: 974 Bytes

Versions: 3

Compression:

Stored size: 974 Bytes

Contents

class Fancy AST {
  class SingletonMethodDef : Rubinius AST DefineSingleton {
    def initialize: @line name: @name args: @arguments body: @body access: @access owner: @receiver {
      name = @name method_name: @receiver
      @body = SingletonMethodDefScope new: @line name: name args: @arguments body: @body
    }

    def bytecode: g {
      pos(g)
      g push_self()
      g send(@access, 0)
      g pop()
      bytecode(g)
    }
  }

  class SingletonMethodDefScope : Rubinius AST DefineSingletonScope {
    def initialize: @line name: @name args: @arguments body: @body {
    }

    define_method("bytecode") |g, recv| {
      bytecode: g receiver: recv
    }

    def bytecode: g receiver: receiver {
      pos(g)
      docstring = @body shift_docstring
      sup = Rubinius AST DefineSingletonScope instance_method('bytecode)
      sup bind(self) call(g, receiver)
      MethodDef set: g docstring: docstring line: @line argnames: $ @arguments names()
    }
  }
}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fancy-0.6.0 lib/compiler/ast/singleton_method_def.fy
fancy-0.5.0 lib/compiler/ast/singleton_method_def.fy
fancy-0.4.0 lib/compiler/ast/singleton_method_def.fy