Sha256: ecd56317007c2367e7b4e059645a88073ef65c29e64900003a440dea2e46ace3
Contents?: true
Size: 739 Bytes
Versions: 36
Compression:
Stored size: 739 Bytes
Contents
module Ruby2JS class Converter # (while # (true) # (...)) handle :while do |condition, block| begin next_token, @next_token = @next_token, :continue # handle while loops that assign a variable while condition.type == :begin and condition.children.length == 1 condition = condition.children.first end if condition.type == :lvasgn var = condition.children[0] unless @vars[var] put "#{es2015 ? 'let' : 'var'} #{var}#@sep" @vars[var] = true end end put 'while ('; parse condition; puts ') {'; scope block; sput '}' ensure @next_token = next_token end end end end
Version data entries
36 entries across 36 versions & 1 rubygems