Sha256: 6c4b872dd982a1b2fa793e4b89816d4a294666daf2888e51c4a05b0aa73d66af

Contents?: true

Size: 763 Bytes

Versions: 4

Compression:

Stored size: 763 Bytes

Contents

class Fancy
  class AST

    class RubyArgs < Node
      def initialize(line, args, block = nil)
        super(line)
        @args = args
        # If no block given and last arg is a block identifier
        if block.nil? &&
            args.array.last.kind_of?(Fancy::AST::Identifier) &&
            args.array.last.identifier =~ /^&\w/
          block = args.array.pop
          block = Fancy::AST::Identifier.new(block.line, block.identifier[1..-1])
        end
        @block = block
      end

      def bytecode(g)
        @args.array.each do |a|
          a.bytecode(g)
        end
        @block.bytecode(g) if @block
      end

      def size
        @args.array.size
      end

      def has_block?
        not @block.nil?
      end
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fancy-0.3.3 boot/rbx-compiler/compiler/ast/ruby_args.rb
fancy-0.3.2 boot/rbx-compiler/compiler/ast/ruby_args.rb
fancy-0.3.1 boot/rbx-compiler/compiler/ast/ruby_args.rb
fancy-0.3.0 boot/rbx-compiler/compiler/ast/ruby_args.rb