ripping out procArityContains
This commit is contained in:
parent
93900d90c6
commit
702ced8ec9
|
@ -1,3 +1,10 @@
|
||||||
|
// Helper functions for whalesong.
|
||||||
|
//
|
||||||
|
// Note: this originally came from js-vm, and may have cruft that
|
||||||
|
// doesn't belong in whalesong. I need to clean this up.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (! this['plt']) { this['plt'] = {}; }
|
if (! this['plt']) { this['plt'] = {}; }
|
||||||
|
|
||||||
// Helpers library: includes a bunch of helper functions that will be used
|
// Helpers library: includes a bunch of helper functions that will be used
|
||||||
|
@ -159,36 +166,6 @@ if (! this['plt']) { this['plt'] = {}; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
var procArityContains = function(n) {
|
|
||||||
return function(proc) {
|
|
||||||
var singleCase = function(aCase) {
|
|
||||||
if ( aCase instanceof types.ContinuationClosureValue ) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return (aCase.numParams == n ||
|
|
||||||
(aCase.isRest && aCase.numParams <= n));
|
|
||||||
};
|
|
||||||
|
|
||||||
var cases = [];
|
|
||||||
if ( proc instanceof types.ContinuationClosureValue ||
|
|
||||||
proc instanceof types.ClosureValue ||
|
|
||||||
proc instanceof types.PrimProc ) {
|
|
||||||
return singleCase(proc);
|
|
||||||
}
|
|
||||||
else if (proc instanceof types.CasePrimitive) {
|
|
||||||
cases = proc.cases;
|
|
||||||
}
|
|
||||||
else if (proc instanceof types.CaseLambdaValue) {
|
|
||||||
cases = proc.closures;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var i = 0; i < cases.length; i++) {
|
|
||||||
if ( singleCase(cases[i]) )
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
var throwCheckError = function(details, pos, args) {
|
var throwCheckError = function(details, pos, args) {
|
||||||
var errorFormatStr;
|
var errorFormatStr;
|
||||||
|
@ -937,7 +914,6 @@ if (! this['plt']) { this['plt'] = {}; }
|
||||||
helpers.reportError = reportError;
|
helpers.reportError = reportError;
|
||||||
helpers.raise = raise;
|
helpers.raise = raise;
|
||||||
|
|
||||||
helpers.procArityContains = procArityContains;
|
|
||||||
helpers.throwCheckError = throwCheckError;
|
helpers.throwCheckError = throwCheckError;
|
||||||
helpers.isList = isList;
|
helpers.isList = isList;
|
||||||
helpers.isListOf = isListOf;
|
helpers.isListOf = isListOf;
|
||||||
|
|
|
@ -1,3 +1,10 @@
|
||||||
|
// The definitions of the basic types in Whalesong.
|
||||||
|
//
|
||||||
|
// Note: this originally came from js-vm, and as a result,
|
||||||
|
// there's quite a lot of cruft and unused code in this module.
|
||||||
|
// I need to filter and rip out the values that aren't used in Whalesong.
|
||||||
|
|
||||||
|
|
||||||
if (! this['plt']) { this['plt'] = {}; }
|
if (! this['plt']) { this['plt'] = {}; }
|
||||||
|
|
||||||
// FIXME: there's a circularity between this module and helpers, and that circularly
|
// FIXME: there's a circularity between this module and helpers, and that circularly
|
||||||
|
@ -1244,7 +1251,7 @@ String.prototype.toDisplayedString = function(cache) {
|
||||||
newType.type.prototype.invokeEffect = function(aBigBang, k) {
|
newType.type.prototype.invokeEffect = function(aBigBang, k) {
|
||||||
var schemeChangeWorld = new PrimProc('update-world', 1, false, false,
|
var schemeChangeWorld = new PrimProc('update-world', 1, false, false,
|
||||||
function(worldUpdater) {
|
function(worldUpdater) {
|
||||||
helpers.check(worldUpdater, helpers.procArityContains(1),
|
//helpers.check(worldUpdater, helpers.procArityContains(1),
|
||||||
'update-world', 'procedure (arity 1)', 1);
|
'update-world', 'procedure (arity 1)', 1);
|
||||||
|
|
||||||
return new INTERNAL_PAUSE(
|
return new INTERNAL_PAUSE(
|
||||||
|
@ -2263,7 +2270,7 @@ String.prototype.toDisplayedString = function(cache) {
|
||||||
// big bang info to be passed into a make-world-config startup argument
|
// big bang info to be passed into a make-world-config startup argument
|
||||||
var BigBangInfo = makeStructureType('bb-info', false, 2, 0, false,
|
var BigBangInfo = makeStructureType('bb-info', false, 2, 0, false,
|
||||||
function(args, name, k) {
|
function(args, name, k) {
|
||||||
helpers.check(args[0], helpers.procArityContains(1), name, 'procedure (arity 1)', 1);
|
//helpers.check(args[0], helpers.procArityContains(1), name, 'procedure (arity 1)', 1);
|
||||||
helpers.check(args[1], types.isJsValue, name, 'js-object', 2);
|
helpers.check(args[1], types.isJsValue, name, 'js-object', 2);
|
||||||
return k(args);
|
return k(args);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user