Sha256: 271b4c07ac3c2a9bb63fb239852dbabd9f826799f813438e1307fdc72569a046

Contents?: true

Size: 973 Bytes

Versions: 4

Compression:

Stored size: 973 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

4 entries across 4 versions & 1 rubygems

Version Path
fancy-0.3.3 lib/compiler/ast/singleton_method_def.fy
fancy-0.3.2 lib/compiler/ast/singleton_method_def.fy
fancy-0.3.1 lib/compiler/ast/singleton_method_def.fy
fancy-0.3.0 lib/compiler/ast/singleton_method_def.fy