Code coverage report for sc/lang/main.js

Statements: 100% (40 / 40)      Branches: 100% (4 / 4)      Functions: 100% (11 / 11)      Lines: 100% (40 / 40)      Ignored: none     

All files » sc/lang/ » main.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 771     1 1   1   1 1   1 1 1   1 2 1   2     1 210     1 115     1 1086     1 3431     1 1 1 1   1 1       1           1 34 13 13   21     1 1     1 1     1 1     1    
(function(sc) {
  "use strict";
 
  require("./lang");
  require("./dollar");
 
  var main = {};
 
  var $ = sc.lang.$;
  var random = sc.libs.random;
 
  var $process = null;
  var $currentEnvir = null;
  var $currentThread = {};
 
  main.run = function(func) {
    if (!$process) {
      initialize();
    }
    return func($);
  };
 
  main.setCurrentEnvir = function($envir) {
    $currentEnvir = $envir;
  };
 
  main.getCurrentEnvir = function() {
    return $currentEnvir;
  };
 
  main.setCurrentThread = function($thread) {
    $currentThread = $thread;
  };
 
  main.getCurrentThread = function() {
    return $currentThread;
  };
 
  function initialize() {
    $process = $("Main").new();
    $process._$interpreter = $("Interpreter").new();
    $process._$mainThread  = $("Thread").new($.Func());
 
    $currentEnvir = $("Environment").new();
    $currentThread = $process._$mainThread;
 
    // $interpreter._$s = SCServer.default();
 
    random.setCurrent($process._$mainThread._randgen);
    // TODO:
    // SoundSystem.addProcess($process);
    // SoundSystem.start();
  }
 
  $.addProperty("Environment", function(key, $value) {
    if ($value) {
      $currentEnvir.put($.Symbol(key), $value);
      return $value;
    }
    return $currentEnvir.at($.Symbol(key));
  });
 
  $.addProperty("This", function() {
    return $process.interpreter();
  });
 
  $.addProperty("ThisProcess", function() {
    return $process;
  });
 
  $.addProperty("ThisThread", function() {
    return $currentThread;
  });
 
  sc.lang.main = main;
})(sc);