Sha256: d3a10717d024e999b5c754dec87ecb895b92f5f2d6d0c0478abb67e3955d8d5c

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

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 {
      { @body = ExpressionList new: @line } unless: @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

2 entries across 2 versions & 1 rubygems

Version Path
fancy-0.10.0 lib/compiler/ast/singleton_method_def.fy
fancy-0.9.0 lib/compiler/ast/singleton_method_def.fy