Sha256: 14b9ab5b4e5e020045de25794f713955056b58202e56f4f75830cdb9ef310799
Contents?: true
Size: 900 Bytes
Versions: 6
Compression:
Stored size: 900 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 line "if (#{name} == null) #{name} = ", expr(default_value), ";" end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems