Sha256: c03b871eea1a0279e0a0b91b1d9c6dd157940e33831074148e91a308e9c8afb5

Contents?: true

Size: 1.07 KB

Versions: 3

Compression:

Stored size: 1.07 KB

Contents

class Fancy AST {
  class ClassDef : Rubinius AST Class {
    def initialize: @line name: @name parent: @parent body: @body (ExpressionList new: @line) {
      { @body = ExpressionList new: @line } unless: @body
      name = nil
      if: (@name is_a?: NestedConstant) then: {
        name = @name scoped
      } else: {
        name = @name string to_sym()
      }

      if: (@body empty?) then: {
        @body unshift_expression: $ NilLiteral new: @line
      }

      initialize(@line, name, @parent, @body)
    }

    def bytecode: g {
      pos(g)
      docstring = body() body() shift_docstring
      docstring if_true: {
        setdoc = MessageSend new: @line \
                             message: (Identifier from: "for:append:" line: @line) \
                             to: (Identifier from: "Fancy::Documentation" line: @line) \
                             args: (MessageArgs new: @line args: [Self new: @line, docstring])

        # Replace first string expression to set documentation.
        body() body() unshift_expression: setdoc
      }
      bytecode(g)
    }
  }
}

Version data entries

3 entries across 3 versions & 1 rubygems

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