summaryrefslogtreecommitdiff
path: root/threads.js
diff options
context:
space:
mode:
authorBartosz Leper <bl.nero@gmail.com>2015-07-20 21:33:33 +0200
committerBartosz Leper <bl.nero@gmail.com>2015-07-20 21:33:33 +0200
commit81476aa5882ec7a25dc03e4f8f5a14ff412434a9 (patch)
tree9e8e882e250168563afca79636d0dba9351bc3a9 /threads.js
parent12671a1fbd6044f22ba037347b6af1bf170af9da (diff)
parent53068ea25954431c174dca1e76ca924b00243c2f (diff)
downloadsnap-81476aa5882ec7a25dc03e4f8f5a14ff412434a9.tar.gz
snap-81476aa5882ec7a25dc03e4f8f5a14ff412434a9.zip
Merge branch 'master' into manual
Diffstat (limited to 'threads.js')
-rw-r--r--threads.js43
1 files changed, 21 insertions, 22 deletions
diff --git a/threads.js b/threads.js
index 165ad0e..af899dc 100644
--- a/threads.js
+++ b/threads.js
@@ -83,7 +83,7 @@ ArgLabelMorph, localize, XML_Element, hex_sha512*/
// Global stuff ////////////////////////////////////////////////////////
-modules.threads = '2015-May-01';
+modules.threads = '2015-June-25';
var ThreadManager;
var Process;
@@ -339,7 +339,7 @@ ThreadManager.prototype.findProcess = function (block) {
*/
Process.prototype = {};
-Process.prototype.contructor = Process;
+Process.prototype.constructor = Process;
Process.prototype.timeout = 500; // msecs after which to force yield
Process.prototype.isCatchingErrors = true;
@@ -2122,14 +2122,14 @@ Process.prototype.reportMonadic = function (fname, n) {
case 'ln':
result = Math.log(x);
break;
- case 'log':
- result = 0;
+ case 'log': // base 10
+ result = Math.log(x) / Math.LN10;
break;
case 'e^':
result = Math.exp(x);
break;
case '10^':
- result = 0;
+ result = Math.pow(10, x);
break;
default:
nop();
@@ -2640,31 +2640,30 @@ Process.prototype.reportTimer = function () {
};
// Process Dates and times in Snap
-// Map block options to built-in functions
-var dateMap = {
- 'year' : 'getFullYear',
- 'month' : 'getMonth',
- 'date': 'getDate',
- 'day of week' : 'getDay',
- 'hour' : 'getHours',
- 'minute' : 'getMinutes',
- 'second' : 'getSeconds',
- 'time in milliseconds' : 'getTime'
-};
-
Process.prototype.reportDate = function (datefn) {
- var inputFn = this.inputOption(datefn),
- currDate = new Date(),
- func = dateMap[inputFn],
- result = currDate[func]();
+ var currDate, func, result,
+ inputFn = this.inputOption(datefn),
+ // Map block options to built-in functions
+ dateMap = {
+ 'year' : 'getFullYear',
+ 'month' : 'getMonth',
+ 'date': 'getDate',
+ 'day of week' : 'getDay',
+ 'hour' : 'getHours',
+ 'minute' : 'getMinutes',
+ 'second' : 'getSeconds',
+ 'time in milliseconds' : 'getTime'
+ };
if (!dateMap[inputFn]) { return ''; }
+ currDate = new Date();
+ func = dateMap[inputFn];
+ result = currDate[func]();
// Show months as 1-12 and days as 1-7
if (inputFn === 'month' || inputFn === 'day of week') {
result += 1;
}
-
return result;
};