Class: EPM::Compile

Inherits:
Object
  • Object
show all
Defined in:
lib/epm/compile.rb

Instance Method Summary collapse

Constructor Details

#initialize(file, settings = {}) ⇒ Compile

Returns a new instance of Compile.



5
6
7
8
# File 'lib/epm/compile.rb', line 5

def initialize file, settings={}
  @file     = EPM::FileHelpers.file_guard file
  @settings = settings
end

Instance Method Details

#compileObject



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/epm/compile.rb', line 10

def compile
  if @file
    if File.extname(@file) == '.lll'
      return compile_lll
    elsif File.extname(@file) == ('.mu' || '.mut')
      return compile_mutan
    elsif File.extname(@file) == ('.se' || '.ser')
      return compile_serpent
    end
  end
end

#compile_lllObject



22
23
24
25
26
27
# File 'lib/epm/compile.rb', line 22

def compile_lll
  contract = `#{@settings["path-to-lllc"]} #{@file}`
  contract.chomp!
  contract = EPM::HexData.hex_guard contract
  return contract
end

#compile_mutanObject



35
36
37
38
39
# File 'lib/epm/compile.rb', line 35

def compile_mutan
  contract = `#{@settings['path-to-mutan']} #{Shellwords.escape(@file)}`
  contract.chomp!
  return EPM::HexData.hex_guard contract
end

#compile_serpentObject



29
30
31
32
33
# File 'lib/epm/compile.rb', line 29

def compile_serpent
  contract = `#{@settings['path-to-serpent']} #{Shellwords.escape(@file)}`
  contract.chomp!
  return EPM::HexData.hex_guard contract
end