Sha256: 8c9e8662e16c25124e83275da7ad3f81cd3b5b68f407bd69bbac4fa54acce5be

Contents?: true

Size: 1008 Bytes

Versions: 1

Compression:

Stored size: 1008 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)
      bytecode(g)
    }
  }

  class SingletonMethodDefScope : Rubinius AST DefineSingletonScope {
    def initialize: @line name: @name args: @arguments body: @body {
      if: (@body empty?) then: {
        @body unshift_expression: $ NilLiteral new: @line
      }
    }

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

    def bytecode: g receiver: receiver {
      pos(g)
      docstring = @body 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

1 entries across 1 versions & 1 rubygems

Version Path
fancy-0.8.0 lib/compiler/ast/singleton_method_def.fy