-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Stefan Marr <[email protected]>
- Loading branch information
Showing
10 changed files
with
54 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
[submodule "core-lib"] | ||
path = core-lib | ||
url = https://github.com/SOM-st/SOM.git | ||
[submodule "libs/big-integer"] | ||
path = libs/big-integer | ||
url = https://github.com/smarr/BigInteger.js.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
load: | ||
- libs/big-integer/BigInteger.js | ||
- src_gen/core_lib.js | ||
- src/lib/platform.js | ||
- src/lib/assert.js | ||
|
Submodule big-integer
deleted from
4d0d1e
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
/* | ||
* Copyright (c) 2014 Stefan Marr, [email protected] | ||
* | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
|
@@ -618,7 +618,7 @@ function Parser(fileContent, fileName) { | |
if (isInIntRange(i)) { | ||
return createLiteralNode(universe.newInteger(i), source); | ||
} else { | ||
return createLiteralNode(universe.newBiginteger(bigInt(i)), source); | ||
return createLiteralNode(universe.newBigInteger(BigInt(i)), source); | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
/* | ||
* Copyright (c) 2014 Stefan Marr, [email protected] | ||
* | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
|
@@ -96,9 +96,9 @@ function IntegerPrimitives() { | |
|
||
var result = l << r; | ||
if (Math.floor(l) != l || !isInIntRange(result) || !isInIntRange(l * Math.pow(2, r))) { | ||
var big = bigInt(l); | ||
big = big.multiply(Math.pow(2, r)); | ||
return universe.newBiginteger(big); | ||
var big = BigInt(l); | ||
big = big * BigInt(Math.pow(2, r)); | ||
return universe.newBigInteger(big); | ||
} | ||
return universe.newInteger(result); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
/* | ||
* Copyright (c) 2014 Stefan Marr, [email protected] | ||
* | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
|
@@ -455,8 +455,8 @@ function Universe() { | |
return new SInteger(intVal); | ||
}; | ||
|
||
this.newBiginteger = function (bigIntVal) { | ||
return new SBigInteger(bigIntVal); | ||
this.newBigInteger = function (BigIntVal) { | ||
return new SBigInteger(BigIntVal); | ||
}; | ||
|
||
this.newBlock = function (blockMethod, contextFrame) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
/* | ||
* Copyright (c) 2014 Stefan Marr, [email protected] | ||
* | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
|
@@ -35,9 +35,9 @@ function SBigInteger(bigintVal) { | |
if (right instanceof SDouble) { | ||
result = bigintVal.toJSNumber() < right; | ||
} else if (right instanceof SInteger) { | ||
result = bigintVal.lesser(right.getEmbeddedInteger()); | ||
result = bigintVal < right.getEmbeddedInteger(); | ||
} else { | ||
result = bigintVal.lesser(right.getEmbeddedBigInteger()); | ||
result = bigintVal < right.getEmbeddedBigInteger(); | ||
} | ||
return (result) ? som.trueObject : som.falseObject; | ||
}; | ||
|
@@ -48,36 +48,36 @@ function SBigInteger(bigintVal) { | |
|
||
this.primAdd = function (right) { | ||
if (right instanceof SBigInteger) { | ||
return universe.newBiginteger(right.getEmbeddedBigInteger().add(bigintVal)); | ||
return universe.newBigInteger(right.getEmbeddedBigInteger() + bigintVal); | ||
} else if (right instanceof SDouble) { | ||
return universe.newDouble(bigintVal.toJSNumber() + right.getEmbeddedDouble()); | ||
} else { | ||
return universe.newBiginteger(bigintVal.add(right.getEmbeddedInteger())) | ||
return universe.newBigInteger(bigintVal + right.getEmbeddedInteger()) | ||
} | ||
}; | ||
|
||
this.primSubtract = function (right) { | ||
var result; | ||
if (right instanceof SBigInteger) { | ||
result = bigintVal.subtract(right.getEmbeddedBigInteger()); | ||
result = bigintVal - right.getEmbeddedBigInteger(); | ||
} else if (right instanceof SDouble) { | ||
return universe.newDouble(bigintVal.toJSNumber() - right.getEmbeddedDouble()); | ||
} else { | ||
result = bigintVal.subtract(right.getEmbeddedInteger()) | ||
result = bigintVal - right.getEmbeddedInteger() | ||
} | ||
return universe.newBiginteger(result); | ||
return universe.newBigInteger(result); | ||
}; | ||
|
||
this.primMultiply = function (right) { | ||
var result; | ||
if (right instanceof SBigInteger) { | ||
result = bigintVal.multiply(right.getEmbeddedBigInteger()); | ||
result = bigintVal * right.getEmbeddedBigInteger(); | ||
} else if (right instanceof SDouble) { | ||
return universe.newDouble(bigintVal.toJSNumber() * right.getEmbeddedDouble()); | ||
} else { | ||
result = bigintVal.multiply(right.getEmbeddedInteger()) | ||
result = bigintVal * right.getEmbeddedInteger() | ||
} | ||
return universe.newBiginteger(result); | ||
return universe.newBigInteger(result); | ||
}; | ||
|
||
this.primDoubleDiv = function (right) { | ||
|
@@ -95,25 +95,25 @@ function SBigInteger(bigintVal) { | |
this.primIntDiv = function (right) { | ||
var result; | ||
if (right instanceof SBigInteger) { | ||
result = bigintVal.divide(right.getEmbeddedBigInteger()); | ||
result = bigintVal / right.getEmbeddedBigInteger(); | ||
} else if (right instanceof SDouble) { | ||
return universe.newDouble(bigintVal.toJSNumber()).primIntDiv(right); | ||
} else { | ||
result = bigintVal.divide(right.getEmbeddedInteger()); | ||
result = bigintVal / right.getEmbeddedInteger(); | ||
} | ||
return universe.newBiginteger(result); | ||
return universe.newBigInteger(result); | ||
}; | ||
|
||
this.primModulo = function (right) { | ||
var result; | ||
if (right instanceof SBigInteger) { | ||
result = bigintVal.mod(right.getEmbeddedBigInteger()); | ||
result = bigintVal % right.getEmbeddedBigInteger(); | ||
} else if (right instanceof SDouble) { | ||
return universe.newDouble(bigintVal.toJSNumber()).primModulo(right); | ||
} else { | ||
result = bigintVal.mod(right.getEmbeddedInteger()); | ||
result = bigintVal % right.getEmbeddedInteger(); | ||
} | ||
return universe.newBiginteger(result); | ||
return universe.newBigInteger(result); | ||
}; | ||
|
||
this.primAnd = function (right) { | ||
|
@@ -123,11 +123,11 @@ function SBigInteger(bigintVal) { | |
this.primEquals = function (right) { | ||
var result; | ||
if (right instanceof SBigInteger) { | ||
result = bigintVal.equals(right.getEmbeddedBigInteger()); | ||
result = bigintVal == right.getEmbeddedBigInteger(); | ||
} else if (right instanceof SDouble) { | ||
result = bigintVal.toJSNumber() == right.getEmbeddedDouble(); | ||
} else if (right instanceof SInteger) { | ||
result = bigintVal.equals(right.getEmbeddedInteger()); | ||
result = bigintVal == right.getEmbeddedInteger(); | ||
} else { | ||
result = false; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
/* | ||
* Copyright (c) 2014 Stefan Marr, [email protected] | ||
* | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
|
@@ -27,7 +27,7 @@ function intOrBigInt(val) { | |
if (isInIntRange(val)) { | ||
return universe.newInteger(val | 0); | ||
} else { | ||
return universe.newBiginteger(bigInt(val)); | ||
return universe.newBigInteger(BigInt(val)); | ||
} | ||
} | ||
|
||
|
@@ -46,26 +46,26 @@ function SInteger(intVal) { | |
function toDouble() { | ||
return universe.newDouble(intVal); // JS numbers are always doubles... | ||
} | ||
|
||
this.primLessThan = function (right) { | ||
var result; | ||
if (right instanceof SBigInteger) { | ||
result = bigInt(intVal).lesser(right.getEmbeddedBigInteger()); | ||
result = BigInt(intVal).lesser(right.getEmbeddedBigInteger()); | ||
} else if (right instanceof SDouble) { | ||
return toDouble.primLessThan(right); | ||
} else { | ||
result = intVal < right.getEmbeddedInteger(); | ||
} | ||
return (result) ? som.trueObject : som.falseObject; | ||
}; | ||
|
||
this.primAsString = function () { | ||
return universe.newString(intVal.toString()); | ||
}; | ||
|
||
this.primAdd = function (right) { | ||
if (right instanceof SBigInteger) { | ||
return universe.newBiginteger( | ||
return universe.newBigInteger( | ||
right.getEmbeddedBigInteger().add(intVal)); | ||
} else if (right instanceof SDouble) { | ||
return toDouble().primAdd(right); | ||
|
@@ -77,7 +77,7 @@ function SInteger(intVal) { | |
|
||
this.primSubtract = function (right) { | ||
if (right instanceof SBigInteger) { | ||
return universe.newBiginteger( | ||
return universe.newBigInteger( | ||
right.getEmbeddedBigInteger().subtract(intVal)); | ||
} else if (right instanceof SDouble) { | ||
return toDouble().primSubtract(right); | ||
|
@@ -89,7 +89,7 @@ function SInteger(intVal) { | |
|
||
this.primMultiply = function (right) { | ||
if (right instanceof SBigInteger) { | ||
return universe.newBiginteger( | ||
return universe.newBigInteger( | ||
right.getEmbeddedBigInteger().multiply(intVal)); | ||
} else if (right instanceof SDouble) { | ||
return toDouble().primMultiply(right); | ||
|
@@ -113,8 +113,8 @@ function SInteger(intVal) { | |
|
||
this.primIntDiv = function (right) { | ||
if (right instanceof SBigInteger) { | ||
var result = bigInt(intVal).divide(right.getEmbeddedBigInteger()); | ||
return universe.newBiginteger(result); | ||
var result = BigInt(intVal).divide(right.getEmbeddedBigInteger()); | ||
return universe.newBigInteger(result); | ||
} else if (right instanceof SDouble) { | ||
return toDouble(intVal).primIntDiv(right); | ||
} else { | ||
|
@@ -125,8 +125,8 @@ function SInteger(intVal) { | |
|
||
this.primModulo = function (right) { | ||
if (right instanceof SBigInteger) { | ||
var result = bigInt(intVal).mod(right.getEmbeddedBigInteger()); | ||
return universe.newBiginteger(result); | ||
var result = BigInt(intVal).mod(right.getEmbeddedBigInteger()); | ||
return universe.newBigInteger(result); | ||
} else if (right instanceof SDouble) { | ||
return toDouble(intVal).primModulo(right); | ||
} else { | ||
|
@@ -149,7 +149,7 @@ function SInteger(intVal) { | |
this.primEquals = function (right) { | ||
var result; | ||
if (right instanceof SBigInteger) { | ||
result = bigInt(intVal).equals(right.getEmbeddedBigInteger()); | ||
result = BigInt(intVal).equals(right.getEmbeddedBigInteger()); | ||
} else if (right instanceof SDouble) { | ||
result = intVal == right.getEmbeddedDouble(); | ||
} else if (right instanceof SInteger) { | ||
|