Class: JSCompiler

Inherits:
Object
  • Object
show all
Defined in:
lib/fwi/compilers/js/compiler.rb

Constant Summary collapse

GEN =
FWI::Generator::JS.new

Instance Method Summary collapse

Instance Method Details

#after_parseObject



12
# File 'lib/fwi/compilers/js/compiler.rb', line 12

def after_parse; end

#compile(file, lex, bitmap, options) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/fwi/compilers/js/compiler.rb', line 15

def compile file, lex, bitmap, options
    base = File.basename(file, File.extname(file))

    files = GEN.gen bitmap
    if @options[:bundle].nil?
        files.each do |fn, contents|
            f = File.join(options[:output], fn)
            FileUtils.mkdir_p File.expand_path("..", f)
            File.write(f, contents)
        end
    else
        contents = ""
        files.each do |fn, fcontents|
            contents << "// File: #{fn}\n"
            contents << fcontents
            contents << "\n"
        end
        f = File.join(options[:output], @options[:bundle])
        FileUtils.mkdir_p File.expand_path("..", f)
        File.write(f, contents)
    end
end

#on_selectedObject



13
# File 'lib/fwi/compilers/js/compiler.rb', line 13

def on_selected; end

#populate_options(o) ⇒ Object



7
8
9
10
# File 'lib/fwi/compilers/js/compiler.rb', line 7

def populate_options o
    @options = {}
    o.on("--bundle [NAME]", "Create a JavaScript bundle file with the given name") { |name| @options[:bundle] = name }
end