removing dependency on types

This commit is contained in:
Danny Yoo 2011-07-06 17:00:42 -04:00
parent cb99151753
commit a080f6079c
5 changed files with 35 additions and 20 deletions

View File

@ -68,8 +68,6 @@
baselib-exceptions.js baselib-exceptions.js
baselib-readergraph.js baselib-readergraph.js
link.js
types.js
runtime.js)) runtime.js))

View File

@ -153,6 +153,29 @@
var makePair = Cons.makeInstance; var makePair = Cons.makeInstance;
var makeList = function() {
var result = Empty.EMPTY;
for(var i = arguments.length-1; i >= 0; i--) {
result = Cons.makeInstance(arguments[i], result);
}
return result;
};
// isList: Any -> Boolean
// Returns true if x is a list (a chain of pairs terminated by EMPTY).
var isList = function(x) {
while (x !== Empty.EMPTY) {
if (x instanceof Cons){
x = x.rest;
} else {
return false;
}
}
return true;
};
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
@ -160,8 +183,9 @@
exports.Empty = Empty; exports.Empty = Empty;
exports.Cons = Cons; exports.Cons = Cons;
exports.isPair = isPair; exports.isPair = isPair;
exports.isList = isList;
exports.makePair = makePair; exports.makePair = makePair;
exports.makeList = makeList;
})(this['plt'].baselib); })(this['plt'].baselib);

View File

@ -6,7 +6,6 @@ if (! this['plt']) { this['plt'] = {}; }
var link = {}; var link = {};
scope['link'] = link; scope['link'] = link;
// link.ready: (string (string -> void)) -> void // link.ready: (string (string -> void)) -> void
// When the name announces that it's ready, calls the function f. // When the name announces that it's ready, calls the function f.
link.ready = function(name, f) { link.ready = function(name, f) {
@ -27,7 +26,6 @@ if (! this['plt']) { this['plt'] = {}; }
}; };
// notifyAll: string -> void // notifyAll: string -> void
// Tell all listeners that the name is ready. // Tell all listeners that the name is ready.
var notifyAll = function(name) { var notifyAll = function(name) {

View File

@ -27,18 +27,16 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
var isNumber = plt.baselib.numbers.isNumber; var isNumber = plt.baselib.numbers.isNumber;
var isNatural = plt.baselib.numbers.isNatural; var isNatural = plt.baselib.numbers.isNatural;
var isReal = plt.baselib.numbers.isReal; var isReal = plt.baselib.numbers.isReal;
var isPair = types.isPair; var isPair = plt.baselib.lists.isPair;
var isList = types.isList; var isList = plt.baselib.lists.isList;
var isVector = types.isVector; var isVector = plt.baselib.vectors.isVector;
var isString = types.isString; var isString = plt.baselib.strings.isString;
var equals = types.equals; var equals = plt.baselib.equality.equals;
var NULL = plt.baselib.lists.EMPTY;
var NULL = types.EMPTY;
var VOID = plt.baselib.constants.VOID_VALUE; var VOID = plt.baselib.constants.VOID_VALUE;
var EOF = plt.baselib.constants.EOF_VALUE; var EOF = plt.baselib.constants.EOF_VALUE;
var NEGATIVE_ZERO = plt.baselib.numbers.negative_zero; var NEGATIVE_ZERO = plt.baselib.numbers.negative_zero;
var INF = plt.baselib.numbers.inf; var INF = plt.baselib.numbers.inf;
var NEGATIVE_INF = plt.baselib.numbers.negative_inf; var NEGATIVE_INF = plt.baselib.numbers.negative_inf;
@ -50,9 +48,9 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
var makeComplex = plt.baselib.numbers.makeComplex; var makeComplex = plt.baselib.numbers.makeComplex;
var makeVector = types.vector; var makeVector = plt.baselib.vectors.makeVector;
var makeList = types.list; var makeList = plt.baselib.lists.makeList;
var makePair = types.pair; var makePair = plt.baselib.lists.makePair;
var heir = plt.baselib.heir; var heir = plt.baselib.heir;
var toDomNode = plt.baselib.format.toDomNode; var toDomNode = plt.baselib.format.toDomNode;
@ -2633,7 +2631,4 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
exports['StructType'] = plt.baselib.structs.StructType; exports['StructType'] = plt.baselib.structs.StructType;
scope.link.announceReady('runtime');
})(this['plt']); })(this['plt']);

View File

@ -1,4 +1,4 @@
#lang s-exp "../../lang/base.rkt" #lang planet dyoo/whalesong
(begin (begin
(define make-parser (define make-parser
(lambda (grammar lexer) (lambda (grammar lexer)