Sha256: 58191719efc0954a1b07937c22632b36a274b2586cc06d94be6ee080028dcb70

Contents?: true

Size: 1.11 KB

Versions: 4

Compression:

Stored size: 1.11 KB

Contents

class Fancy AST {
  class TupleLiteral : Node {
    def initialize: @line entries: @elements { }

    def bytecode: g {
      pos(g)
      ary = ArrayLiteral new: @line array: [FixnumLiteral new: @line value: (@elements size)]

      args = RubyArgs new: @line args: ary

      msg_ident = Identifier from: "new" line: @line
      msg_ident ruby_ident: true
      ms = MessageSend new:     @line                                            \
                       message: (msg_ident)                                      \
                       to:      (Identifier from: "Rubinius::Tuple" line: @line) \
                       args:    args

      ms bytecode: g

      @elements each_with_index() |e i| {
        g dup()
        ary = [FixnumLiteral new: @line value: i, e]

        ms = MessageSend new:  @line                                       \
                         message: (Identifier from: "at:put:" line: @line) \
                         to:   (Nothing new: @line)                        \
                         args: (MessageArgs new: @line args: ary)

        ms bytecode: g
        g pop()
      }
    }
  }
}

Version data entries

4 entries across 4 versions & 1 rubygems

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