Sha256: 87acad22bc6cf033ad56d23b9fc7257291af371e1272f88fe5454f2c66fc711c
Contents?: true
Size: 895 Bytes
Versions: 16
Compression:
Stored size: 895 Bytes
Contents
# frozen_string_literal: true require 'opal/nodes/base' module Opal module Nodes module Args # This node is responsible for extracting a single # optional post-argument # # args_to_keep is the number of required post-arguments # # def m(a = 1, b, c, d); end # becomes something like: # if post_args.length > 3 # a = post_args[0] # post_args = post_args[1..-1] # end # class ExtractPostOptarg < Base handle :extract_post_optarg children :name, :default_value, :args_to_keep def compile add_temp name line "if ($post_args.length > #{args_to_keep}) #{name} = $post_args.shift();" return if default_value.children[1] == :undefined push "if (#{name} == null) #{name} = ", expr(default_value) end end end end end
Version data entries
16 entries across 16 versions & 1 rubygems