continuing to add primitives
This commit is contained in:
parent
1a9824b1d0
commit
c066bdf568
|
@ -27,6 +27,8 @@
|
||||||
var isString = baselib.strings.isString;
|
var isString = baselib.strings.isString;
|
||||||
var isSymbol = baselib.symbols.isSymbol;
|
var isSymbol = baselib.symbols.isSymbol;
|
||||||
var isBox = baselib.boxes.isBox;
|
var isBox = baselib.boxes.isBox;
|
||||||
|
var isStruct = baselib.structs.isStruct;
|
||||||
|
var isStructType = baselib.structs.isStructType;
|
||||||
var equals = baselib.equality.equals;
|
var equals = baselib.equality.equals;
|
||||||
|
|
||||||
var NULL = baselib.lists.EMPTY;
|
var NULL = baselib.lists.EMPTY;
|
||||||
|
@ -79,11 +81,11 @@
|
||||||
var checkInteger = baselib.check.checkInteger;
|
var checkInteger = baselib.check.checkInteger;
|
||||||
var checkIntegerForChar = baselib.check.makeCheckArgumentType(
|
var checkIntegerForChar = baselib.check.makeCheckArgumentType(
|
||||||
function(x) {
|
function(x) {
|
||||||
return (baselib.numbers.isInteger(x) &&
|
return (baselib.numbers.isInteger(x) &&
|
||||||
((baselib.numbers.lessThanOrEqual(0, x) &&
|
((baselib.numbers.lessThanOrEqual(0, x) &&
|
||||||
baselib.numbers.lessThanOrEqual(x, 55295))
|
baselib.numbers.lessThanOrEqual(x, 55295))
|
||||||
||
|
||
|
||||||
(baselib.numbers.lessThanOrEqual(57344, x) &&
|
(baselib.numbers.lessThanOrEqual(57344, x) &&
|
||||||
baselib.numbers.lessThanOrEqual(x, 1114111))));
|
baselib.numbers.lessThanOrEqual(x, 1114111))));
|
||||||
},
|
},
|
||||||
'integer'
|
'integer'
|
||||||
|
@ -927,22 +929,6 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
installPrimitiveProcedure(
|
installPrimitiveProcedure(
|
||||||
'string-ci=?',
|
'string-ci=?',
|
||||||
baselib.arity.makeArityAtLeast(1),
|
baselib.arity.makeArityAtLeast(1),
|
||||||
|
@ -1015,9 +1001,6 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
installPrimitiveProcedure(
|
installPrimitiveProcedure(
|
||||||
'string-append',
|
'string-append',
|
||||||
baselib.arity.makeArityAtLeast(0),
|
baselib.arity.makeArityAtLeast(0),
|
||||||
|
@ -1102,19 +1085,99 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
installPrimitiveProcedure(
|
var makeCharComparator = function(name, cmp) {
|
||||||
'char=?',
|
return function(M) {
|
||||||
baselib.arity.makeArityAtLeast(2),
|
var s = checkChar(M, name, 0).val;
|
||||||
function(M) {
|
|
||||||
var s = checkChar(M, 'char=?', 0).val;
|
|
||||||
var i;
|
var i;
|
||||||
for (i = 1; i < M.a; i++) {
|
for (i = 1; i < M.a; i++) {
|
||||||
if (checkChar(M, 'char=?', i).val !== s) {
|
if (!(cmp(s, checkChar(M, name, i).val))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
installPrimitiveProcedure(
|
||||||
|
'char>?',
|
||||||
|
baselib.arity.makeArityAtLeast(2),
|
||||||
|
makeCharComparator('char>?',
|
||||||
|
function(x, y) {
|
||||||
|
return x > y;
|
||||||
|
}));
|
||||||
|
|
||||||
|
installPrimitiveProcedure(
|
||||||
|
'char>=?',
|
||||||
|
baselib.arity.makeArityAtLeast(2),
|
||||||
|
makeCharComparator('char>=?',
|
||||||
|
function(x, y) {
|
||||||
|
return x >= y;
|
||||||
|
}));
|
||||||
|
|
||||||
|
installPrimitiveProcedure(
|
||||||
|
'char<?',
|
||||||
|
baselib.arity.makeArityAtLeast(2),
|
||||||
|
makeCharComparator('char<?',
|
||||||
|
function(x, y) {
|
||||||
|
return x < y;
|
||||||
|
}));
|
||||||
|
|
||||||
|
installPrimitiveProcedure(
|
||||||
|
'char<=?',
|
||||||
|
baselib.arity.makeArityAtLeast(2),
|
||||||
|
makeCharComparator('char<=?',
|
||||||
|
function(x, y) {
|
||||||
|
return x <= y;
|
||||||
|
}));
|
||||||
|
|
||||||
|
installPrimitiveProcedure(
|
||||||
|
'char=?',
|
||||||
|
baselib.arity.makeArityAtLeast(2),
|
||||||
|
makeCharComparator('char=?',
|
||||||
|
function(x, y) {
|
||||||
|
return x === y;
|
||||||
|
}));
|
||||||
|
|
||||||
|
installPrimitiveProcedure(
|
||||||
|
'char-ci>?',
|
||||||
|
baselib.arity.makeArityAtLeast(2),
|
||||||
|
makeCharComparator('char-ci>?',
|
||||||
|
function(x, y) {
|
||||||
|
return x.toUpperCase() > y.toUpperCase();
|
||||||
|
}));
|
||||||
|
|
||||||
|
installPrimitiveProcedure(
|
||||||
|
'char-ci>=?',
|
||||||
|
baselib.arity.makeArityAtLeast(2),
|
||||||
|
makeCharComparator('char-ci>=?',
|
||||||
|
function(x, y) {
|
||||||
|
return x.toUpperCase() >= y.toUpperCase();
|
||||||
|
}));
|
||||||
|
|
||||||
|
installPrimitiveProcedure(
|
||||||
|
'char-ci<?',
|
||||||
|
baselib.arity.makeArityAtLeast(2),
|
||||||
|
makeCharComparator('char-ci<?',
|
||||||
|
function(x, y) {
|
||||||
|
return x.toUpperCase() < y.toUpperCase();
|
||||||
|
}));
|
||||||
|
|
||||||
|
installPrimitiveProcedure(
|
||||||
|
'char-ci<=?',
|
||||||
|
baselib.arity.makeArityAtLeast(2),
|
||||||
|
makeCharComparator('char-ci<=?',
|
||||||
|
function(x, y) {
|
||||||
|
return x.toUpperCase() <= y.toUpperCase();
|
||||||
|
}));
|
||||||
|
|
||||||
|
installPrimitiveProcedure(
|
||||||
|
'char-ci=?',
|
||||||
|
baselib.arity.makeArityAtLeast(2),
|
||||||
|
makeCharComparator('char-ci=?',
|
||||||
|
function(x, y) {
|
||||||
|
return x.toUpperCase() === y.toUpperCase();
|
||||||
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
installPrimitiveProcedure(
|
installPrimitiveProcedure(
|
||||||
|
@ -1125,7 +1188,6 @@
|
||||||
return baselib.chars.makeChar(String.fromCharCode(ch));
|
return baselib.chars.makeChar(String.fromCharCode(ch));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
installPrimitiveProcedure(
|
installPrimitiveProcedure(
|
||||||
'char-upcase',
|
'char-upcase',
|
||||||
1,
|
1,
|
||||||
|
@ -1855,9 +1917,9 @@
|
||||||
vs.push(baselib.format.format("~e", [M.e[M.e.length - 1 - i]]));
|
vs.push(baselib.format.format("~e", [M.e[M.e.length - 1 - i]]));
|
||||||
}
|
}
|
||||||
raise(M, baselib.exceptions.makeExnFail(M.e[M.e.length - 1].toString() +
|
raise(M, baselib.exceptions.makeExnFail(M.e[M.e.length - 1].toString() +
|
||||||
": " +
|
": " +
|
||||||
vs.join(' '),
|
vs.join(' '),
|
||||||
M.captureContinuationMarks()));
|
M.captureContinuationMarks()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isSymbol(M.e[M.e.length - 1])) {
|
if (isSymbol(M.e[M.e.length - 1])) {
|
||||||
|
@ -2017,7 +2079,6 @@
|
||||||
return contMarks;
|
return contMarks;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
installPrimitiveClosure(
|
installPrimitiveClosure(
|
||||||
'make-struct-type',
|
'make-struct-type',
|
||||||
makeList(4, 5, 6, 7, 8, 9, 10, 11),
|
makeList(4, 5, 6, 7, 8, 9, 10, 11),
|
||||||
|
@ -2113,6 +2174,19 @@
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
installPrimitiveClosure(
|
||||||
|
'struct?',
|
||||||
|
1,
|
||||||
|
function(M) {
|
||||||
|
return isStruct(M.e[M.e.length - 1]);
|
||||||
|
});
|
||||||
|
|
||||||
|
installPrimitiveClosure(
|
||||||
|
'struct-type?',
|
||||||
|
1,
|
||||||
|
function(M) {
|
||||||
|
return isStructType(M.e[M.e.length - 1]);
|
||||||
|
});
|
||||||
|
|
||||||
installPrimitiveProcedure(
|
installPrimitiveProcedure(
|
||||||
'current-inspector',
|
'current-inspector',
|
||||||
|
@ -2217,7 +2291,7 @@
|
||||||
|
|
||||||
installPrimitiveProcedure(
|
installPrimitiveProcedure(
|
||||||
'srcloc',
|
'srcloc',
|
||||||
5,
|
5,
|
||||||
function(M) {
|
function(M) {
|
||||||
var source = M.e[M.e.length - 1];
|
var source = M.e[M.e.length - 1];
|
||||||
var line = checkNatural(M, 'srcloc', 1);
|
var line = checkNatural(M, 'srcloc', 1);
|
||||||
|
@ -2313,12 +2387,6 @@
|
||||||
return baselib.contmarks.DEFAULT_CONTINUATION_PROMPT_TAG;
|
return baselib.contmarks.DEFAULT_CONTINUATION_PROMPT_TAG;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
exports['Primitives'] = Primitives;
|
exports['Primitives'] = Primitives;
|
||||||
exports['installPrimitiveProcedure'] = installPrimitiveProcedure;
|
exports['installPrimitiveProcedure'] = installPrimitiveProcedure;
|
||||||
exports['installPrimitiveClosure'] = installPrimitiveClosure;
|
exports['installPrimitiveClosure'] = installPrimitiveClosure;
|
||||||
|
|
|
@ -185,7 +185,13 @@
|
||||||
srcloc-line
|
srcloc-line
|
||||||
srcloc-column
|
srcloc-column
|
||||||
srcloc-position
|
srcloc-position
|
||||||
srcloc-span)
|
srcloc-span
|
||||||
|
|
||||||
|
|
||||||
|
make-struct-type
|
||||||
|
make-struct-field-accessor
|
||||||
|
make-struct-field-mutator
|
||||||
|
struct-type?)
|
||||||
|
|
||||||
|
|
||||||
(define (-identity x) x)
|
(define (-identity x) x)
|
||||||
|
@ -217,10 +223,6 @@
|
||||||
;; continuation-mark-set?
|
;; continuation-mark-set?
|
||||||
;; continuation-mark-set->list
|
;; continuation-mark-set->list
|
||||||
|
|
||||||
;; make-struct-type
|
|
||||||
;; make-struct-field-accessor
|
|
||||||
;; make-struct-field-mutator
|
|
||||||
;; struct-type?
|
|
||||||
;; struct-constructor-procedure?
|
;; struct-constructor-procedure?
|
||||||
;; struct-predicate-procedure?
|
;; struct-predicate-procedure?
|
||||||
;; struct-accessor-procedure?
|
;; struct-accessor-procedure?
|
||||||
|
@ -313,7 +315,7 @@ string?
|
||||||
char?
|
char?
|
||||||
boolean?
|
boolean?
|
||||||
vector?
|
vector?
|
||||||
;; struct?
|
struct?
|
||||||
;; eof-object?
|
;; eof-object?
|
||||||
;; bytes?
|
;; bytes?
|
||||||
;; byte?
|
;; byte?
|
||||||
|
@ -435,16 +437,16 @@ symbol->string
|
||||||
vector->list
|
vector->list
|
||||||
list->vector
|
list->vector
|
||||||
;; build-vector
|
;; build-vector
|
||||||
char=?
|
char=?
|
||||||
;; char<?
|
char<?
|
||||||
;; char>?
|
char>?
|
||||||
;; char<=?
|
char<=?
|
||||||
;; char>=?
|
char>=?
|
||||||
;; char-ci=?
|
char-ci=?
|
||||||
;; char-ci<?
|
char-ci<?
|
||||||
;; char-ci>?
|
char-ci>?
|
||||||
;; char-ci<=?
|
char-ci<=?
|
||||||
;; char-ci>=?
|
char-ci>=?
|
||||||
;; char-alphabetic?
|
;; char-alphabetic?
|
||||||
;; char-numeric?
|
;; char-numeric?
|
||||||
;; char-whitespace?
|
;; char-whitespace?
|
||||||
|
|
Loading…
Reference in New Issue
Block a user