Sha256: 5a6a62aae4eb94040cf84810bc5041115076c03563d2a6bd70e6f301ca96d10f

Contents?: true

Size: 1.1 KB

Versions: 2

Compression:

Stored size: 1.1 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: "[]:" line: @line) \
                         to:   (Nothing new: @line)                        \
                         args: (MessageArgs new: @line args: ary)

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

Version data entries

2 entries across 2 versions & 1 rubygems

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