Module: TraceurCompiler::Source

Defined in:
lib/traceur_compiler.rb

Class Method Summary collapse

Class Method Details

.contentsObject



16
17
18
# File 'lib/traceur_compiler.rb', line 16

def self.contents
  @contents ||= File.read(path)
end

.contextObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/traceur_compiler.rb', line 20

def self.context
  return @context unless @context.nil?
  @context = ExecJS.compile(contents)
  @context.exec "    console = {\n      error: function () { },\n      log: function () { }\n    };\n  stubs\n  @context.exec <<-compile\n    compile = function (contents, options) {\n      for (var key in options) {\n        traceur.options[key] = options[key];\n      }\n\n      var project = new traceur.semantics.symbols.Project(''),\n        reporter = new traceur.util.ErrorReporter();\n      reporter.reportMessageInternal = function (location, format, args) {\n        throw new Error(traceur.util.ErrorReporter.format(location, format, args));\n      };\n\n      project.addFile(new traceur.syntax.SourceFile('unknown', contents));\n      var response = traceur.codegeneration.Compiler.compile(reporter, project, false);\n      return traceur.outputgeneration.ProjectWriter.write(response, {});\n    }\n  compile\n  @context\nend\n"

.pathObject



7
8
9
# File 'lib/traceur_compiler.rb', line 7

def self.path
  @path ||= ENV['TRACEUR_COMPILER_SOURCE_PATH'] || bundled_path
end

.path=(path) ⇒ Object



11
12
13
14
# File 'lib/traceur_compiler.rb', line 11

def self.path=(path)
  @contents = @context = nil
  @path = path
end