Sha256: e06ad03ca02f8ce38b4b5bdb51685f8c7232b9b1d3df645f6669a86f541bf7c4

Contents?: true

Size: 1.41 KB

Versions: 18

Compression:

Stored size: 1.41 KB

Contents

# frozen_string_literal: true

require 'opal/nodes/base'
require 'opal/nodes/call'

module Opal
  module Nodes
    # recvr.JS[:prop]
    # => recvr.prop
    class JsAttrNode < Base
      handle :jsattr
      children :recvr, :property

      def compile
        push recv(recvr), '[', expr(property), ']'
      end
    end

    # recvr.JS[:prop] = value
    # => recvr.prop = value
    class JsAttrAsgnNode < Base
      handle :jsattrasgn

      children :recvr, :property, :value

      def compile
        push recv(recvr), '[', expr(property), '] = ', expr(value)
      end
    end

    class JsCallNode < CallNode
      handle :jscall

      def initialize(*)
        super

        # For .JS. call we pass a block
        # as a plain JS callback
        if @iter
          @arglist = @arglist << @iter
        end
        @iter = nil
      end

      def compile
        default_compile
      end

      def method_jsid
        ".#{meth}"
      end

      def compile_using_send
        push recv(receiver_sexp), method_jsid, '.apply(null'
        compile_arguments
        if iter
          push '.concat(', expr(iter), ')'
        end
        push ')'
      end
    end

    # /regexp/ =~ rhs
    # s(:match_with_lvasgn, lhs, rhs)
    class Match3Node < Base
      handle :match_with_lvasgn

      children :lhs, :rhs

      def compile
        sexp = s(:send, lhs, :=~, rhs)
        push process(sexp, @level)
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
opal-1.3.2 lib/opal/nodes/call_special.rb
opal-1.3.1 lib/opal/nodes/call_special.rb
opal-1.3.0 lib/opal/nodes/call_special.rb
opal-1.3.0.rc1 lib/opal/nodes/call_special.rb
opal-1.3.0.alpha1 lib/opal/nodes/call_special.rb
opal-1.2.0 lib/opal/nodes/call_special.rb
opal-1.2.0.beta1 lib/opal/nodes/call_special.rb
opal-1.1.1 lib/opal/nodes/call_special.rb
opal-1.1.1.rc1 lib/opal/nodes/call_special.rb
opal-1.1.0 lib/opal/nodes/call_special.rb
opal-1.1.0.rc1 lib/opal/nodes/call_special.rb
opal-1.0.5 lib/opal/nodes/call_special.rb
opal-1.0.4 lib/opal/nodes/call_special.rb
opal-1.0.3 lib/opal/nodes/call_special.rb
opal-1.0.2 lib/opal/nodes/call_special.rb
opal-1.0.1 lib/opal/nodes/call_special.rb
opal-1.0.0 lib/opal/nodes/call_special.rb
opal-1.0.0.beta1 lib/opal/nodes/call_special.rb