Sha256: c87ef781c9910a6ab56b0656180fb720eead46aa58f94aa2e1530098a42b29a5

Contents?: true

Size: 1007 Bytes

Versions: 1

Compression:

Stored size: 1007 Bytes

Contents

class Fancy AST {
  class ClassDef : Rubinius AST Class {
    def initialize: @line name: @name parent: @parent body: @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

1 entries across 1 versions & 1 rubygems

Version Path
fancy-0.3.3 lib/compiler/ast/class_def.fy