├── TODO.txt ├── antlr ├── CommonTokenTypes.txt ├── CountingCharBuffer.java ├── CountingLexerSharedInputState.java ├── ExtAST.java ├── ExtToken.java ├── TODO-antlr.txt ├── antlrTest.emaker ├── clean.sh ├── e.g ├── elex.g └── quasi.g ├── clean ├── clrune ├── doc └── reference.html ├── e-core └── knot.eexpr ├── e-on-cl.asd ├── iclrune ├── jlib └── parseEToSExpression.emaker ├── lib ├── java │ ├── io │ │ ├── makeByteArrayInputStream.emaker │ │ ├── makeByteArrayOutputStream.emaker │ │ ├── makeDataInputStream.emaker │ │ ├── makeDataOutputStream.emaker │ │ └── type │ │ │ ├── BufferedReader.emaker │ │ │ ├── DataInput.emaker │ │ │ ├── DataOutput.emaker │ │ │ ├── FileNotFoundException.emaker │ │ │ └── IOException.emaker │ └── lang │ │ ├── makeByte.emaker │ │ ├── makeThrowable.emaker │ │ └── type │ │ ├── Byte.emaker │ │ ├── Exception.emaker │ │ ├── Runnable.emaker │ │ ├── StringBuffer.emaker │ │ └── Throwable.emaker ├── net │ ├── captp │ │ ├── comm │ │ │ ├── makeCapTPConnection.emaker │ │ │ ├── makeCapTPSerializer.emaker │ │ │ ├── makeCapTPUnserializer.emaker │ │ │ ├── makeHub.emaker │ │ │ ├── makeIntroducer.emaker │ │ │ ├── makeLocatorUnum.emaker │ │ │ └── makeNonceLocator.emaker │ │ ├── protocol │ │ │ ├── VatID.emaker │ │ │ ├── messageDescs.emaker │ │ │ └── paramTypes.emaker │ │ ├── tables │ │ │ ├── makeAnswersTable.emaker │ │ │ ├── makeCommTable.emaker │ │ │ ├── makeExportsTable.emaker │ │ │ ├── makeNearGiftTable.emaker │ │ │ ├── makePromiseGiftTable.emaker │ │ │ ├── makeProxiesTable.emaker │ │ │ ├── makeSwissTable.emaker │ │ │ └── makeVine.emaker │ │ └── util │ │ │ ├── asWaterkenBase32.emaker │ │ │ └── traceMessages.emaker │ └── vattp │ │ └── messageJoining.emaker └── org │ ├── apache │ └── oro │ │ └── text │ │ └── regex │ │ └── makePatternMatcherInput.emaker │ ├── cubik │ └── cle │ │ ├── binary │ │ ├── character32Coding.emaker │ │ ├── dataEBuildCoding.emaker │ │ ├── float64Coding.emaker │ │ ├── signedIntegerCoding.emaker │ │ ├── unsignedIntegerCoding.emaker │ │ ├── utf8StringWithLength16Coding.emaker │ │ └── wholeNumCoding.emaker │ │ ├── charenc │ │ ├── README.txt │ │ ├── US-ASCII.emaker │ │ └── UTF-8.emaker │ │ ├── charsets.emaker │ │ ├── convertQuasiInput.emaker │ │ ├── dumpENodes.emaker │ │ ├── fail │ │ ├── defineException.emaker │ │ ├── defineExceptionGuard.emaker │ │ ├── makeCoercionFailure.emaker │ │ └── makeStringException.emaker │ │ ├── file │ │ ├── File.emaker │ │ └── makeReadOnlyFile.emaker │ │ ├── io │ │ ├── join.emaker │ │ ├── makeAppendStream.emaker │ │ ├── makeFDInStreamAuthor.emaker │ │ ├── makeSimplePipe.emaker │ │ ├── makeSubOutStream.emaker │ │ ├── makeWriterStream.emaker │ │ ├── mapStream.emaker │ │ ├── splitIn.emaker │ │ ├── transformIn.emaker │ │ ├── transformOut.emaker │ │ └── trickleIn.emaker │ │ ├── makeAdvisoryInterface.emaker │ │ ├── makeDefaultPropertySlot.emaker │ │ ├── makeDelayingRef.emaker │ │ ├── makeIOScope.emaker │ │ ├── makePseudoFarRef.emaker │ │ ├── makeSharedRefLink.emaker │ │ ├── memoize.emaker │ │ ├── memoizeAuthor.emaker │ │ ├── parser │ │ ├── lalr1__quasiParser.emaker │ │ └── makeLALR1ParserAuthor.emaker │ │ ├── prim │ │ └── anyGuardSugar.emaker │ │ ├── root.emaker │ │ ├── schedule │ │ ├── Schedule.emaker │ │ ├── eventual.emaker │ │ └── now.emaker │ │ ├── simpleRuneAuthor.emaker │ │ ├── sugarRoot.emaker │ │ ├── test │ │ ├── emakerEnvGuards.emaker │ │ ├── importUncall │ │ │ ├── askedEarly.emaker │ │ │ ├── notRequested.emaker │ │ │ ├── notUnique.emaker │ │ │ ├── ok.emaker │ │ │ └── selfless.emaker │ │ └── testSugar.emaker │ │ └── wrapRandomState.emaker │ ├── erights │ └── e │ │ ├── develop │ │ └── exception │ │ │ └── makePrintStreamWriterAuthor.emaker │ │ ├── elang │ │ ├── cmd │ │ │ └── controlLoopMaker.emaker │ │ ├── coord │ │ │ ├── OrderedRegionMaker.emaker │ │ │ └── OrderedSpaceMaker.emaker │ │ ├── evm │ │ │ ├── StaticWalkEnvironment.emaker │ │ │ ├── makeSimpleNounExpr.emaker │ │ │ └── makeStaticScope.emaker │ │ ├── expand │ │ │ ├── __makeVerbFacet.emaker │ │ │ ├── __splitList.emaker │ │ │ ├── __switchFailed.emaker │ │ │ ├── booleanFlow.emaker │ │ │ ├── comparer.emaker │ │ │ ├── makeViaBinder.emaker │ │ │ ├── makeViaExtractor.emaker │ │ │ ├── makeViaQuasi.emaker │ │ │ ├── makeViaSame.emaker │ │ │ ├── slotToBinding.emaker │ │ │ ├── suchThat.emaker │ │ │ └── viaEmptyMap.emaker │ │ ├── interp │ │ │ ├── ControlLoop.emaker │ │ │ ├── help.emaker │ │ │ ├── makePackageLoader.emaker │ │ │ ├── makePerlMatchMaker.emaker │ │ │ ├── makeProtocolDesc.emaker │ │ │ ├── notNull.emaker │ │ │ ├── require.emaker │ │ │ ├── type │ │ │ │ └── ControlLoop.emaker │ │ │ ├── typeLoader.emaker │ │ │ └── vow.emaker │ │ ├── scope │ │ │ ├── makeScope.emaker │ │ │ └── scopeSugar.emaker │ │ ├── syntax │ │ │ ├── ePrinter.emaker │ │ │ ├── epatt__quasiParser.emaker │ │ │ ├── makeELexer.emaker │ │ │ ├── makeEParser.emaker │ │ │ └── makePrettyFeeder.emaker │ │ └── visitors │ │ │ ├── makeENodeCopyVisitor.emaker │ │ │ ├── makeKernelECopyVisitor.emaker │ │ │ └── makeQuasiSubstituteVisitor.emaker │ │ └── elib │ │ ├── base │ │ ├── makeMessageDesc.emaker │ │ ├── makeParamDesc.emaker │ │ ├── makeTypeDesc.emaker │ │ └── makeValueThunk.emaker │ │ ├── eio │ │ ├── EIO.emaker │ │ ├── InStream.emaker │ │ ├── OutStream.emaker │ │ └── Stream.emaker │ │ ├── oldeio │ │ ├── makeTextWriter.emaker │ │ └── makeUnQuote.emaker │ │ ├── ref │ │ ├── RefAuthor.emaker │ │ ├── makeDelayedRedirector.emaker │ │ ├── makeProxy.emaker │ │ └── makeRedirector.emaker │ │ ├── sealing │ │ ├── makeBrand.emaker │ │ └── makeBrandAuthor.emaker │ │ ├── serial │ │ ├── DEBuilderOf.emaker │ │ ├── Data.emaker │ │ ├── DeepFrozenAuthor.emaker │ │ ├── PassByCopy.emaker │ │ ├── PassByProxy.emaker │ │ ├── deASTKit.emaker │ │ ├── deBytecodeKit.emaker │ │ ├── deENodeKit.emaker │ │ ├── deSrcKit.emaker │ │ ├── deSubgraphKit.emaker │ │ ├── makeRemoteCall.emaker │ │ ├── makeUncaller.emaker │ │ └── type │ │ │ └── Uncaller.emaker │ │ ├── slot │ │ ├── List.emaker │ │ ├── Map.emaker │ │ ├── Same.emaker │ │ ├── SameAuthor.emaker │ │ ├── Slot.emaker │ │ ├── SubrangeGuardAuthor.emaker │ │ ├── Tuple.emaker │ │ ├── finalSlotGuardSugar.emaker │ │ ├── finalSlotGuardSugarAuthor.emaker │ │ ├── makeBaseGuard.emaker │ │ ├── makeBaseGuardAuthor.emaker │ │ ├── makeCoercedSlot.emaker │ │ ├── makeFinalSlot.emaker │ │ ├── makeGuardedSlot.emaker │ │ ├── makeIntersectionGuard.emaker │ │ ├── makeLazySlot.emaker │ │ ├── makeNegatedGuard.emaker │ │ ├── makeUnionGuard.emaker │ │ ├── makeVarSlot.emaker │ │ ├── nullOk.emaker │ │ └── type │ │ │ ├── Guard.emaker │ │ │ ├── Slot.emaker │ │ │ └── ValueGuard.emaker │ │ ├── tables │ │ ├── listSugar.emaker │ │ ├── makeConstList.emaker │ │ ├── makeConstMap.emaker │ │ ├── makeConstSetAuthor.emaker │ │ ├── makeCycleBreaker.emaker │ │ ├── makeFlexList.emaker │ │ ├── makeFlexListShell.emaker │ │ ├── makeFlexMap.emaker │ │ ├── makeFlexMapShell.emaker │ │ ├── makeFlexSet.emaker │ │ ├── makeTraversalKey.emaker │ │ ├── mapSugar.emaker │ │ ├── setSugar.emaker │ │ └── type │ │ │ ├── ConstList.emaker │ │ │ └── TraversalKey.emaker │ │ ├── util │ │ └── OneArgFunc.emaker │ │ └── vat │ │ ├── makeQueue.emaker │ │ └── makeVatAuthor.emaker │ └── quasiliteral │ ├── astro │ ├── makeAstroTagAuthor.emaker │ └── makeBaseAstroBuilder.emaker │ ├── base │ └── type │ │ ├── MatchMaker.emaker │ │ ├── QuasiExprParser.emaker │ │ ├── QuasiPatternParser.emaker │ │ └── ValueMaker.emaker │ ├── quasiterm │ └── makeQBuilder.emaker │ ├── syntax │ ├── makeFileFeeder.emaker │ ├── makeLineFeeder.emaker │ ├── makeTwineFeeder.emaker │ └── makeURIKit.emaker │ ├── term │ ├── makeTermAuthor.emaker │ ├── makeTermBuilder.emaker │ ├── makeTermLexer.emaker │ └── makeTermParser.emaker │ └── text │ ├── makeFirstCharSplitter.emaker │ └── simple__quasiParser.emaker ├── lisp ├── antlr-system.lisp ├── base.lisp ├── bordeaux-threads-patch.lisp ├── comm.lisp ├── compile-options.lisp ├── compiler-base.lisp ├── compiler-entry.lisp ├── compiler-seq.lisp ├── e-lambda.lisp ├── elang-nodes.lisp ├── elib-guts.lisp ├── elib-values.lisp ├── elib.lisp ├── environment.lisp ├── event-log.lisp ├── extern.lisp ├── final-init.lisp ├── float.lisp ├── guard.lisp ├── irc-repl.lisp ├── jar.lisp ├── knot-base.lisp ├── knot.lisp ├── lazy.lisp ├── lisp-test.lisp ├── miranda.lisp ├── nonkernel.lisp ├── packages.lisp ├── print.lisp ├── proxy.lisp ├── queues.lisp ├── random.lisp ├── ref.lisp ├── rune.lisp ├── runner-late.lisp ├── runner.lisp ├── same.lisp ├── serve-event.lisp ├── slots.lisp ├── smethod.lisp ├── sockets.lisp ├── sockets2.lisp ├── sugar.lisp ├── syntax.lisp ├── tables2.lisp ├── type-desc-early.lisp ├── universal.lisp ├── updoc.lisp ├── util-guts.lisp ├── util.lisp └── vat.lisp ├── ltests ├── boolean.tlisp ├── compiler-seq.tlisp ├── elib.tlisp ├── eq.tlisp ├── fqn.tlisp ├── knot.tlisp ├── node.tlisp ├── queues.tlisp ├── sugar-delegate.tlisp ├── sugar.tlisp ├── thread.tlisp ├── turn.tlisp ├── types.tlisp └── util.tlisp ├── tests ├── brand.updoc ├── captp │ ├── AnswersTable.updoc │ ├── SwissTable.updoc │ ├── base32.updoc │ ├── connection-pair.updoc │ ├── connection.updoc │ ├── hub.updoc │ ├── hubs-and-connections.updoc │ ├── introducer.updoc │ ├── other-objects.updoc │ ├── serialization.updoc │ └── tracer.updoc ├── character.updoc ├── data.updoc ├── deep-frozen.updoc ├── eio.updoc ├── encoding.updoc ├── exception-data.updoc ├── exception-native.updoc ├── exceptions.updoc ├── extend.updoc ├── file.updoc ├── guard-matching.updoc ├── guard-subrange.updoc ├── guards.updoc ├── help.updoc ├── imports.updoc ├── lang │ ├── ENodeCopyVisitor.updoc │ ├── audit-cache.updoc │ ├── audit.updoc │ ├── enode.updoc │ ├── kernel.updoc │ ├── syntax-in.updoc │ ├── syntax-sugar.updoc │ ├── syntax.updoc │ └── vm.updoc ├── lazy-slot.updoc ├── literals.updoc ├── memoize.updoc ├── miranda.updoc ├── mod.updoc ├── native-quirks.updoc ├── native.updoc ├── number-bits.updoc ├── numbers.updoc ├── overflow.updoc ├── parser.updoc ├── pass-by-construction.updoc ├── print.updoc ├── priority-queue.updoc ├── process.updoc ├── properties.updoc ├── protocol-desc.updoc ├── proxy-delaying.updoc ├── proxy-pseudofar.updoc ├── proxy.updoc ├── random.updoc ├── ref.updoc ├── region.updoc ├── rx.updoc ├── same.updoc ├── scope-privileged.updoc ├── scope-safe.updoc ├── scope-univ.updoc ├── scopes.updoc ├── send.updoc ├── serial.updoc ├── slots.updoc ├── socket.updoc ├── stream │ ├── append.updoc │ ├── asNear.updoc │ ├── binary.updoc │ ├── ext-pipe.updoc │ ├── join.updoc │ ├── map.updoc │ ├── pipe.updoc │ ├── splitIn.updoc │ ├── subOut.updoc │ ├── transform-in.updoc │ ├── transform-out.updoc │ ├── trickle.updoc │ ├── types.updoc │ ├── util.updoc │ └── writer.updoc ├── symbol.updoc ├── table-const-list.updoc ├── table-const-map.updoc ├── table-const-set.updoc ├── table-flex-list.updoc ├── table-flex-map.updoc ├── table-flex-set.updoc ├── table-lists.updoc ├── table-streams.updoc ├── term.updoc ├── term │ ├── base.updoc │ ├── lexer.updoc │ ├── parse.updoc │ ├── qbuilder.updoc │ └── termbuilder.updoc ├── timer.updoc ├── twine.updoc ├── unicode.updoc ├── updoc.updoc ├── valueThunk.updoc ├── vat │ ├── comm-implementation.updoc │ ├── comm.updoc │ └── sharing.updoc ├── vattp │ └── messages.updoc └── weak.updoc └── toptests ├── dead.updoc ├── fail.updoc ├── hello.e └── stdin.updoc /antlr/CommonTokenTypes.txt: -------------------------------------------------------------------------------- 1 | Common // output token vocab name 2 | QUASIOPEN=4 3 | QUASICLOSE=5 4 | QUASIBODY=6 5 | QuasiContent=7 6 | RCURLY="}"=8 7 | DOLLAR_IDENT=9 8 | AT_IDENT=10 9 | DOLLAR_CURLY=11 10 | AT_CURLY=12 11 | DOLLAR_IGNORE=13 12 | AT_IGNORE=14 13 | DOLLARESC=15 14 | SOURCE_VALUE_HOLE=16 15 | SOURCE_PATTERN_HOLE=17 16 | ERROR_QUASI_KEYWORD=18 17 | 18 | // XXX why do these numbers start at 4? 19 | -------------------------------------------------------------------------------- /antlr/CountingCharBuffer.java: -------------------------------------------------------------------------------- 1 | // Copyright 2006-2007 Kevin Reid, under the terms of the MIT X license 2 | // found at http://www.opensource.org/licenses/mit-license.html ............... 3 | 4 | import java.io.Reader; 5 | import antlr.CharBuffer; 6 | 7 | /** Keeps track of the current character position from the beginning of the input. */ 8 | class CountingCharBuffer extends CharBuffer { 9 | private int position = 0; 10 | 11 | public CountingCharBuffer(Reader input, int initPosition) { 12 | super(input); 13 | position = initPosition; 14 | } 15 | 16 | public int getPosition() { return position; } 17 | 18 | public void consume() { 19 | super.consume(); 20 | position++; 21 | } 22 | 23 | public void rewind(int mark) { 24 | syncConsume(); 25 | // int markerOffset = mark(); rewind(markerOffset); <- this should work if we need to stop accessing the markerOffset field 26 | position -= markerOffset - mark; 27 | super.rewind(mark); 28 | } 29 | 30 | public void reset() { 31 | position = 0; // XXX is this correct? should it reset to initPosition instead? 32 | } 33 | } -------------------------------------------------------------------------------- /antlr/CountingLexerSharedInputState.java: -------------------------------------------------------------------------------- 1 | // Copyright 2006-2007 Kevin Reid, under the terms of the MIT X license 2 | // found at http://www.opensource.org/licenses/mit-license.html ............... 3 | 4 | import java.io.InputStream; 5 | import java.io.Reader; 6 | import antlr.LexerSharedInputState; 7 | import antlr.InputBuffer; 8 | 9 | public class CountingLexerSharedInputState extends LexerSharedInputState { 10 | public CountingLexerSharedInputState(InputBuffer inbuf) { 11 | super((CountingCharBuffer)inbuf); 12 | } 13 | 14 | public CountingLexerSharedInputState(Reader in, int position) { 15 | this(new CountingCharBuffer(in, 0)); 16 | } 17 | 18 | public int getPosition() { return ((CountingCharBuffer)input).getPosition(); } 19 | } 20 | -------------------------------------------------------------------------------- /antlr/ExtAST.java: -------------------------------------------------------------------------------- 1 | // Copyright 2006-2007 Kevin Reid, under the terms of the MIT X license 2 | // found at http://www.opensource.org/licenses/mit-license.html ............... 3 | 4 | import antlr.CommonAST; 5 | import antlr.collections.AST; 6 | import antlr.Token; 7 | 8 | /** Keeps source position information. It seems strange that ANTLR does not do this automatically. */ 9 | public class ExtAST extends CommonAST { 10 | private int line = -1; 11 | private int column = -1; 12 | 13 | public ExtAST() { super(); } 14 | public ExtAST(Token token) { super(token); } 15 | 16 | public void initialize(Token token) { 17 | super.initialize(token); 18 | line = token.getLine(); 19 | column = token.getColumn(); 20 | } 21 | 22 | public int getLine() { 23 | if (line != -1) { 24 | return line; 25 | } else { 26 | AST c = getFirstChild(); 27 | if (c != null) { 28 | return c.getLine(); 29 | } else { 30 | return 0; 31 | } 32 | } 33 | } 34 | public int getColumn() { 35 | if (column != -1) { 36 | return column; 37 | } else { 38 | AST c = getFirstChild(); 39 | if (c != null) { 40 | return c.getColumn(); 41 | } else { 42 | return 0; 43 | } 44 | } 45 | } 46 | } -------------------------------------------------------------------------------- /antlr/ExtToken.java: -------------------------------------------------------------------------------- 1 | // Copyright 2007 Kevin Reid, under the terms of the MIT X license 2 | // found at http://www.opensource.org/licenses/mit-license.html ............... 3 | 4 | import antlr.CommonToken; 5 | 6 | /** Modified print behavior over CommonToken; in particular, does not print the numeric token type, which is not useful information to the user; also knows how to reverse text transformations for particular token types. */ 7 | public class ExtToken extends CommonToken { 8 | 9 | /** this is the constructor invoked by CharScanner */ 10 | public ExtToken() { super(); } 11 | 12 | public String getOriginalText() { 13 | if (type == ETokenTypes.EOF) { 14 | return ""; 15 | } else if (type == ETokenTypes.SOURCE_VALUE_HOLE) { 16 | return "<$-hole #" + getText() + ">"; 17 | } else if (type == ETokenTypes.SOURCE_PATTERN_HOLE) { 18 | return "<@-hole #" + getText() + ">"; 19 | } else if (type == ETokenTypes.DOLLAR_IDENT) { 20 | return "$" + getText(); 21 | } else if (type == ETokenTypes.AT_IDENT) { 22 | return "@" + getText(); 23 | } else if (type == ETokenTypes.DOLLARESC) { 24 | return "$\\" + getText(); // XXX escape 25 | } else if (type == ETokenTypes.CHAR_LITERAL) { 26 | return "'" + getText() + "'"; // XXX escape 27 | } else if (type == ETokenTypes.STRING) { 28 | return "\"" + getText() + "\""; // XXX escape 29 | } else if (type == ETokenTypes.HEX) { 30 | return "0x" + getText(); 31 | } else if (type == ETokenTypes.OCTAL) { 32 | return "0" + getText(); 33 | } else if (type == ETokenTypes.URI) { 34 | return "<" + getText() + ">"; 35 | } else if (type == ETokenTypes.URIGetter) { 36 | return "<" + getText() + ">"; 37 | } else { 38 | return getText(); 39 | } 40 | } 41 | 42 | public String toString() { 43 | return "<\"" + getOriginalText() + "\" @ " + getLine() + ":" + getColumn() + ">"; 44 | } 45 | } -------------------------------------------------------------------------------- /antlr/TODO-antlr.txt: -------------------------------------------------------------------------------- 1 | Parsing bugs: 2 | 3 | Fails to parse: 4 | N-ary infix operators and update forms ("a + (b, c)") -- deprecated? if so, should report a specific error 5 | 6 | Bad parse trees: 7 | "pragma.enable(\"dot-props\"); a <- ::b" 8 | -------------------------------------------------------------------------------- /antlr/antlrTest.emaker: -------------------------------------------------------------------------------- 1 | /** For debugging. Usage: 2 | 3 | $ rlwrap rune -cpa e-on-cl/antlr/ 4 | ? def [pp, c] := (, stdout, println) 5 | ? c(pp("E.code(goes, here)")) 6 | 7 | */ 8 | def setup(, stdout, println) :any { 9 | #def := 10 | def := 11 | def := 12 | def makeEParser := 13 | def makeEALexer := 14 | def makeQuasiLexer := 15 | def makeTokenMultiBuffer := 16 | def makeTokenStreamSelector := 17 | def makeDumpASTVisitor := 18 | 19 | def pp(text) :any { 20 | def fname := "ktest" 21 | def elexer := makeEALexer((text)) 22 | def qlexer := makeQuasiLexer(elexer.getInputState()) 23 | def tb := makeTokenMultiBuffer(["e", "quasi"], [elexer, qlexer]) 24 | elexer.setSelector(tb) 25 | qlexer.setSelector(tb) 26 | elexer.setFilename(fname) 27 | qlexer.setFilename(fname) 28 | 29 | def parser := makeEParser(tb) 30 | parser.setFilename(fname) 31 | 32 | parser.start() 33 | def ast := parser.getAST() 34 | def visitor := makeDumpASTVisitor() 35 | visitor.visit(ast) 36 | if (ast != null) { 37 | println(ast.toStringTree()) 38 | } 39 | return ast 40 | } 41 | 42 | pragma.enable("accumulator") 43 | def tokenSymbols := accum [] for tn in makeEParser.get_tokenNames() { _.with("|" + tn.replaceAll("\\", "\\\\").replaceAll("|", "\\|") + "|") }; null 44 | 45 | def c(var ast) :void { 46 | while (ast != null) { 47 | stdout.print(" ((", tokenSymbols[ast.getType()], " ") 48 | stdout.quote(ast.getText()) 49 | stdout.print(")") 50 | c(ast.getFirstChild()) 51 | stdout.print(")") 52 | ast := ast.getNextSibling() 53 | } 54 | } 55 | return [pp, c] 56 | } -------------------------------------------------------------------------------- /antlr/clean.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Copyright 2006-2007 Kevin Reid, under the terms of the MIT X license 4 | # found at http://www.opensource.org/licenses/mit-license.html ................ 5 | 6 | set -e 7 | 8 | rm -f *.class \ 9 | {E,EALexer,QuasiLexer}TokenTypes.{txt,java} \ 10 | {EALexer,QuasiLexer,EParser}.java 11 | -------------------------------------------------------------------------------- /clean: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Copyright 2006-2007 Kevin Reid, under the terms of the MIT X license 4 | # found at http://www.opensource.org/licenses/mit-license.html ................ 5 | 6 | set -e 7 | 8 | rm -rf compiled-lib/* 9 | rm -f e-image-main e-image-run \ 10 | test-parse-cache-*.sexp \ 11 | {lisp,e-core}/*.{fasl,dfsl,nfasl,fas,lib,cls,x86f,abcl} 12 | 13 | (cd antlr && ./clean.sh) 14 | -------------------------------------------------------------------------------- /doc/reference.html: -------------------------------------------------------------------------------- 1 | 2 | E-on-CL Reference Requirements 3 | 4 | 5 | 6 |

Immutability

7 | 8 |

All of these objects, when used as E-references, must be treated as immutable: 9 | 10 |

    11 |
  • cl:string 12 |
  • cl:cons 13 |
  • cl:array 14 |
15 | 16 |

Symbols may be mutated, even though E-on-CL treats them as immutable atoms, as the mutable components of symbols are not exposed to the E system.

17 | 18 |

Equivalence

19 | 20 |

An e.elib:ref to an object must be treated equivalently to the object itself. This may be accomplished by dereference using ref-shorten, e-coerce, or e-coercef.

21 | 22 |

No distinctions may be made between objects that e.elib:equalizers consider equal.

-------------------------------------------------------------------------------- /lib/java/io/makeByteArrayInputStream.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def makeByteArrayInputStream { 7 | # XXX unimplemented 8 | } 9 | -------------------------------------------------------------------------------- /lib/java/io/makeByteArrayOutputStream.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def makeByteArrayOutputStream { 7 | # XXX unimplemented 8 | } 9 | -------------------------------------------------------------------------------- /lib/java/io/makeDataInputStream.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def makeDataInputStream { 7 | # XXX unimplemented 8 | } 9 | -------------------------------------------------------------------------------- /lib/java/io/makeDataOutputStream.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def makeDataOutputStream { 7 | # XXX unimplemented 8 | } 9 | -------------------------------------------------------------------------------- /lib/java/io/type/BufferedReader.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def BufferedReader { 7 | to coerce(specimen, optEjector) { 8 | throw.eject(optEjector, "no BufferedReaders yet") 9 | } 10 | } -------------------------------------------------------------------------------- /lib/java/io/type/DataInput.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def DataInput { 7 | to coerce(specimen, optEjector) { 8 | throw.eject(optEjector, "no DataInput yet") 9 | } 10 | } -------------------------------------------------------------------------------- /lib/java/io/type/DataOutput.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def DataOutput { 7 | to coerce(specimen, optEjector) { 8 | throw.eject(optEjector, "no DataOutput yet") 9 | } 10 | } -------------------------------------------------------------------------------- /lib/java/io/type/FileNotFoundException.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def FileNotFoundException { 7 | to coerce(specimen, optEjector) { 8 | throw.eject(optEjector, "XXX FileNotFoundException not distinguished") 9 | } 10 | } -------------------------------------------------------------------------------- /lib/java/io/type/IOException.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def IOException { 7 | to coerce(specimen, optEjector) { 8 | throw.eject(optEjector, "IOException not yet available") 9 | } 10 | } -------------------------------------------------------------------------------- /lib/java/lang/makeByte.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def makeByte implements DeepFrozen { 7 | to getTYPE() { 8 | # XXX perhaps we should have deprecation warnings 9 | return 10 | } 11 | } -------------------------------------------------------------------------------- /lib/java/lang/makeThrowable.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | /** Java-E compatibility */ 7 | def makeThrowable { 8 | to asType() { return } 9 | 10 | # XXX methods 11 | } -------------------------------------------------------------------------------- /lib/java/lang/type/Byte.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | # XXX this should be unified with the CL type (SIGNED-BYTE 8) for efficiency 5 | -128..!128 -------------------------------------------------------------------------------- /lib/java/lang/type/Exception.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | # This is Not Wrong because E-on-CL has no non-Exception throwables (since throwables are (currently) CONDITION objects and ejection is implemented by other means). 5 | -------------------------------------------------------------------------------- /lib/java/lang/type/Runnable.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def Runnable { 7 | to coerce(specimen, optEjector) { 8 | if (!specimen.__respondsTo("run", 0)) { 9 | traceln("java.lang.Runnable guard could reject " + E.toQuote(specimen)) 10 | } 11 | return specimen 12 | } 13 | } -------------------------------------------------------------------------------- /lib/java/lang/type/StringBuffer.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def StringBuffer { 7 | to coerce(specimen, optEjector) { 8 | throw.eject(optEjector, "StringBuffer not yet available") 9 | } 10 | } -------------------------------------------------------------------------------- /lib/java/lang/type/Throwable.emaker: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/net/captp/comm/makeCapTPSerializer.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2007 Kevin Reid under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | pragma.enable("accumulator") 6 | 7 | def messageDescs := 8 | def typeEncodings := [] 9 | def [=> OpCode :DeepFrozen] | _ := typeEncodings 10 | 11 | def argTable2 :DeepFrozen := accum [].asMap() for rec in messageDescs[typeEncodings] { 12 | _.with( 13 | def [verb, opCode :(OpCode.asType()), encoders :DeepFrozen] := rec 14 | verb, 15 | def encodeMsg(out, args) implements DeepFrozen { 16 | require(args.size() == encoders.size()) 17 | OpCode.writingTo(out)(opCode) 18 | for i => encoder in encoders { encoder.writingTo(out)(args[i]) } 19 | } 20 | ) 21 | } 22 | 23 | def makeCapTPSerializer(messageStreams) implements ExitViaHere, DeepFrozen { 24 | 25 | return def capTPSerializer { 26 | match [verb, args] { 27 | def encoder := argTable2[verb] 28 | def [s] := messageStreams.takeAtMost(1) 29 | try { 30 | encoder(s, args) 31 | } finally { 32 | s <- reserve() <- resolve(null) 33 | } 34 | null 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /lib/net/captp/comm/makeHub.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2007 Kevin Reid under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def makeBrand :DeepFrozen := 7 | 8 | def makeCapTPHub(makeConnection, outgoingConnect) implements ExitViaHere, DeepFrozen { 9 | def liveConnections := [].asMap().diverge() 10 | 11 | def [for3DescSealer, for3DescUnsealer] := makeBrand("CapTP 3Desc transfer") 12 | def for3DescBrand := for3DescSealer.getBrand() 13 | 14 | def connectAndRegister 15 | 16 | def get(searchPath, vatID) { 17 | return liveConnections.fetch(vatID, fn{ 18 | connectAndRegister(searchPath, vatID) 19 | liveConnections[vatID] }) 20 | } 21 | 22 | def register(searchPath, vatID, remoteRec) { 23 | var live := true 24 | def peerHub { 25 | to get(otherSearchPath, otherVatID) { 26 | return get(otherSearchPath, otherVatID)[1] 27 | } 28 | to nowDead() { 29 | if (live) { 30 | live := false 31 | liveConnections.removeKey(vatID) 32 | } 33 | } 34 | to get3DescBrand() { return for3DescBrand } 35 | to get3DescSealer() { return for3DescSealer } 36 | to amplifyFor3Desc(specimen, recipID) { 37 | if (for3DescUnsealer.amplify(specimen) =~ [wantsRecip]) { 38 | return wantsRecip(recipID) 39 | } 40 | } 41 | to isOurProxy(specimen) { 42 | return for3DescUnsealer.amplify(specimen) =~ [_] 43 | } 44 | } 45 | def [localRec, of, pf] := makeConnection(peerHub, searchPath, vatID, remoteRec) 46 | liveConnections[vatID] := [of, pf] 47 | return localRec 48 | } 49 | 50 | bind connectAndRegister(searchPath, vatID) { 51 | def localRec := register(searchPath, vatID, 52 | outgoingConnect(localRec, searchPath, vatID)) 53 | } 54 | 55 | def hubOutward { 56 | to get(searchPath, vatID) { 57 | return get(searchPath, vatID)[0] 58 | } 59 | to incoming(searchPath, vatID, remoteRec) { 60 | # XXX fail if connection already present 61 | return register(searchPath, vatID, remoteRec) 62 | } 63 | } 64 | return hubOutward 65 | } -------------------------------------------------------------------------------- /lib/net/captp/protocol/VatID.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2007 Kevin Reid under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | # XXX Restrict this, and reference documentation. A VatID seems from inspection to be a 160-bit number represented in Waterken base32 encoding. 5 | # XXX Should the VatID be an object holding the bits, or a number, rather than the string form? 6 | 7 | String -------------------------------------------------------------------------------- /lib/net/captp/protocol/messageDescs.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2007 Kevin Reid under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def messageDescs implements DeepFrozen, ExitViaHere { 7 | to get([=> AnswerPos, 8 | => ExportPos, 9 | => MsgCount, 10 | => MsgName, 11 | => Obj, 12 | => WireDelta, 13 | => IncomingPos] | _) { 14 | return [ 15 | ["DeliverOnly", 8, [IncomingPos, MsgName, Obj]], 16 | ["Deliver", 13, [AnswerPos, Obj, IncomingPos, MsgName, Obj]], 17 | ["GCExport", 10, [ExportPos, WireDelta]], 18 | ["GCAnswer", 11, [AnswerPos]], 19 | ["Shutdown", 12, [MsgCount]], 20 | #["Terminated", _, [Obj]], 21 | #["Wormhole", _, [Data, VatID, VatID]] 22 | ] 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /lib/net/captp/protocol/paramTypes.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2007 Kevin Reid under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def paramTypes implements DeepFrozen, ExitViaHere { 7 | to get([=> signedIntegerCoding, 8 | => utf8StringWithLength16Coding, 9 | => dataEBuildCoding] | _) { 10 | return [ 11 | "OpCode" => signedIntegerCoding[8], 12 | "IncomingPos" => signedIntegerCoding[32], 13 | "AnswerPos" => signedIntegerCoding[32], 14 | "ExportPos" => signedIntegerCoding[32], 15 | "MsgName" => utf8StringWithLength16Coding, 16 | "MsgCount" => signedIntegerCoding[64], 17 | "WireDelta" => signedIntegerCoding[8], 18 | "Obj" => dataEBuildCoding, 19 | ] 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /lib/net/captp/tables/makeAnswersTable.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2002 Combex, Inc. under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ............... 3 | 4 | pragma.syntax("0.9") 5 | 6 | def makeCommTable :DeepFrozen := 7 | def Throwable :DeepFrozen := 8 | 9 | def makeAnswersTable() implements DeepFrozen { 10 | def answersTable extends makeCommTable(answersTable) { 11 | to __printOn(out :TextWriter) { 12 | out.print("") 15 | } 16 | to smash(problem :Throwable) :void { 17 | for i in 1..!(answersTable._getCapacity()) { 18 | if (!answersTable.isFree(i)) { 19 | E.sendOnly(answersTable[i], "__reactToLostClient", [problem]) 20 | } 21 | } 22 | super.smash(problem) 23 | } 24 | } 25 | return answersTable 26 | } -------------------------------------------------------------------------------- /lib/net/captp/tables/makeProxiesTable.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2002 Combex, Inc. under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ............... 3 | 4 | pragma.syntax("0.9") 5 | 6 | def makeCommTable :DeepFrozen := 7 | def EProxyHandler :DeepFrozen := any # XXX specific 8 | def makeProxy :DeepFrozen := 9 | def Throwable :DeepFrozen := 10 | 11 | /** 12 | * 13 | */ 14 | def makeProxiesTable() implements DeepFrozen { 15 | def proxiesTable extends makeCommTable(proxiesTable) { 16 | /** 17 | * 18 | */ 19 | to smash(problem :Throwable) :void { 20 | for i in 1..!(super._getCapacity()) { 21 | if (!proxiesTable.isFree(i)) { 22 | proxiesTable[i].smash(problem) 23 | } 24 | } 25 | super.smash(problem); 26 | } 27 | } 28 | return proxiesTable 29 | } -------------------------------------------------------------------------------- /lib/net/captp/tables/makeVine.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2007 Kevin Reid under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def fakeUnsealToken as DeepFrozen {} 7 | 8 | interface Vine :DeepFrozen guards VineStamp :DeepFrozen { 9 | to run() :void 10 | } 11 | 12 | # XXX document this 13 | def makeVine implements DeepFrozen { 14 | to asType() { return Vine } 15 | to run(target) { 16 | def vine implements VineStamp { 17 | to __optSealedDispatch(brand) { 18 | if (brand == fakeUnsealToken) { return target } 19 | } 20 | to run() {} 21 | } 22 | return vine 23 | } 24 | } -------------------------------------------------------------------------------- /lib/org/apache/oro/text/regex/makePatternMatcherInput.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | /** Java-E compatibility. */ 7 | def makePatternMatcherInput { 8 | to "run(String)"(s) { return s } 9 | } -------------------------------------------------------------------------------- /lib/org/cubik/cle/binary/character32Coding.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2007-2008 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | 7 | def unsignedIntegerCoding :DeepFrozen := 8 | 9 | def u64 :DeepFrozen := unsignedIntegerCoding[64] 10 | 11 | def character32Coding implements DeepFrozen, ExitViaHere { # implements Binary 12 | to asType() { return char } 13 | to writingTo(out) { # , schedule 14 | # XXX consult stream's byte size 15 | return def writer(n :char) { 16 | throw("Unimplemented") 17 | } 18 | } 19 | to takingFrom(ins, schedule) { 20 | # XXX consult stream's byte size 21 | return def taker() :char { 22 | throw("Unimplemented") 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /lib/org/cubik/cle/binary/dataEBuildCoding.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2007-2008 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def deBytecodeKit :DeepFrozen := 7 | def DataEBuild :DeepFrozen := any 8 | 9 | def dataEBuildCoding implements DeepFrozen, ExitViaHere { # implements Binary 10 | to asType() { return DataEBuild } 11 | to writingTo(out) { # , schedule 12 | return def writer(value :DataEBuild) { 13 | var done := false 14 | try { 15 | def subB := deBytecodeKit.makeStreamBuilder(out) 16 | /** limited-duration builder so we don't hand out eternal authority to our stream */ 17 | def dwBuilder { 18 | match msg { 19 | if (done) { 20 | throw(`builder for $value past its dynamic extent`) 21 | } else { 22 | E.callWithPair(subB, msg) 23 | } 24 | } 25 | } 26 | value(dwBuilder) 27 | } finally { 28 | done := true 29 | } 30 | } 31 | } 32 | to takingFrom(ins, schedule) { 33 | return def taker() :DataEBuild { 34 | def storage := deBytecodeKit.recognizeStream(ins, deBytecodeKit.makeBuilder()) 35 | return fn b { deBytecodeKit.recognize(storage, b) } 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /lib/org/cubik/cle/binary/float64Coding.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2007-2008 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | 7 | def unsignedIntegerCoding :DeepFrozen := 8 | 9 | def u64 :DeepFrozen := unsignedIntegerCoding[64] 10 | 11 | def float64Coding implements DeepFrozen, ExitViaHere { # implements Binary 12 | to asType() { return float64 } 13 | to writingTo(out) { # , schedule 14 | # XXX consult stream's byte size 15 | return def writer(n :float64) { 16 | throw("Unimplemented") 17 | } 18 | } 19 | to takingFrom(ins, schedule) { 20 | # XXX consult stream's byte size 21 | return def taker() :float64 { 22 | throw("Unimplemented") 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /lib/org/cubik/cle/binary/signedIntegerCoding.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2007-2008 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def unsignedIntegerCoding :DeepFrozen := 7 | 8 | def signedIntegerCoding implements DeepFrozen, ExitViaHere { 9 | to get(bitCount :(int >= 0)) { 10 | def bitCountD :int := bitCount # XXX interim 11 | def unsignedIntegerSpecificCoding :DeepFrozen := unsignedIntegerCoding[bitCount] 12 | def valueBitCount :int := bitCount - 1 13 | def SignedIntegerSpecific :DeepFrozen := ((-(2**valueBitCount))..!(2**valueBitCount)) 14 | return def signedIntegerSpecificCoding implements DeepFrozen { # implements Binary 15 | to asType() { return SignedIntegerSpecific } 16 | to writingTo(out) { # , schedule 17 | def writeU := unsignedIntegerSpecificCoding.writingTo(out) 18 | return def writer(value :SignedIntegerSpecific) { 19 | writeU(value & (2**bitCountD-1)) 20 | } 21 | } 22 | to takingFrom(ins, schedule) { 23 | def takeU := unsignedIntegerSpecificCoding.takingFrom(ins, schedule) 24 | def signMask := (1 << (bitCountD-1)) 25 | return def taker() :(schedule.result(SignedIntegerSpecific)) { 26 | return schedule.whenResolved(takeU(), fn u { 27 | u - ((u & signMask) << 1) 28 | }) 29 | } 30 | } 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /lib/org/cubik/cle/binary/unsignedIntegerCoding.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2007-2008 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | pragma.enable("one-method-object") 6 | 7 | def dataBits :DeepFrozen := 7 8 | 9 | def unsignedIntegerCoding implements DeepFrozen, ExitViaHere { 10 | to get(bitCount :(int >= 0)) { 11 | def bitCountD :int := bitCount # XXX interim -- DeepFrozen ought to accept (int >= 0) as a subtype 12 | def UnsignedIntegerSpecific :DeepFrozen := (0..!(2**bitCount)) 13 | return def unsignedIntegerSpecificCoding implements DeepFrozen { # implements Binary 14 | to asType() { return UnsignedIntegerSpecific } 15 | to writingTo(out) { # , schedule 16 | def byteCount := bitCountD // 8 17 | def mask := (2**8-1) 18 | # XXX consult stream's byte size 19 | return def writer(n :UnsignedIntegerSpecific) { 20 | out.reserve().resolve(__makeList.fromValuesOf(def wIter.iterate(f) { 21 | var i := bitCountD - 8 22 | while (i >= 0) { 23 | f(null, n >> i & mask) 24 | i -= 8 25 | } 26 | })) 27 | } 28 | } 29 | to takingFrom(ins, schedule) { 30 | def byteCount := bitCountD // 8 31 | # XXX consult stream's byte size 32 | return def taker() :(schedule.result(UnsignedIntegerSpecific)) { 33 | return schedule.whenResolved(EIO.takeRange(byteCount, byteCount, ins), fn bytes { 34 | # XXX this is O(n^2) in the size of the number; we could do better by using an efficient "bignum-from-digit-array" primitive 35 | var acc := 0 36 | for i => byte in bytes { 37 | acc |= byte << (bitCountD - (i+1)*8) 38 | } 39 | acc 40 | }) 41 | } 42 | } 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /lib/org/cubik/cle/binary/utf8StringWithLength16Coding.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2007-2008 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def utf_8 :DeepFrozen := ["UTF-8"] 7 | 8 | def unsignedIntegerCoding :DeepFrozen := 9 | 10 | def shortCoding :DeepFrozen := unsignedIntegerCoding[16] 11 | 12 | def utf8StringWithLength16Coding implements DeepFrozen, ExitViaHere { # implements Binary 13 | to asType() { return String } 14 | to writingTo(out) { # , schedule 15 | # XXX verify stream's byte size 16 | def writeShort := shortCoding.writingTo(out) 17 | return def writer(value :String) { 18 | def data := EIO.takeAll(utf_8.encode(value.asStream(), [].asMap())) 19 | writeShort(data.size()) # may fail 20 | out.reserve().resolve(data) 21 | } 22 | } 23 | to takingFrom(ins, schedule) { 24 | # XXX verify stream's byte size 25 | def readShort := shortCoding.takingFrom(ins, schedule) 26 | return def taker() :(schedule.result(String)) { 27 | return schedule.whenResolved(readShort(), fn size { 28 | # XXX unnecessarily non-streaming; fixable with a "substream of N of the characters from this stream" 29 | schedule.whenResolved(EIO.takeRange(size, size, ins), fn data { 30 | def ta := EIO.takeAll(utf_8.decode(data.asStream(), [].asMap())) 31 | # workaround for bug in takeRange 32 | if (ta == []) { "" } else { ta } 33 | }) 34 | }) 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /lib/org/cubik/cle/binary/wholeNumCoding.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2007-2008 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def dataBits :DeepFrozen := 7 7 | def WholeNum :DeepFrozen := (int >= 0) 8 | 9 | /** http://www.waterken.com/dev/Doc/code/#ExtensionNumber */ 10 | # XXX is this the right name? should we call this ExtensionNumber instead? 11 | def wholeNumCoding implements DeepFrozen, ExitViaHere { # implements Binary 12 | to asType() { return WholeNum } 13 | to writingTo(out) { # , schedule 14 | # XXX consult stream's byte size 15 | return def writeWholeNum(n :WholeNum) { 16 | def count := n.bitLength().ceilDivide(dataBits) 17 | out.reserve().resolve(__makeList.fromValuesOf(def wnIter { 18 | to iterate(f) { 19 | var i := count * dataBits 20 | while ((i -= dataBits).atLeastZero()) { 21 | f(null, ((n >> i) & (2**dataBits-1)) | i.isZero().pick(0, 2**dataBits)) 22 | } 23 | } 24 | })) 25 | } 26 | } 27 | to takingFrom(ins, schedule) { 28 | # XXX consult stream's byte size 29 | return def takeWholeNum() :(schedule.result(WholeNum)) { 30 | # XXX this is O(n^2) in the size of the number; we could do better by buffering the 7-bytes and using an efficient "bignum-from-digit-array" primitive 31 | var acc := 0 32 | return schedule.whenResolved( 33 | schedule.loop(fn { 34 | schedule.whenResolved(EIO.takeRange(1, 1, ins), fn chunk { 35 | def [byte] := chunk 36 | acc := (acc << dataBits) | (byte & (2**dataBits-1)) 37 | (byte & 2**dataBits).aboveZero() # continuation condition 38 | }) 39 | }), 40 | fn _ { acc }) 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /lib/org/cubik/cle/charenc/README.txt: -------------------------------------------------------------------------------- 1 | XXX choices described here to be reviewed. 2 | 3 | The namespace here is a subset of , using the "preferred MIME name" where such exists, as this seems to be the most commonly used namespace for encodings. 4 | 5 | For looking up namespaces using any of their aliases and case-insensitively, use (XXX bad name) -------------------------------------------------------------------------------- /lib/org/cubik/cle/charenc/US-ASCII.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def ASCIIRange :DeepFrozen := 0..!128 7 | 8 | def mapStream :DeepFrozen := 9 | def getCharacter :DeepFrozen := 10 | 11 | def ::"US-ASCII" implements DeepFrozen, ExitViaHere { 12 | to __printOn(tw :TextWriter) { tw.print("") } 13 | to decode(octetStream, ==([].asMap())) { 14 | 15 | return mapStream.chunked(String, octetStream, def asciiChunkDecoder { 16 | to __printOn(tw :TextWriter) { 17 | tw.write("from ASCII") 18 | } 19 | to run(inn) { 20 | def out := [].diverge(char) 21 | out.setSize(inn.size()) 22 | for i => octett in inn { 23 | out[i] := getCharacter(octett :ASCIIRange) 24 | } 25 | return __makeTwine.fromValuesOf(out) 26 | } 27 | }) 28 | } 29 | 30 | to encode(charStream, ==([].asMap())) { 31 | # XXX should be int8 32 | return mapStream.chunked(List[int], charStream, def asciiChunkEncoder { 33 | to __printOn(tw :TextWriter) { 34 | tw.write("to ASCII") 35 | } 36 | to run(inn) { 37 | def out := [].diverge(ASCIIRange) 38 | out.setSize(inn.size()) 39 | for i => ch in inn { 40 | out[i] := ch.getCodepoint() 41 | } 42 | return out.snapshot() 43 | } 44 | }) 45 | } 46 | } -------------------------------------------------------------------------------- /lib/org/cubik/cle/charsets.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def imports :DeepFrozen := 7 | 8 | /** Supplies encoding objects named according to the IANA charset registry. 9 | 10 | http://www.iana.org/assignments/character-sets */ 11 | def charsets implements DeepFrozen, ExitViaHere { 12 | to __printOn(tw :TextWriter) { 13 | tw.write("") 14 | } 15 | to get(name :String) { 16 | return imports[name.toUpperCase()] 17 | } 18 | } -------------------------------------------------------------------------------- /lib/org/cubik/cle/convertQuasiInput.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def makeFirstCharSplitter := 7 | 8 | def quasiSpecialSplitter :DeepFrozen := makeFirstCharSplitter("$@") 9 | 10 | def convertQuasiInput implements DeepFrozen, ExitViaHere { 11 | to inlineHoles_to_holeCharacterIndexes(quasi1Source :Twine) { 12 | var outSource := "" 13 | def outVH := [].diverge() 14 | def outPH := [].diverge() 15 | 16 | var position := 0 17 | while (quasiSpecialSplitter.findInFrom(quasi1Source, position) \ 18 | =~ markerIndex ? markerIndex >= 0) { 19 | outSource += quasi1Source(position, markerIndex) # plain text 20 | def marker := quasi1Source[markerIndex] 21 | switch (quasi1Source[markerIndex + 1]) { 22 | match =='{' { #} 23 | def closeIndex ? markerIndex >= 0 := 24 | quasi1Source.startOf(#{ 25 | "}", markerIndex) 26 | def holeIndex := __makeInt(quasi1Source.run(markerIndex + 2, closeIndex)) 27 | def holeOutPosition := outSource.size() 28 | switch (marker) { 29 | match =='$' { outVH[holeIndex] := holeOutPosition } 30 | match =='@' { outPH[holeIndex] := holeOutPosition } 31 | } 32 | outSource += E.toString(marker) 33 | position := closeIndex + 1 34 | } 35 | match ==marker { 36 | outSource += E.toString(marker) 37 | position := markerIndex + 2 38 | } 39 | } 40 | } 41 | outSource += quasi1Source.run(position) 42 | return [outSource, outVH.snapshot(), outPH.snapshot()] 43 | } 44 | } 45 | 46 | ? convertQuasiInput.inlineHoles_to_holeCharacterIndexes("a${0}b@{0}c@@d$$e${1}f") 47 | # value: ["a$b@c@d$e$f", [1, 9], [3]] 48 | -------------------------------------------------------------------------------- /lib/org/cubik/cle/dumpENodes.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def makeVisitor(writer, depth) :any { 7 | return def condensedDumpVisitor { 8 | match [`visit@name`, [_] + elements] { 9 | def single := elements.size() <=> 1 10 | def step := if (single) { "" } else { " " } 11 | writer.print(name.replaceAll("Expr", "E.").replaceAll("Pattern", "P.")) 12 | def nextWriter := writer.indent(step) 13 | for element in elements { 14 | if (single) { nextWriter.write(" ") } else { nextWriter.println() } 15 | if (element.__respondsTo("welcome", 1)) { element.welcome(makeVisitor(nextWriter, depth + 1)) 16 | } else if (element =~ l :List ? (l !~ s :String)) { E.call(makeVisitor(nextWriter, depth + 1), "visit[]", [null] + l) 17 | } else { 18 | nextWriter.print(element) 19 | } 20 | } 21 | } 22 | } 23 | } 24 | 25 | def dumpENodes implements ExitViaHere { 26 | to run(node, out) { 27 | node.welcome(makeVisitor(out, 0)) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /lib/org/cubik/cle/fail/defineException.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def makeException :DeepFrozen := 7 | 8 | def defineException implements DeepFrozen, ExitViaHere { 9 | to run(typeIDs :List[String], 10 | printer :DeepFrozen) { 11 | 12 | def cprinter :DeepFrozen := {def cprinter(tw :TextWriter, exception) implements DeepFrozen { 13 | printer(tw, exception._getProperties()) 14 | }} 15 | 16 | 17 | def exceptionDefinition implements DeepFrozen { 18 | to run(properties :Map[String, any]) { 19 | return makeException(typeIDs, 20 | properties, 21 | cprinter) 22 | } 23 | } 24 | 25 | return exceptionDefinition 26 | } 27 | } -------------------------------------------------------------------------------- /lib/org/cubik/cle/fail/defineExceptionGuard.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | pragma.enable("accumulator") 6 | 7 | def StructureException :DeepFrozen := 8 | def simplifyFQName :DeepFrozen := 9 | 10 | def defineExceptionGuard implements DeepFrozen, ExitViaHere { 11 | to run(matchTypeIDs :List[String]) { 12 | 13 | def idSet := matchTypeIDs.asSet() 14 | 15 | def exceptionGuard { 16 | to __printOn(out :TextWriter) { 17 | var sep := "" 18 | for x in matchTypeIDs { 19 | out.print(sep, simplifyFQName(x)) 20 | sep := "|" 21 | } 22 | } 23 | 24 | to coerce(specimen, optEjector) { 25 | def se := StructureException.coerce(specimen, optEjector) 26 | def type := se.__getAllegedType() 27 | if (accum false for super in type.getSupers() { _ | idSet.contains(super.getOptFQName()) }) { 28 | return se 29 | } else { 30 | throw.eject(optEjector, `exception $se doesn't match types $matchTypeIDs`) 31 | } 32 | } 33 | } 34 | 35 | return exceptionGuard 36 | } 37 | } -------------------------------------------------------------------------------- /lib/org/cubik/cle/fail/makeCoercionFailure.emaker: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/org/cubik/cle/fail/makeStringException.emaker: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/org/cubik/cle/file/File.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def AssocFunc := any # XXX point to interface 7 | 8 | def File := ( 9 | interface "org.cubik.cle.file.File" { 10 | to exists() :boolean 11 | to get(subpath :String) :File 12 | to getOpt(subpath :String) :nullOk[File] 13 | to getText() :String # XXX failure? 14 | to getTwine() :Twine # XXX failure? 15 | to deepReadOnly() :File 16 | to shallowReadOnly() :File 17 | to iterate(f :AssocFunc) :void 18 | }) 19 | 20 | # XXX all methods, docs -------------------------------------------------------------------------------- /lib/org/cubik/cle/file/makeReadOnlyFile.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | # XXX support File as lazy-value 7 | #def File := 8 | 9 | /** Return a read-only facet on a standard file-protocol object. */ 10 | def makeReadOnlyFile implements ExitViaHere { # implements DeepFrozen (fails because DeepFrozen uses this!) 11 | to run(rwFile, beShallow) { 12 | def readOnlyFile { # implements File 13 | # XXX all appropriate methods 14 | 15 | to deepReadOnly() { return readOnlyFile } # :File 16 | to shallowReadOnly() { return readOnlyFile } # :File 17 | 18 | to exists() :boolean { return rwFile.exists() } 19 | 20 | to getText() :String { return rwFile.getText() } 21 | to getTwine() :Twine { return rwFile.getTwine() } 22 | 23 | to getName() :String { return rwFile.getName() } 24 | to getPath() :String { return rwFile.getPath() } 25 | to getPlatformPath() :String { return rwFile.getPlatformPath() } 26 | } 27 | return readOnlyFile 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /lib/org/cubik/cle/io/join.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | pragma.enable("call-pattern") 6 | 7 | def ALL :DeepFrozen := EIO.getALL() 8 | 9 | def terminating(chunk) as DeepFrozen { 10 | return chunk == null || Ref.isBroken(chunk) 11 | } 12 | 13 | def join implements DeepFrozen, ExitViaHere { 14 | /** Transfers the elements of an InStream to an OutStream. Acts immediately if possible; for non-immediate effects, use join <- (...). The return value will be resolved, to the terminator of the input stream, as soon as no more elements will be delivered to the OutStream; at this time, the output stream will also be terminated. */ 15 | to run(input, output) { 16 | def loop() { 17 | while (true) { 18 | def chunk := input.takeAtMost(ALL) 19 | def resolver := output.reserve() 20 | if (Ref.isNear(resolver)) { 21 | resolver.resolve(chunk) 22 | } else { 23 | resolver <- resolve(chunk) 24 | } 25 | if (Ref.isNear(chunk)) { 26 | if (terminating(chunk)) { 27 | return chunk 28 | } 29 | } else { 30 | return when (chunk) -> { 31 | if (terminating(chunk)) { 32 | chunk 33 | } else { 34 | loop() 35 | } 36 | } 37 | } 38 | } 39 | } 40 | return loop() 41 | } 42 | } -------------------------------------------------------------------------------- /lib/org/cubik/cle/io/makeAppendStream.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | pragma.enable("call-pattern") 6 | 7 | def OutStream :DeepFrozen := 8 | def makeWriterStream :DeepFrozen := 9 | 10 | /** Makes OutStreams which synchronously append to FlexLists or other objects with append/1 and elementType/0 methods. A trivial but frequently occurring use of makeWriterStream. (For closure notification, check the resulting stream's terminates/0.) */ 11 | def makeAppendStream implements DeepFrozen, ExitViaHere { 12 | to run(target) :OutStream { 13 | # XXX target could be nonnear on construction if we could defer target.elementType(). change makeWriterStream interface? 14 | return makeWriterStream(List[target.valueType()], E.call, def listWriter { 15 | to write(chunk) { target.append(chunk) } 16 | to flush() {} 17 | to close() {} 18 | to fail(_) {} 19 | }) 20 | } 21 | } 22 | 23 | -------------------------------------------------------------------------------- /lib/org/cubik/cle/io/makeSubOutStream.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | pragma.enable("call-pattern") 6 | 7 | # XXX this emaker has no tests, whoops 8 | 9 | def OutStream :DeepFrozen := 10 | def makeSubOutStream implements DeepFrozen, ExitViaHere { 11 | /** Wraps an OutStream with another OutStream which passes on chunks and failure, but not closure. */ 12 | to stopClose(target :OutStream) :OutStream { 13 | 14 | def [terminator, termRes] := Ref.promise() 15 | 16 | var optUnusedResolver := null 17 | 18 | Ref.whenResolved(target.terminates(), termRes.resolveRace) 19 | 20 | return def subOutStream { 21 | to getChunkType() { return target.getChunkType() } 22 | to reserve() { 23 | if (Ref.isResolved(terminator)) { return terminator } 24 | return Ref.whenResolved(if (optUnusedResolver != null) \ 25 | { def r := optUnusedResolver; optUnusedResolver := null; r } \ 26 | else { target.reserve() }, 27 | fn targetResolver { 28 | def subResolver { 29 | to resolve(chunk) { 30 | switch (chunk) { 31 | match ==null { 32 | termRes.resolveRace(chunk) 33 | targetResolver.resolve([]) # XXX support general chunk types 34 | optUnusedResolver := targetResolver 35 | } 36 | #match Ref.broken(_) { 37 | # termRes.resolveRace(chunk) 38 | # optUnusedResolver := targetResolver 39 | #} 40 | match _ { 41 | targetResolver.resolve(chunk) 42 | } 43 | } 44 | } 45 | to smash(p) { subResolver.resolve(Ref.broken(p)) } 46 | } 47 | }) 48 | } 49 | to flush() { 50 | target.flush() 51 | } 52 | to terminates() { 53 | return terminator 54 | } 55 | } 56 | } 57 | } 58 | 59 | -------------------------------------------------------------------------------- /lib/org/cubik/cle/io/transformOut.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | pragma.enable("call-pattern") 6 | 7 | interface Resolver :DeepFrozen {} # XXX implement 8 | 9 | def OutStream :DeepFrozen := any # # XXX should be DeepFrozen, isn't because 'vow' isn't 10 | 11 | def transformOut implements DeepFrozen, ExitViaHere { 12 | # XXX chunkType should probably be provided by chunkFilter -- do this to transformIn as well 13 | to run(chunkType :Guard, chunkFilter, underlying :OutStream) :OutStream { 14 | return def transformOutStream { # implements OutStream 15 | to __printOn(out :TextWriter) { 16 | out.write("-") 17 | out.print(chunkFilter) 18 | out.write("->") 19 | out.printSame(underlying) 20 | } 21 | 22 | to getChunkType() { 23 | return chunkType 24 | } 25 | to reserve() { 26 | return Ref.whenResolved(underlying.reserve(), fn targetResolver { 27 | if (targetResolver == null || Ref.isBroken(targetResolver)) { 28 | targetResolver 29 | } else { 30 | def subResolver implements Resolver { 31 | to resolve(chunk) { 32 | if (chunk == null && chunkFilter.__respondsTo("finish", 0)) { 33 | def fin := chunkFilter.finish() 34 | targetResolver.resolve(fin) 35 | underlying.reserve() <- resolve(null) # XXX need a policy? 36 | } else if (chunk == null || Ref.isBroken(chunk)) { 37 | targetResolver.resolve(chunk) 38 | } else { 39 | targetResolver.resolve(chunkFilter(chunk)) 40 | } 41 | } 42 | to smash(problem) { 43 | targetResolver.resolve(Ref.broken(problem)) 44 | } 45 | } 46 | } 47 | }) 48 | } 49 | to flush() { 50 | underlying.flush() 51 | } 52 | to terminates() { 53 | return underlying.terminates() 54 | } 55 | } 56 | } 57 | } 58 | 59 | -------------------------------------------------------------------------------- /lib/org/cubik/cle/io/trickleIn.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2008 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def ALL :DeepFrozen := EIO.getALL() 7 | def InStream :DeepFrozen := 8 | 9 | def trickleIn implements DeepFrozen { 10 | to run(underlying :InStream) { 11 | def one 12 | def zero 13 | var howMany := zero 14 | bind one() { howMany := zero; return 1 } 15 | bind zero() { howMany := one; return 0 } 16 | 17 | return def trickleIn implements InStream { 18 | to __printOn(out :TextWriter) { 19 | out.write("<-trickling-") 20 | out.printSame(underlying) 21 | } 22 | 23 | to getChunkType() :Guard { return underlying.getChunkType() } 24 | to fail(p) :void { underlying.fail(p) } 25 | to close() :void { underlying.close() } 26 | 27 | to takeAtMost(maximum :int) :any { 28 | if (0 <=> maximum) { 29 | return underlying <- takeAtMost(maximum) 30 | } else { 31 | return underlying <- takeAtMost(howMany()) 32 | } 33 | } 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /lib/org/cubik/cle/makeAdvisoryInterface.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def simplifyFQName :DeepFrozen := 7 | 8 | def EventuallyDeepFrozen :()[DeepFrozen."eventually"()] := DeepFrozen."eventually"() 9 | 10 | def makeAdvisoryInterface implements DeepFrozen, ExitViaHere { 11 | to run(typeDesc) { # XXX typeDesc :Data 12 | def advisoryInterface implements EventuallyDeepFrozen { # XXX implements Data 13 | method __optSealedDispatch(brand) :any { 14 | if (brand == EventuallyDeepFrozen.getPeekBrand()) { 15 | EventuallyDeepFrozen.getPeekSealer().seal(meta.getState()) 16 | } 17 | } 18 | 19 | to audit(_) :any { 20 | # XXX allow stamping? 21 | return false 22 | } 23 | 24 | to coerce(specimen, _) { 25 | return specimen 26 | } 27 | 28 | to __printOn(out :TextWriter) :void { 29 | out.print(simplifyFQName(typeDesc.getFQName())) 30 | } 31 | 32 | # XXX should extend the TypeDesc 33 | } 34 | return advisoryInterface 35 | } 36 | } -------------------------------------------------------------------------------- /lib/org/cubik/cle/makeDefaultPropertySlot.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def ePrinter :DeepFrozen := 7 | 8 | def makeDefaultPropertySlot(object, propertyName :String) implements DeepFrozen { 9 | 10 | def capName := { def mark := 1.min(propertyName.size()) 11 | propertyName(0, mark).toUpperCase() + 12 | propertyName(mark) } 13 | def getVerb := "get" + capName 14 | def setVerb := "set" + capName 15 | /** This is a Slot acting as a facet on the `get$Property` and `set$Property` methods of another object. */ 16 | def defaultPropertySlot { 17 | to __printOn(out :TextWriter) { 18 | ePrinter.printPropertySlot(out, propertyName) 19 | } 20 | /** E.call(target, `get$Property`, []) */ 21 | to get() { 22 | return E.call(object, getVerb, []) 23 | } 24 | /** E.call(target, `set$Property`, [new]); null */ 25 | to put(new) { 26 | E.call(object, setVerb, [new]) 27 | null 28 | } 29 | to isFinal() { return false } 30 | } 31 | return defaultPropertySlot 32 | } -------------------------------------------------------------------------------- /lib/org/cubik/cle/makeDelayingRef.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2008 Kevin Reid under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def makeProxy :DeepFrozen := 7 | 8 | /** Make an eventual ref which stores its messages in a buffer, and delivers all messages so far (but not future messages) to another ref on command. Originally written for orchestrating tests of eventual protocols. */ 9 | def makeDelayingRef(resolved :boolean) implements ExitViaHere, DeepFrozen { 10 | # future ideas: allow promise->far transition while still buffering; allow a user-supplied buffer 11 | 12 | def buffer := [].diverge() 13 | 14 | def delayingRefHandler { 15 | method handleSend(verb, args) :any { 16 | def [p, r] := Ref.promise() 17 | buffer.push([verb, args, r]) 18 | p 19 | } 20 | 21 | method handleSendOnly(verb, args) { 22 | # XXX we should propagate sendOnlyness since it is visible to the target 23 | delayingRefHandler.handleSend(verb, args) 24 | } 25 | 26 | method handleOptSealedDispatch(brand) { null } 27 | } 28 | 29 | def delayingRefResolver { 30 | to resolveSoFar(target) { 31 | for [verb, args, resolver] in buffer.removeRun(0) { 32 | resolver.resolve(E.send(target, verb, args)) 33 | } 34 | } 35 | } 36 | 37 | return [makeProxy(delayingRefHandler, (def p; p), resolved), 38 | delayingRefResolver] 39 | } -------------------------------------------------------------------------------- /lib/org/cubik/cle/makePseudoFarRef.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | pragma.enable("exporter") 7 | pragma.enable("importer") 8 | pragma.enable("accumulator") 9 | 10 | # could be Data 11 | def nonPassedMiranda :DeepFrozen := \ 12 | accum [].asSet() for messageDesc in \ 13 | null.__getAllegedType().getMessageTypes().without("__getAllegedType/0") \ 14 | .without("__respondsTo/2").without("__reactToLostClient/1") \ 15 | .without("__optSealedDispatch/1").without("__printOn/1") { 16 | _.with([messageDesc.getVerb(), messageDesc.getParams().size()]) 17 | } 18 | 19 | def makeProxy :DeepFrozen := 20 | 21 | def makePseudoFarRef implements DeepFrozen, ExitViaHere { 22 | /** Make a Far reference out of a Near reference from the same vat. It does not modify arguments and return values, so is not a membrane. XXX document miranda method choices */ 23 | to run(nearRef) { 24 | 25 | def proxy 26 | 27 | def farHandler { 28 | method handleSend(verb, args) :any { 29 | switch ([verb, args]) { 30 | match [=="__order", [nv, na]] { 31 | [farHandler.handleSend(nv, na), proxy] 32 | } 33 | match [=="__optUncall", []] { null } 34 | match [=="__conformTo", [_]] { proxy } 35 | match [=="__whenBroken", [_]] { null } 36 | match [=="__whenMoreResolved", [reactor]] { 37 | E.sendOnly(reactor, "run", [proxy]) 38 | null 39 | } 40 | match _ ? nonPassedMiranda.contains(def pairName := [verb, args.size()]) { 41 | throw(`unhandled unpassed miranda method: $pairName`) 42 | } 43 | match _ { E.send(nearRef, verb, args) } 44 | } 45 | } 46 | 47 | method handleSendOnly(verb, args) { 48 | # XXX passed-on sendOnlys will unnecessarily become sends (but this is not too bad since our target is usually near) 49 | farHandler.handleSend(verb, args) 50 | } 51 | } 52 | 53 | return bind proxy := makeProxy(farHandler, (def p; p), true) 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /lib/org/cubik/cle/memoize.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | -------------------------------------------------------------------------------- /lib/org/cubik/cle/prim/anyGuardSugar.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def makeUnionGuard :DeepFrozen := 7 | 8 | def sugarRoot :DeepFrozen := 9 | 10 | def anyGuardSugar extends sugarRoot implements DeepFrozen, ExitViaHere { 11 | to "instance_match__of/1"(self, specimen, ejector) { 12 | return makeUnionGuard."match__run/1"(specimen, ejector) 13 | } 14 | 15 | to instance_of(self, options) { return makeUnionGuard(options) } 16 | 17 | match [=="instance_get", [self] + options ? options.size().aboveZero()] { 18 | makeUnionGuard(options) 19 | } 20 | 21 | match [=="__respondsTo", [=="instance_get", n :int ? n.aboveZero()]] { 22 | true 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /lib/org/cubik/cle/root.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2006-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def EventuallyDeepFrozen :()[DeepFrozen."eventually"()] := DeepFrozen."eventually"() 7 | 8 | def root implements DeepFrozen, ExitViaHere { 9 | /** Produces an object to serve as the root of 'extends' chains. It responds 'no such method' to everything, but refers to 'self' in the error instead of the parent-most object. */ 10 | to get(self) { 11 | return def root1 implements EventuallyDeepFrozen { 12 | 13 | method __optSealedDispatch(brand) :any { 14 | if (brand == EventuallyDeepFrozen.getPeekBrand()) { 15 | EventuallyDeepFrozen.getPeekSealer().seal(meta.getState()) 16 | } 17 | } 18 | 19 | to __printOn(out :TextWriter) { 20 | out.write("") 23 | } 24 | 25 | match [=="__getAllegedType", []] { 26 | # Miranda __getAllegedType/0 invokes matchers 27 | null.__getAllegedType() 28 | } 29 | 30 | # match [=="__respondsTo", [verb, arity]] { # XXX not proven necessary yet 31 | 32 | match [verb, args] { 33 | # XXX typed exception 34 | # XXX have built-in no-such-method give this more useful error 35 | throw(`the ${self.__getAllegedType().getFQName()} ${E.toQuote(self)} does not understand $verb/${args.size()} $args`) 36 | } 37 | } 38 | }} 39 | -------------------------------------------------------------------------------- /lib/org/cubik/cle/schedule/Schedule.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2008 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def File := ( 7 | interface "org.cubik.cle.schedule.Schedule" { 8 | /** Invoke reactor with ref. If possible, do so after ref is resolved. */ 9 | to whenResolved(ref :any, reactor :any) 10 | /** Invoke continueFn until it returns false, then return null. */ 11 | to loop(continueFn) :vow[nullOk] 12 | /** Return nearGuard or vow[nearGuard], as appropriate. */ 13 | to result(nearGuard :Guard) :Guard 14 | }) 15 | -------------------------------------------------------------------------------- /lib/org/cubik/cle/schedule/eventual.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2008 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def Schedule := 7 | 8 | def ::"eventual" implements DeepFrozen, Schedule { 9 | to whenResolved(ref, reactor) { 10 | return Ref.whenResolved(ref, reactor) 11 | } 12 | to loop(continueFn) { 13 | return when (def again := continueFn <- ()) -> { 14 | if (again) { 15 | ::"eventual".loop(continueFn) 16 | } else { 17 | null 18 | } 19 | } 20 | } 21 | to result(g) { return vow[g] } 22 | } -------------------------------------------------------------------------------- /lib/org/cubik/cle/schedule/now.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2008 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def Schedule := 7 | 8 | def now implements DeepFrozen, Schedule { 9 | to whenResolved(ref, reactor) { 10 | # if (Ref.isEventual(ref)) -- should we fail here? 11 | return reactor(ref) 12 | } 13 | to loop(continueFn) { 14 | __loop(continueFn) 15 | } 16 | to result(g) { return g } 17 | } -------------------------------------------------------------------------------- /lib/org/cubik/cle/simpleRuneAuthor.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2008 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | pragma.enable("importer") 7 | pragma.enable("exporter") 8 | 9 | def makeEParser :DeepFrozen := 10 | 11 | def simpleRuneAuthor implements DeepFrozen, ExitViaHere { 12 | to defaultAuths() { 13 | def privilegedScope := 14 | return [ 15 | "file__uriGetter" => privilegedScope["file__uriGetter"], 16 | "privilegedScope" => privilegedScope 17 | ] 18 | } 19 | 20 | to run(auths :Map) { 21 | def [=> , => privilegedScope] | _ := auths 22 | 23 | def simpleRune { 24 | to run(args :List) { 25 | switch (args) { 26 | match [scriptName] + scriptArgs { 27 | def scope := privilegedScope.with("interp", 28 | def interp extends privilegedScope["interp"] { 29 | to getArgs() { return scriptArgs }}) 30 | 31 | return makeEParser.run([scriptName].getTwine()).asKernelE() <- eval(scope) 32 | } 33 | match [] { 34 | def [=> lisp] | _ := privilegedScope 35 | return lisp["CL", "FUNCALL"].getFunction()( 36 | lisp["E.UTIL", "SYSTEM-SYMBOL"].getFunction()( 37 | "REPL-START", "E.UPDOC", "e-on-cl.updoc")) 38 | } 39 | } 40 | } 41 | } 42 | return simpleRune 43 | } 44 | } -------------------------------------------------------------------------------- /lib/org/cubik/cle/sugarRoot.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2006-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def sugarRoot implements DeepFrozen, ExitViaHere { 7 | match [=="instance___getAllegedType", [_]] { 8 | # __getAllegedType/0 for the sugar 9 | null.__getAllegedType() 10 | } 11 | 12 | match [=="instance___respondsTo", [self, verb, arity]] { 13 | [verb, arity] == ["__getAllegedType", 0] || 14 | [verb, arity] == ["__respondsTo", 2] 15 | } 16 | 17 | match [`instance_@verb`, [self] + args] { 18 | # XXX typed exception 19 | # XXX have built-in no-such-method give this more useful error 20 | 21 | # this form disabled because simple__quasiParser is too unprimitive 22 | #throw(`the ${self.__getAllegedType().getFQName()} ${E.toQuote(self)} does not understand $verb/${args.size()} $args`) 23 | 24 | throw(E.toString(def _{to __printOn(out :TextWriter) { 25 | out.write("the ") 26 | out.print(self.__getAllegedType().getFQName()) 27 | out.write(" ") 28 | out.quote(self) 29 | out.write(" does not understand ") 30 | out.print(verb) 31 | out.write("/") 32 | out.print(args.size()) 33 | args.printOn(" (", ", ", ")", out) 34 | }})) 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /lib/org/cubik/cle/test/emakerEnvGuards.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2008 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | def FinalSlot := .asType() 5 | def Same := 6 | 7 | def checkerAuditor { 8 | to audit(audition) { 9 | for noun => slot in ["true" => &true, "float64" => &float64] { 10 | require((def g := audition.getGuard(noun)) == Same[slot], fn { 11 | `$noun's guard isn't Same[$slot], but $g` 12 | }) 13 | } 14 | 15 | # These guards are not Same[slot] because these things are private to the emaker, and so it is not necessarily-harmless to reveal them to auditors. 16 | for noun in ["trace", "traceln", "ExitViaHere"] { 17 | require((def g := audition.getGuard(noun)) == FinalSlot[DeepFrozen], fn { 18 | `$noun's guard isn't FinalSlot[DeepFrozen], but $g` 19 | }) 20 | } 21 | 22 | return false 23 | } 24 | } 25 | 26 | def dummy implements checkerAuditor { 27 | to run() { true; float64; trace; traceln; ExitViaHere } 28 | } 29 | 30 | "ok" -------------------------------------------------------------------------------- /lib/org/cubik/cle/test/importUncall/askedEarly.emaker: -------------------------------------------------------------------------------- 1 | pragma.syntax("0.9") 2 | 3 | def askedEarly implements DeepFrozen, ExitViaHere {} 4 | 5 | if (.optUnget(askedEarly) != null) { 6 | throw("shouldn't happen") 7 | } 8 | 9 | askedEarly -------------------------------------------------------------------------------- /lib/org/cubik/cle/test/importUncall/notRequested.emaker: -------------------------------------------------------------------------------- 1 | pragma.syntax("0.9") 2 | 3 | def notRequested implements DeepFrozen {} -------------------------------------------------------------------------------- /lib/org/cubik/cle/test/importUncall/notUnique.emaker: -------------------------------------------------------------------------------- 1 | pragma.syntax("0.9") 2 | 3 | def notUnique implements ExitViaHere {} -------------------------------------------------------------------------------- /lib/org/cubik/cle/test/importUncall/ok.emaker: -------------------------------------------------------------------------------- 1 | pragma.syntax("0.9") 2 | 3 | def ok implements DeepFrozen, ExitViaHere {} -------------------------------------------------------------------------------- /lib/org/cubik/cle/test/importUncall/selfless.emaker: -------------------------------------------------------------------------------- 1 | pragma.syntax("0.9") 2 | 3 | ["selfless E-implemented"].asSet() -------------------------------------------------------------------------------- /lib/org/cubik/cle/test/testSugar.emaker: -------------------------------------------------------------------------------- 1 | def testSugar { 2 | to instance_foo(self, bar) { 3 | return [E.toQuote(self), "baz", bar] 4 | } 5 | } -------------------------------------------------------------------------------- /lib/org/cubik/cle/wrapRandomState.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def swissSizeInOctets :int := 20 7 | def swissUpperBound :int := 2 ** (8 * swissSizeInOctets) 8 | 9 | /** Wrap a CL:RANDOM-STATE object so as to hide its state. */ 10 | def wrapRandomState(randomState) implements DeepFrozen, ExitViaHere { 11 | trace("WARNING: privilegedScope entropy is not yet high-quality") 12 | return def wrappedRandomState { 13 | to __printOn(out :TextWriter) { 14 | out.write("") 15 | } 16 | to nextInt(range :int) :int { return randomState.nextInt(range) } 17 | to nextSwiss() :int { return randomState.nextInt(swissUpperBound) } 18 | } 19 | } -------------------------------------------------------------------------------- /lib/org/erights/e/develop/exception/makePrintStreamWriterAuthor.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def makePrintStreamWriterAuthor(stdin, stdout, stderr) { 7 | /** This object exists solely to support inherited rune */ 8 | def makePrintStreamWriter { 9 | to stdin() { return stdin } 10 | to stdout() { return stdout } 11 | to stderr() { return stderr } 12 | } 13 | return makePrintStreamWriter 14 | } -------------------------------------------------------------------------------- /lib/org/erights/e/elang/evm/StaticWalkEnvironment.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def := # XXX shouldn't be .type. 7 | 8 | # XXX document this interface 9 | 10 | ( 11 | interface StaticWalkEnvironment { 12 | to withNounUse(_ :any[, ]) :StaticWalkEnvironment 13 | 14 | to withFinalPattern(_ :()) :StaticWalkEnvironment 15 | to withVarPattern(_ :()) :StaticWalkEnvironment 16 | to withBindingPattern(_ :()) :StaticWalkEnvironment 17 | 18 | to withAssignment(_ :()) :StaticWalkEnvironment 19 | 20 | to withMetaState() :StaticWalkEnvironment 21 | 22 | to withHide(_) :StaticWalkEnvironment 23 | to withScript(_) :StaticWalkEnvironment 24 | 25 | to withSubnode(key :String, subnode :()) :StaticWalkEnvironment 26 | to withSubnodeIndex(key :String, subnode :()) :StaticWalkEnvironment 27 | }) 28 | -------------------------------------------------------------------------------- /lib/org/erights/e/elang/evm/makeSimpleNounExpr.emaker: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /lib/org/erights/e/elang/evm/makeStaticScope.emaker: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /lib/org/erights/e/elang/expand/__switchFailed.emaker: -------------------------------------------------------------------------------- 1 | pragma.syntax("0.9") 2 | 3 | 4 | def defineException :DeepFrozen := 5 | #def defineExceptionGuard :DeepFrozen := 6 | 7 | def makeSwitchFailure :DeepFrozen := defineException( 8 | [def failureFQN := meta.context().getFQNPrefix() + "SwitchFailure"], 9 | def _(out :TextWriter, [=> specimen, => failures]) as DeepFrozen { 10 | out.print(specimen) 11 | out.write(" did not match any option:") 12 | def outi := out.indent() 13 | for failure in failures { outi.lnPrint(failure) } 14 | }) 15 | # def SwitchFailure := defineExceptionGuard([failureFQN]) 16 | 17 | {def __switchFailed implements DeepFrozen, ExitViaHere { 18 | match [=="run", [specimen] + failures] { 19 | # XXX avoid printing 20 | throw(makeSwitchFailure([=> specimen, => failures])) 21 | } 22 | }} 23 | -------------------------------------------------------------------------------- /lib/org/erights/e/elang/expand/booleanFlow.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2006-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def broken :DeepFrozen := (any, Ref.broken("boolean flow expression failed"), null) 7 | 8 | def booleanFlow implements DeepFrozen, ExitViaHere { 9 | to broken() { return broken } 10 | to failureList(size :int) { 11 | return [false] + [broken] * size 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /lib/org/erights/e/elang/expand/comparer.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | # XXX document 7 | 8 | # NOTE: Adding boolean result guards would break the OrderedRegion making trick (int > 0) 9 | def comparer implements DeepFrozen, ExitViaHere { 10 | method lessThan (a, b) { a.op__cmp(b).belowZero () } 11 | method leq (a, b) { a.op__cmp(b).atMostZero () } 12 | method asBigAs (a, b) { a.op__cmp(b).isZero () } 13 | method geq (a, b) { a.op__cmp(b).atLeastZero() } 14 | method greaterThan(a, b) { a.op__cmp(b).aboveZero () } 15 | } -------------------------------------------------------------------------------- /lib/org/erights/e/elang/expand/makeViaBinder.emaker: -------------------------------------------------------------------------------- 1 | pragma.syntax("0.9") 2 | 3 | 4 | {def __bind implements DeepFrozen, ExitViaHere { 5 | to run(resolver) :any { 6 | return def binder(specimen, _) :any { # implements ViaFunction 7 | resolver.resolve(specimen) 8 | } 9 | } 10 | to run(resolver, guard) :any { 11 | return def guardedBinder(specimen, optEjector) :any { # implements ViaFunction 12 | resolver.resolve(guard.coerce(specimen, optEjector)) 13 | } 14 | } 15 | }} 16 | -------------------------------------------------------------------------------- /lib/org/erights/e/elang/expand/makeViaExtractor.emaker: -------------------------------------------------------------------------------- 1 | pragma.syntax("0.9") 2 | 3 | 4 | {def __mapExtract implements DeepFrozen, ExitViaHere { 5 | to run(key) :any { 6 | return def extractor(specimen, optEjector) implements DeepFrozen.optionally() { # implements ViaFunction 7 | return escape e { 8 | [specimen.fetch(key, e), specimen.without(key)] 9 | } catch _ { 10 | # XXX avoid printing 11 | throw.eject(optEjector, E.toQuote(key) + " not in matched map: " + E.toQuote(specimen)) 12 | } 13 | } 14 | } 15 | to "default"(key, defaultValue) :any { 16 | return def defaultingExtractor(specimen, optEjector) implements DeepFrozen.optionally() { # implements ViaFunction 17 | return [specimen.fetch(key, fn { return [defaultValue, specimen] }), specimen.without(key)] 18 | } 19 | } 20 | }} 21 | -------------------------------------------------------------------------------- /lib/org/erights/e/elang/expand/makeViaQuasi.emaker: -------------------------------------------------------------------------------- 1 | pragma.syntax("0.9") 2 | 3 | 4 | {def __quasiMatcher implements DeepFrozen, ExitViaHere { 5 | to run(matchMaker, values) :any { 6 | return def quasiMatcher(specimen, optEjector) :any implements DeepFrozen.optionally() { 7 | return matchMaker.matchBind(values, specimen, optEjector) 8 | } 9 | } 10 | }} 11 | -------------------------------------------------------------------------------- /lib/org/erights/e/elang/expand/makeViaSame.emaker: -------------------------------------------------------------------------------- 1 | pragma.syntax("0.9") 2 | 3 | 4 | {def __matchSame implements DeepFrozen, ExitViaHere { 5 | to run(expected) :any { 6 | return def sameMatcher(specimen, optEjector) :any implements DeepFrozen.optionally() { 7 | def comparison := __equalizer.optSame(specimen, expected) 8 | # XXX avoid printing 9 | if (comparison == null) { 10 | throw.eject(optEjector, E.toQuote(specimen) + " is not yet " + E.toQuote(expected)) 11 | } else if (comparison) { 12 | return expected 13 | } else { 14 | throw.eject(optEjector, E.toQuote(specimen) + " is not " + E.toQuote(expected)) 15 | } 16 | } 17 | } 18 | to different(unexpected) :any { 19 | return def differentMatcher(specimen, optEjector) :any implements DeepFrozen.optionally() { 20 | def comparison := __equalizer.optSame(specimen, unexpected) 21 | # XXX avoid printing 22 | if (comparison == null) { 23 | throw.eject(optEjector, E.toQuote(specimen) + " is not yet different from " + E.toQuote(unexpected)) 24 | } else if (comparison) { 25 | throw.eject(optEjector, "must not be " + E.toQuote(unexpected)) 26 | } else { 27 | return specimen 28 | } 29 | } 30 | } 31 | }} 32 | -------------------------------------------------------------------------------- /lib/org/erights/e/elang/expand/slotToBinding.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2008 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def makeCoercedSlot :DeepFrozen := 7 | 8 | def slotToBinding implements DeepFrozen, ExitViaHere { 9 | to run(guard) { 10 | return def guardedSlotToBinding(specimen, ejector) { 11 | return makeCoercedSlot(guard, specimen, ejector) 12 | } 13 | } 14 | to run(specimen, ejector) { 15 | return makeCoercedSlot(any, specimen, throw) 16 | } 17 | } -------------------------------------------------------------------------------- /lib/org/erights/e/elang/expand/viaEmptyMap.emaker: -------------------------------------------------------------------------------- 1 | pragma.syntax("0.9") 2 | 3 | {def __mapEmpty(specimen, optEjector) :void implements DeepFrozen, ExitViaHere { # implements ViaFunction 4 | if (specimen.size().isZero()) { 5 | } else { 6 | # XXX avoid printing 7 | throw.eject(optEjector, "unused elements in matched map: " + E.toQuote(specimen)) 8 | } 9 | }} 10 | -------------------------------------------------------------------------------- /lib/org/erights/e/elang/interp/makePackageLoader.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def EventuallyDeepFrozen :()[DeepFrozen."eventually"()] := DeepFrozen."eventually"() 7 | 8 | def makePackageLoader implements DeepFrozen, ExitViaHere { 9 | to run(loader, scheme, packageFQN) { 10 | def fqnPrefix := packageFQN(0, packageFQN.size() - 1) 11 | 12 | def packageLoader implements EventuallyDeepFrozen { # extends makeBaseLoader(...) 13 | method __optSealedDispatch(brand) :any { 14 | if (brand == EventuallyDeepFrozen.getPeekBrand()) { 15 | EventuallyDeepFrozen.getPeekSealer().seal(meta.getState()) 16 | } 17 | } 18 | 19 | to __printOn(out :TextWriter) { 20 | out.write("<") 21 | out.print(scheme) 22 | out.print(fqnPrefix + "*") 23 | out.write(">") 24 | } 25 | 26 | to get(name) { 27 | return loader[fqnPrefix + name] 28 | } 29 | to fetch(name, absent) { 30 | return loader.fetch(fqnPrefix + name, absent) 31 | } 32 | 33 | to without(_) { return packageLoader } # XXX map-pattern support hack 34 | } 35 | 36 | return packageLoader 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /lib/org/erights/e/elang/interp/notNull.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2002 Combex, Inc. under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.8") 5 | 6 | # modified by kpreid to be DeepFrozen and not use __makeGuard 7 | 8 | /** 9 | * Defines the builtin 'notNull' guard. 10 | * 11 | * @author Mark Miller 12 | */ 13 | def notNull0 implements DeepFrozen, ExitViaHere { 14 | /** 15 | * 'notNull' is a non-transforming guard -- when it succeeds, the result 16 | * is the same as the specimen. 17 | *

18 | * notNull succeeds when the specimen is either not settled or not null. 19 | * This means it will succeed for a promise that hasn't yet resolved to 20 | * null, even if it will be resolved to null. 21 | */ 22 | to coerce(specimen, optEjector) :any { 23 | if (Ref.isSettled(specimen) && null == specimen) { 24 | throw.eject(optEjector, "Must not be null") 25 | } else { 26 | specimen 27 | } 28 | } 29 | 30 | /** 31 | * Prints "notNull" 32 | */ 33 | to __printOn(out :TextWriter) :void { out.print("notNull") } 34 | } 35 | -------------------------------------------------------------------------------- /lib/org/erights/e/elang/interp/type/ControlLoop.emaker: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /lib/org/erights/e/elang/interp/typeLoader.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def insertNamePrefix :DeepFrozen := {def insertNamePrefix(fqn, insertion) implements DeepFrozen { 7 | def lastDotPos := fqn.lastIndexOf1('.') 8 | return \ 9 | if (lastDotPos == -1) { 10 | insertion + fqn 11 | } else { 12 | def after := lastDotPos + 1 13 | fqn(0, after) + insertion + fqn(after) 14 | } 15 | }} 16 | 17 | /** Compatibility. => OR .asType(), whichever exists */ 18 | def typeLoader implements DeepFrozen, ExitViaHere { 19 | to __printOn(out :TextWriter) { 20 | out.print("") 21 | } 22 | 23 | to get(fqn :String) :any { 24 | escape notTypeEmaker { 25 | return .fetch(insertNamePrefix(fqn, "type."), notTypeEmaker) 26 | } 27 | 28 | def maker := .fetch( 29 | insertNamePrefix(fqn, "make"), 30 | fn { 31 | throw(`no type object found for $fqn`) 32 | }) 33 | try { 34 | return maker.asType() 35 | } catch p { 36 | traceln(`type-loader: maker $maker for fqn $fqn exists but .asType() failed`) 37 | throw(p) 38 | } 39 | } 40 | 41 | /** Always returns null. 42 | 43 | Use .optUncall instead. */ 44 | to optUncall(specimen) {} 45 | } 46 | -------------------------------------------------------------------------------- /lib/org/erights/e/elang/scope/makeScope.emaker: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /lib/org/erights/e/elang/syntax/ePrinter.emaker: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /lib/org/erights/e/elang/syntax/epatt__quasiParser.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def primParser :DeepFrozen := 7 | def convertQuasiInput :DeepFrozen := 8 | 9 | def epatt__quasiParser implements DeepFrozen, ExitViaHere { 10 | to valueMaker(quasi1Source) { 11 | def [quasi2Source, valueHoles, patternHoles] := convertQuasiInput.inlineHoles_to_holeCharacterIndexes(quasi1Source) 12 | return primParser.pattern(quasi2Source, [valueHoles, patternHoles], null) 13 | } 14 | 15 | to matchMaker(quasi1Source) { 16 | def [quasi2Source, valueHoles, patternHoles] := convertQuasiInput.inlineHoles_to_holeCharacterIndexes(quasi1Source) 17 | return primParser.pattern(quasi2Source, [valueHoles, patternHoles], null) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /lib/org/erights/e/elang/syntax/makeELexer.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def primParser :DeepFrozen := 7 | def makeTwineFeeder :DeepFrozen := 8 | 9 | /** Java-E compatibility for makeParseFuncAuthor */ 10 | def makeELexer implements DeepFrozen, ExitViaHere { 11 | to make(source :Twine, partialFlag, noTabsFlag) { 12 | return makeELexer(makeTwineFeeder(source), partialFlag, noTabsFlag) 13 | } 14 | to run(var lineFeeder, partialFlag :boolean, noTabsFlag :boolean) { 15 | def fakeELexer { 16 | /** kludge */ 17 | to getFeeder() { return lineFeeder } 18 | 19 | to setSource(source :Twine) { 20 | lineFeeder := makeTwineFeeder(source) 21 | } 22 | } 23 | return fakeELexer 24 | } 25 | to isIdentifier(noun) { return primParser.isIdentifier(noun) } 26 | } -------------------------------------------------------------------------------- /lib/org/erights/e/elang/syntax/makePrettyFeeder.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def makePrettyFeeder implements DeepFrozen, ExitViaHere { 7 | to pretty(text) { return text } # XXX stub for deSrcKit. this should be doing indentation 8 | } 9 | -------------------------------------------------------------------------------- /lib/org/erights/e/elang/visitors/makeENodeCopyVisitor.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | pragma.enable("accumulator") 6 | 7 | def root :DeepFrozen := 8 | 9 | def makeENodeCopyVisitor implements DeepFrozen, ExitViaHere { # XXX write tests and documentation for this 10 | to run(self) { 11 | def eNodeCopyVisitor extends root[self] { 12 | to run(node) { 13 | return switch (node) { 14 | match list :List { 15 | accum [] for x in list { _.with(self.run(x)) } 16 | } 17 | match ==null { null } 18 | match _ { 19 | node.welcome(self) 20 | } 21 | } 22 | } 23 | 24 | match [`visit@_`, [optOriginal :notNull] + args] { 25 | def maker := optOriginal.__optUncall()[0] 26 | 27 | def subnodeFlags := maker.getParameterSubnodeFlags() 28 | 29 | def left := [if (optOriginal != null) {optOriginal.getOptSpan()}] 30 | # xxx preserve scope layout arg, if it ever becomes real 31 | def right := [null] 32 | 33 | E.call(maker, "run", 34 | accum left for i => arg in args { _.with( 35 | if (subnodeFlags[i]) { 36 | self.run(arg) 37 | } else { 38 | arg 39 | } 40 | )} + right 41 | ) 42 | } 43 | } 44 | return eNodeCopyVisitor 45 | } 46 | } -------------------------------------------------------------------------------- /lib/org/erights/e/elang/visitors/makeKernelECopyVisitor.emaker: -------------------------------------------------------------------------------- 1 | # E-on-Java compatibility alias. 2 | -------------------------------------------------------------------------------- /lib/org/erights/e/elang/visitors/makeQuasiSubstituteVisitor.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def EventuallyDeepFrozen :()[DeepFrozen."eventually"()] := DeepFrozen."eventually"() 7 | 8 | def makeENodeCopyVisitor :DeepFrozen := 9 | 10 | def makeQuasiSubstituteVisitor implements DeepFrozen, ExitViaHere { 11 | to run(args) { 12 | def substituteVisitor extends makeENodeCopyVisitor(substituteVisitor) \ 13 | implements EventuallyDeepFrozen { 14 | method __optSealedDispatch(brand) :any { 15 | if (brand == EventuallyDeepFrozen.getPeekBrand()) { 16 | EventuallyDeepFrozen.getPeekSealer().seal(meta.getState()) 17 | } 18 | } 19 | 20 | to visitQuasiLiteralNode(optOriginal, index) { 21 | return args[index] 22 | } 23 | to visitQuasiLiteralExpr(optOriginal, index) { 24 | return args[index] 25 | } 26 | to visitQuasiLiteralPatt(optOriginal, index) { 27 | return args[index] 28 | } 29 | to visitQuasiPatternNode(optOriginal, index) { 30 | throw("found quasi-pattern node $optOriginal in quasi-literal tree") 31 | } 32 | to visitQuasiPatternExpr(optOriginal, index) { 33 | throw("found quasi-pattern node $optOriginal in quasi-literal tree") 34 | } 35 | to visitQuasiPatternPatt(optOriginal, index) { 36 | throw("found quasi-pattern node $optOriginal in quasi-literal tree") 37 | } 38 | } 39 | 40 | return substituteVisitor 41 | } 42 | } -------------------------------------------------------------------------------- /lib/org/erights/e/elib/base/makeMessageDesc.emaker: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /lib/org/erights/e/elib/base/makeParamDesc.emaker: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /lib/org/erights/e/elib/base/makeTypeDesc.emaker: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /lib/org/erights/e/elib/base/makeValueThunk.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2007 Kevin Reid under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | interface ValueThunk :DeepFrozen guards ValueThunkStamp :DeepFrozen { 7 | to run() :any 8 | } 9 | 10 | /** Makes a thunk which returns a preexisting reference, and is pass-by-construction. */ 11 | def makeValueThunk implements DeepFrozen, ExitViaHere { # , SelflessMaker 12 | to asType() { return ValueThunk } 13 | to run(value) { 14 | def valueThunk implements ValueThunkStamp, pbc { # , Selfless 15 | /** Always returns the same, preexisting, reference. */ 16 | to run() { return value } 17 | to __optUncall() { return [makeValueThunk, "run", [value]] } 18 | to __printOn(out :TextWriter) { 19 | out.quote(makeValueThunk) 20 | out.write("(") 21 | out.quote(value) 22 | out.write(")") 23 | } 24 | } 25 | return valueThunk 26 | } 27 | /** Equivalent to makeValueThunk(null), except that it should (but does not yet) return the same thunk every time. */ 28 | to getNULL_THUNK() { 29 | # XXX should be memoized or preconstructed 30 | return makeValueThunk(null) 31 | } 32 | to __printOn(out :TextWriter) { 33 | out.write(makeValueThunk.__getAllegedType().getFQName().split("$").last()) 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /lib/org/erights/e/elib/eio/InStream.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | ( 7 | /** XXX Finish this documentation 8 | */ 9 | interface "org.erights.e.elib.eio.inStream" \ 10 | extends { 11 | /** Take up to the specified size of chunk from the stream. 12 | * 13 | * Returns (possibly a promise for) either the taken chunk, or the stream's terminator. 14 | * 15 | * takeAtMost(0) must eventually resolve even if no elements are yet available. 16 | * 17 | * A client should not invoke takeAtMost/1 before the result of a previous invocation has resolved; a stream should throw if this occurs, and must not become terminated. 18 | */ 19 | to takeAtMost(maximum :(EIO.getRange())) :vow[any] 20 | 21 | /** Communicates closure (null terminator) upstream. Not guaranteed to have any effect on future take operations. */ 22 | to close() :void 23 | 24 | /** Communicates failure (broken terminator) upstream. Not guaranteed to have any effect on future take operations. */ 25 | to fail(problem :()) :void # XXX Throwable is Java legacy 26 | }) -------------------------------------------------------------------------------- /lib/org/erights/e/elib/eio/OutStream.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def Resolver := any # XXX define properly. Is allowed to be other than a standard promise resolver. 7 | 8 | ( 9 | interface "org.erights.e.elib.eio.outStream" \ 10 | extends { 11 | /** Returns the stream's terminator if it is terminated; otherwise, a resolver which should be resolved to the next chunk, or terminator, to send out this stream. 12 | * 13 | * There may be multiple open resolvers at any time, and the stream must not deliver the elements in an order other than that of the original reserve messages. 14 | */ 15 | to reserve() :vow[nullOk[Resolver]] 16 | 17 | /** Obligates this stream to eventually deliver (i.e. not indefinitely buffer) elements up to the end of the chunk provided for the most recent reserve/0 message, and pass on the obligation to any downstream components if possible. */ 18 | to flush() :void 19 | 20 | /** Returns a promise for the stream's terminator. */ 21 | to terminates() :vow[any] 22 | }) -------------------------------------------------------------------------------- /lib/org/erights/e/elib/eio/Stream.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | ( 7 | /** XXX Finish this documentation 8 | * 9 | * A stream's 'terminator' is either null, for a normally closed stream, or broken, for a stream which has failed in some way. Termination might be propagated from the 'other side', be a communication problem, or be caused by the client performing a termination operation. The operations for sending and receiving terminations are different for InStreams and OutStreams. 10 | * 11 | * A chunk must not be null or broken. 12 | */ 13 | interface "org.erights.e.elib.eio.stream" { 14 | /** Return a guard for the chunks that this stream supplies or accepts. */ 15 | to getChunkType() :Guard 16 | 17 | # XXX consider changing getChunkType to getChunkMaker, such that you can make a mutable-buffer for takeAll, and concat and split, with it. If we do this, revise EIO.takeAll and makeSimplePipe's chunk splitting 18 | }) -------------------------------------------------------------------------------- /lib/org/erights/e/elib/oldeio/makeTextWriter.emaker: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /lib/org/erights/e/elib/oldeio/makeUnQuote.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | # XXX EventuallyDeepFrozen needs to be made prettier 7 | def EventuallyDeepFrozen :()[DeepFrozen."eventually"()] := DeepFrozen."eventually"() 8 | 9 | def makeUnQuote implements EventuallyDeepFrozen, ExitViaHere { 10 | 11 | /** For DeepFrozen#eventually */ 12 | method __optSealedDispatch(brand) :any { 13 | if (brand == EventuallyDeepFrozen.getPeekBrand()) { 14 | EventuallyDeepFrozen.getPeekSealer().seal(meta.getState()) 15 | } 16 | } 17 | 18 | to run(text :Twine) { 19 | def unQuote implements DeepFrozen { 20 | to __printOn(out :TextWriter) { 21 | out.print(text) 22 | } 23 | 24 | # XXX indirect self-reference for DF auditing 25 | to __optUncall() { return [, "run", [text]] } 26 | } 27 | return unQuote 28 | } 29 | } -------------------------------------------------------------------------------- /lib/org/erights/e/elib/ref/makeProxy.emaker: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /lib/org/erights/e/elib/ref/makeRedirector.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2002 Combex, Inc. under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def OneArgFunc :DeepFrozen := 7 | 8 | /** Wraps a Resolver in a way suitable for inclusion as an argument in a __whenMoreResolved message. 9 | * 10 | * Turns the first response such an argument may get into a resolution of the Resolver, and then become inoperative. 11 | * 12 | * @author Mark S. Miller 13 | */ 14 | def makeRedirector(resolver) implements DeepFrozen, ExitViaHere { 15 | 16 | # Dropped after the redirector is used. 17 | var myOptResolver := resolver 18 | 19 | return def redirector implements OneArgFunc { 20 | /** Resolve the Resolver to the arg. */ 21 | to run(arg :any) :void { 22 | if (null != myOptResolver) { 23 | myOptResolver.resolve(arg) 24 | myOptResolver := null 25 | } 26 | } 27 | 28 | /** 29 | * Smash the Resolver with the arg. 30 | */ 31 | to __reactToLostClient(problem) :void { 32 | if (null != myOptResolver) { 33 | myOptResolver.smash(problem) 34 | myOptResolver := null 35 | } 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /lib/org/erights/e/elib/sealing/makeBrand.emaker: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /lib/org/erights/e/elib/serial/Data.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def Data0 := 7 | /** Data: The object is either PassByCopy or a standard graph exit and all of its components (per standard uncalls) are Data. 8 | 9 | This guard's result is always == to the specimen. */ 10 | def Data implements DeepFrozen, ExitViaHere { 11 | to coerce(specimen, optEjector) { 12 | # XXX should be a FlexSet but they aren't implemented yet 13 | def seen := [].asMap().diverge() 14 | 15 | def recur(x) { 16 | if (!seen.maps(x)) { 17 | seen.put(x, null) 18 | switch (x) { 19 | match list :List ? (x == list && list !~ _ :String) { 20 | for sub in list { recur(sub) } 21 | } 22 | match _ { 23 | if (!(Ref.isPassByCopy(x) || StandardGraphExit.passes(x))) { 24 | throw.eject(optEjector, `$specimen is not Data because $x is not`) 25 | } 26 | recur(x.__optUncall()) 27 | } 28 | } 29 | } 30 | } 31 | 32 | recur(specimen) 33 | return specimen 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /lib/org/erights/e/elib/serial/PassByCopy.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def PassByCopy0 implements DeepFrozen, ExitViaHere { 7 | to __printOn(out :TextWriter) :void { 8 | out.print("PassByCopy") 9 | } 10 | 11 | to audit(_) :boolean { 12 | throw("PassByCopy auditing not implemented") 13 | } 14 | 15 | to coerce(specimen, optEjector) :any { 16 | # XXX make BaseGuard provide this coercion pattern 17 | return \ 18 | if (Ref.isPassByCopy(specimen)) { 19 | specimen 20 | } else if (Ref.isPassByCopy( 21 | def coerced := specimen.__conformTo(PassByCopy0))) { 22 | coerced 23 | } else { 24 | throw.eject(optEjector, `not PassByCopy: $specimen`) 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /lib/org/erights/e/elib/serial/PassByProxy.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def PassByProxy implements DeepFrozen, ExitViaHere { 7 | to __printOn(out :TextWriter) :void { 8 | out.print("PassByProxy") 9 | } 10 | 11 | to coerce(specimen, optEjector) :any { 12 | # XXX make BaseGuard provide this coercion pattern 13 | return \ 14 | if (!Ref.isPBC(specimen)) { 15 | specimen 16 | } else if (!Ref.isPBC( 17 | def coerced := specimen.__conformTo(PassByProxy))) { 18 | coerced 19 | } else { 20 | throw.eject(optEjector, `not PassByProxy: $specimen`) 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /lib/org/erights/e/elib/serial/makeRemoteCall.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | /** Currently, this exists only to make serial.makeUncaller import successfully. 7 | * 8 | * XXX is this in JavaE a remnant of JOSS serialization or is it useful? */ 9 | def makeRemoteCall implements DeepFrozen, ExitViaHere { 10 | to optUncall(specimen) {} 11 | } -------------------------------------------------------------------------------- /lib/org/erights/e/elib/slot/Map.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | pragma.enable("accumulator") 7 | 8 | def simplifyFQName :DeepFrozen := 9 | 10 | def ConstMap :DeepFrozen := 11 | 12 | interface MapGuard :DeepFrozen guards MapGuardStamp :DeepFrozen {} 13 | 14 | def Map0 implements MapGuardStamp, DeepFrozen, ExitViaHere { 15 | to __printOn(out :TextWriter) { 16 | out.print("Map") 17 | } 18 | 19 | to coerce(specimen, optEjector) { 20 | return ConstMap.coerce(specimen, optEjector) 21 | } 22 | 23 | to get(keyGuard, valueGuard) { 24 | def Map1 implements MapGuardStamp { 25 | 26 | to coerce(var specimen, optEjector) { 27 | specimen := Map0.coerce(specimen, optEjector) 28 | 29 | # XXX we need a more efficient way of doing this which doesn't require accumulating a new map for non-coercing cases 30 | return accum [].asMap() for subKey => subValue in specimen { 31 | _.with(keyGuard .coerce(subKey, optEjector), 32 | valueGuard.coerce(subValue, optEjector)) 33 | } 34 | } 35 | 36 | to getKeyGuard() { return keyGuard } 37 | to getValueGuard() { return valueGuard } 38 | to getValGuard() { return valueGuard } # XXX EoJ compatibility 39 | 40 | to __printOn(out :TextWriter) { 41 | out.print("Map[") 42 | out.quote(keyGuard) 43 | out.print(", ") 44 | out.quote(valueGuard) 45 | out.print("]") 46 | } 47 | } 48 | 49 | return Map1 50 | } 51 | 52 | to getKeyGuard() { return any } 53 | to getValueGuard() { return any } 54 | 55 | to "match__get/2"(specimen, ejector) { 56 | def ofKind := MapGuard.coerce(specimen, ejector) 57 | return [ofKind.getKeyGuard(), ofKind.getValueGuard()] 58 | } 59 | 60 | to getTheTrivialValue() { return [].asMap() } 61 | } -------------------------------------------------------------------------------- /lib/org/erights/e/elib/slot/Same.emaker: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/org/erights/e/elib/slot/SameAuthor.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def SameAuthor(DeepFrozenStamp, makeSameGuard) { 7 | def SameGuard := makeSameGuard.asType() 8 | 9 | /** .. Note that these guards expose the object they test for! If using this to test against a private reference, do not expose it! */ 10 | def Same implements DeepFrozenStamp { 11 | to __printOn(out :TextWriter) { 12 | out.print("Same") 13 | } 14 | 15 | # to asType() { return SameGuard } 16 | 17 | to "match__get/1"(specimen, ejector) { 18 | def ofKind := SameGuard.coerce(specimen, ejector) 19 | return [ofKind.getAllowed()] 20 | } 21 | 22 | to get(allowed) { 23 | return makeSameGuard(allowed) 24 | } 25 | } 26 | return Same 27 | } -------------------------------------------------------------------------------- /lib/org/erights/e/elib/slot/Slot.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2002 Combex, Inc. under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | ( 7 | /** 8 | * A Slot implements a potentially mutable variable as an object with a 9 | * "value" property.

10 | *

11 | * This supertype only provides the accessor function, since the setting 12 | * function is optional. 13 | * 14 | * @author Mark S. Miller 15 | */ 16 | interface "org.erights.e.elib.slot.Slot" { 17 | /** 18 | * Get the current value of the variable. 19 | */ 20 | to get() :any 21 | /** 22 | * Sets the current value of the variable to be a coercion of specimen to 23 | * a value that meets the constraints represented by this slot. 24 | *

25 | * get() will then return this value. If the variable is final 26 | * (immutable), then throw an informative exception instead. 27 | */ 28 | to put(newValue :any) :void 29 | /** 30 | * Says whether the Slot acts like a {@link FinalSlot}. 31 | */ 32 | to isFinal() :boolean 33 | }) -------------------------------------------------------------------------------- /lib/org/erights/e/elib/slot/Tuple.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | pragma.enable("accumulator") 7 | 8 | def EventuallyDeepFrozen :()[DeepFrozen."eventually"()] := DeepFrozen."eventually"() 9 | 10 | interface TupleGuard guards TupleGuardStamp {} 11 | 12 | def Tuple0 implements EventuallyDeepFrozen, ExitViaHere { 13 | method __optSealedDispatch(brand) :any { 14 | if (brand == EventuallyDeepFrozen.getPeekBrand()) { 15 | EventuallyDeepFrozen.getPeekSealer().seal(meta.getState()) 16 | } 17 | } 18 | 19 | to __printOn(out :TextWriter) { 20 | out.print("Tuple") 21 | } 22 | 23 | to "match__of/1"(specimen, ejector) { 24 | def ofKind := TupleGuard.coerce(specimen, ejector) 25 | return [ofKind.getElementGuards()] 26 | } 27 | 28 | to of(elementGuards) { 29 | return def Tuple1 implements EventuallyDeepFrozen, TupleGuardStamp { 30 | method __optSealedDispatch(brand) :any { 31 | if (brand == EventuallyDeepFrozen.getPeekBrand()) { 32 | EventuallyDeepFrozen.getPeekSealer().seal(meta.getState()) 33 | } 34 | } 35 | 36 | to __printOn(out :TextWriter) { 37 | out.quote(Tuple0) 38 | out.quote(elementGuards) 39 | } 40 | 41 | to getElementGuards() { return elementGuards } 42 | 43 | to coerce(specimen, optEjector) { 44 | # XXX should we do specimen.__conformTo(Tuple1)? As it is, the specimen cannot tell it's coercing to a List-of-specific-element-type. 45 | def trueList := List.coerce(specimen, optEjector) 46 | 47 | if (trueList.size() != elementGuards.size()) { 48 | throw.eject(optEjector, `Need ${elementGuards.size()} element list: ${E.toQuote(trueList)}`) 49 | } else { 50 | return accum [] \ 51 | for i => element in trueList { 52 | _.with(elementGuards[i].coerce(element, optEjector)) 53 | } 54 | } 55 | } 56 | } 57 | } 58 | 59 | match [=="get", elementGuards] { Tuple0.of(elementGuards) } 60 | } -------------------------------------------------------------------------------- /lib/org/erights/e/elib/slot/finalSlotGuardSugar.emaker: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/org/erights/e/elib/slot/finalSlotGuardSugarAuthor.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def ZeroAuditor { to audit(_) { return false }} 7 | 8 | def finalSlotGuardSugarAuthor(DeepFrozenStamp, TransparentStamp) { 9 | def FinalSlotPGuardStamp { to audit(_) { return true }} 10 | def FinalSlotPGuard { 11 | to coerce(sp, ej) { 12 | if (__auditedBy(FinalSlotPGuardStamp, sp)) { 13 | return sp 14 | } else { 15 | throw.eject(ej, "not a FinalSlot[_] guard") 16 | } 17 | } 18 | } 19 | 20 | #var sugarRootLazy match msg { E.callWithPair(sugarRootLazy := , msg) } -- XXX doesn't work because var-obj isn't yet supported 21 | var sugarRootLazy := null 22 | sugarRootLazy := def sugarRootThunk match msg { E.callWithPair(sugarRootLazy := , msg) } 23 | 24 | return def finalSlotGuardSugar extends sugarRootLazy implements DeepFrozenStamp, ExitViaHere { 25 | 26 | to getValueGuard() { return any } 27 | 28 | to "instance_match__get/1"(self, specimen, ejector) { 29 | return [FinalSlotPGuard.coerce(specimen, ejector).getValueGuard()] 30 | } 31 | 32 | to instance_get(self, valueGuard) { 33 | return def FinalSlotP implements DeepFrozen.isDeepFrozen(valueGuard).pick(DeepFrozenStamp, ZeroAuditor), FinalSlotPGuardStamp, Selfless, TransparentStamp { 34 | to __optUncall() { 35 | return [.asType(), "get", [valueGuard]] 36 | } 37 | 38 | to __printOn(out :TextWriter) { 39 | out.quote(self) 40 | out.print("[") 41 | out.quote(valueGuard) 42 | out.print("]") 43 | } 44 | 45 | to getValueGuard() { return valueGuard } 46 | 47 | to coerce(specimen, ejector) { 48 | return __makeFinalSlot(valueGuard.coerce( 49 | self.coerce(specimen, ejector).get(), 50 | ejector)) 51 | } 52 | } 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /lib/org/erights/e/elib/slot/makeBaseGuard.emaker: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /lib/org/erights/e/elib/slot/makeCoercedSlot.emaker: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /lib/org/erights/e/elib/slot/makeFinalSlot.emaker: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /lib/org/erights/e/elib/slot/makeGuardedSlot.emaker: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /lib/org/erights/e/elib/slot/makeIntersectionGuard.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | 7 | def _make(subGuards) as DeepFrozen { 8 | def intersectionGuard implements DeepFrozen."optionally"() { 9 | to __printOn(out :TextWriter) { 10 | out.print("all") 11 | out.quote(subGuards) # pun 12 | } 13 | 14 | # xxx this flattening can no longer be done trivially 15 | # to and(other) { 16 | # return (subGuards.with(other)) 17 | # } 18 | 19 | /** Audits objects with all of the subGuards, which must then be auditors. */ 20 | to audit(objectExpr, witness) { 21 | for auditor in subGuards { 22 | witness.ask(auditor) 23 | } 24 | return false 25 | } 26 | 27 | to coerce(var specimen, optEjector) { 28 | for guard in subGuards { 29 | specimen := guard.coerce(specimen, optEjector) 30 | } 31 | return specimen 32 | } 33 | } 34 | 35 | return intersectionGuard 36 | } 37 | 38 | def makeIntersectionGuard implements DeepFrozen, ExitViaHere { 39 | to run(subGuards) { return _make(subGuards) } 40 | match [=="get", subGuards] { _make(subGuards) } 41 | } 42 | 43 | # XXX unneeded check 44 | # XXX flatten check 45 | -------------------------------------------------------------------------------- /lib/org/erights/e/elib/slot/makeLazySlot.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2004 Hewlett Packard, Inc. under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.8") 5 | 6 | # Modified by Kevin Reid on 2005-03-14: 7 | # * Safe against nonlocal exits by the value maker 8 | # * makeLazySlot is DeepFrozen 9 | 10 | def Slot :DeepFrozen := 11 | 12 | def makeLazySlot implements DeepFrozen, ExitViaHere { 13 | to run(maker) :Slot { 14 | var getter := null 15 | 16 | def firstGetter() :any { 17 | def v 18 | getter := fn { v } 19 | try { 20 | bind v := maker() 21 | } catch p { 22 | v__Resolver.resolveRace(getter := Ref.broken(p)) 23 | throw(p) 24 | } finally { 25 | if (!Ref.isResolved(v)) { 26 | v__Resolver.resolveRace(getter := 27 | Ref.broken("nonlocal exit by lazy slot's maker")) 28 | } 29 | } 30 | return v 31 | } 32 | getter := firstGetter 33 | 34 | def lazySlot implements Slot { 35 | to get() :any { return getter() } 36 | to put(_) :void { throw("this lazy Slot may not be changed") } 37 | to isFinal() :boolean { return true } 38 | } 39 | return lazySlot 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /lib/org/erights/e/elib/slot/makeNegatedGuard.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | 7 | def makeException :DeepFrozen := 8 | def ncfTypes :DeepFrozen := [meta.context().getFQNPrefix() + "NegatedCoercionFailure"] 9 | def makeNegatedCoercionFailure(specimen, guard) as DeepFrozen { 10 | return makeException(ncfTypes, [=> specimen, => guard], 11 | def ncfPrinter implements DeepFrozen { 12 | to run(tw :TextWriter, e ? (e._getProperties() =~ [=> specimen, => guard])) { 13 | tw.write("problem: ") 14 | tw.quote(specimen) 15 | tw.write(" must not be a ") # XXX aan 16 | tw.quote(guard) 17 | } 18 | }) 19 | } 20 | 21 | def _make(subGuard) as DeepFrozen { 22 | def negatedGuard { 23 | to __printOn(out :TextWriter) { 24 | out.write("Not[") 25 | out.quote(subGuard) 26 | out.write("]") 27 | } 28 | 29 | to coerce(specimen, optEjector) { 30 | def coerceReturn := __return 31 | 32 | subGuard.coerce(specimen, def negatedGuardSuccess(_) { 33 | coerceReturn(specimen) 34 | }) 35 | 36 | # If we reach here, then the subGuard did not fail, so we do. 37 | # XXX reveals the subGuard to the ejector: is this OK? subguards *often* reveal themselves (__conformTo(guard)), to their specimens, but not always. 38 | throw.eject(optEjector, makeNegatedCoercionFailure(specimen, subGuard)) 39 | } 40 | } 41 | 42 | return negatedGuard 43 | } 44 | 45 | def makeNegatedGuard implements DeepFrozen, ExitViaHere { 46 | # maker usage 47 | to run(subGuard) { return _make(subGuard) } 48 | # parameterized-guard usage 49 | to get(subGuard) { return _make(subGuard) } 50 | } 51 | 52 | # XXX unneeded check 53 | # XXX flatten check 54 | -------------------------------------------------------------------------------- /lib/org/erights/e/elib/slot/makeUnionGuard.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def EventuallyDeepFrozen :()[DeepFrozen."eventually"()] := DeepFrozen."eventually"() 7 | 8 | interface UnionGuard :DeepFrozen guards UnionGuardStamp :DeepFrozen {} 9 | 10 | def makeUnionGuard implements DeepFrozen, ExitViaHere { 11 | to run(subGuards) { 12 | def unionGuard implements EventuallyDeepFrozen, UnionGuardStamp { 13 | method __optSealedDispatch(brand) :any { 14 | if (brand == EventuallyDeepFrozen.getPeekBrand()) { 15 | EventuallyDeepFrozen.getPeekSealer().seal(meta.getState()) 16 | } 17 | } 18 | 19 | to __printOn(out :TextWriter) { 20 | out.print(any) 21 | # XXX list syntax pun 22 | out.quote(subGuards) 23 | } 24 | 25 | # xxx this flattening can no longer be done trivially 26 | # to or(other) { 27 | # return (subGuards.with(other)) 28 | # } 29 | 30 | to coerce(specimen, optEjector) { 31 | for guard in subGuards { 32 | return guard.coerce(specimen, __continue) 33 | } 34 | # XXX this is unlike Java-E's UnionGuard, but provides a more informative message, but hides information about individual failures. fix this once we have fancy exception structure. 35 | throw.eject(optEjector, `doesn't match any of $subGuards`) 36 | } 37 | 38 | to getChoices() { return subGuards } 39 | } 40 | 41 | return unionGuard 42 | } 43 | 44 | to "match__run/1"(specimen, ejector) { 45 | def ofKind := UnionGuard.coerce(specimen, ejector) 46 | return [ofKind.getChoices()] 47 | } 48 | } 49 | 50 | # XXX unneeded check 51 | # XXX flatten check 52 | -------------------------------------------------------------------------------- /lib/org/erights/e/elib/slot/makeVarSlot.emaker: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /lib/org/erights/e/elib/slot/nullOk.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def EventuallyDeepFrozen :()[DeepFrozen."eventually"()] := DeepFrozen."eventually"() 7 | 8 | def NullOkParamStamp :DeepFrozen := {def NullOkParamStamp implements DeepFrozen {to audit(_) { return true }}} 9 | def NullOkParam :DeepFrozen := {def NullOkParam implements DeepFrozen {to coerce(sp, ej) { if (__auditedBy(NullOkParamStamp, sp)) {return sp} else {throw.eject(ej, "Not a parameterized nullOk")}}}} 10 | 11 | def nullOk0 implements DeepFrozen, ExitViaHere { 12 | 13 | to __printOn(out :TextWriter) :void { 14 | out.print("nullOk") 15 | } 16 | 17 | to coerce(specimen, optEjector) :any { 18 | if (specimen != null) { 19 | throw.eject(optEjector, "must be null") 20 | } 21 | } 22 | 23 | to getTheTrivialValue() { return null } 24 | 25 | to get(subGuard) { 26 | def nullOk1 implements EventuallyDeepFrozen, NullOkParamStamp { 27 | method __optSealedDispatch(brand) :any { 28 | if (brand == EventuallyDeepFrozen.getPeekBrand()) { 29 | EventuallyDeepFrozen.getPeekSealer().seal(meta.getState()) 30 | } 31 | } 32 | 33 | to __printOn(out :TextWriter) :void { 34 | # XXX print this explicitly as E-syntax sugared "get" call 35 | out.print("nullOk") 36 | out.quote([subGuard]) 37 | } 38 | 39 | to getSubGuard() { return subGuard } # XXX name 40 | 41 | to coerce(specimen, optEjector) { 42 | if (specimen == null) { 43 | return null 44 | } else { 45 | return subGuard.coerce(specimen, optEjector) 46 | } 47 | } 48 | } 49 | return nullOk1 50 | } 51 | 52 | to "match__get/1"(specimen, ejector) { 53 | def ofKind := NullOkParam.coerce(specimen, ejector) 54 | return [ofKind.getSubGuard()] 55 | } 56 | } -------------------------------------------------------------------------------- /lib/org/erights/e/elib/slot/type/Guard.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2002 Combex, Inc. under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def OneArgFunc := 7 | 8 | def Guard := 9 | ( 10 | # XXX what is a ValueGuardTemplate? 11 | /** 12 | * A Guard will either coerce an input to a value that matches some 13 | * condition, or it will fail. 14 | *

15 | * A Guard is used in the E language to guard the return value of a 16 | * method. It is also used both in E and ELib as an argument to a 17 | * ValueGuardTemplate. 18 | *

19 | * XXX Guard will also require DeepFrozen 20 | * 21 | * @author Mark S. Miller 22 | */ 23 | interface "org.erights.e.elib.slot.Guard" { 24 | 25 | /** 26 | * If specimen coerces to a value that matches the condition represented 27 | * by this guard, return that value; other fail (according to optEjector) 28 | * with a problem explaining why not. 29 | * 30 | * If optEjector is null, then throw the problem. 31 | * Otherwise, call optEjector with the problem. optEjector should 32 | * perform a non-local exit, and so should not return. 33 | * If optEjector returns anyway, then throw the problem after all. 34 | */ 35 | to coerce(specimen :any, ejector :OneArgFunc) :any 36 | 37 | /** XXX document this */ 38 | to getTheTrivialValue() :any 39 | 40 | /** Optional interface. True if the other guard's coercion results are all possible coercion results of this guard; false if any are not; null if the answer is unknown. */ 41 | to rangeSupersetOf(other :Guard) :nullOk[boolean] 42 | }) -------------------------------------------------------------------------------- /lib/org/erights/e/elib/slot/type/Slot.emaker: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /lib/org/erights/e/elib/slot/type/ValueGuard.emaker: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /lib/org/erights/e/elib/tables/makeConstList.emaker: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/org/erights/e/elib/tables/makeConstMap.emaker: -------------------------------------------------------------------------------- 1 | __makeMap 2 | -------------------------------------------------------------------------------- /lib/org/erights/e/elib/tables/makeFlexMap.emaker: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/org/erights/e/elib/tables/makeTraversalKey.emaker: -------------------------------------------------------------------------------- 1 | pragma.syntax("0.9") 2 | __equalizer.makeTraversalKey -------------------------------------------------------------------------------- /lib/org/erights/e/elib/tables/type/ConstList.emaker: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/org/erights/e/elib/tables/type/TraversalKey.emaker: -------------------------------------------------------------------------------- 1 | Ref.broken("There is currently no TraversalKey guard available. Please let us know what you would like to use it for.") -------------------------------------------------------------------------------- /lib/org/erights/e/elib/util/OneArgFunc.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | ( 7 | interface OneArgFunc { 8 | to run(_ :any) :any 9 | }) -------------------------------------------------------------------------------- /lib/org/erights/e/elib/vat/makeQueue.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | # XXX should we instead export the CL-implemented queue that our non-threaded vat implementation used? 7 | 8 | /** Java-E rune compatibility. */ 9 | def makeQueue implements ExitViaHere { 10 | to run() { return makeQueue(any) } 11 | 12 | to run(Element) { 13 | # XXX use conses since that's what we're really doing 14 | 15 | var inn := null 16 | var out := null 17 | 18 | def queue { 19 | to enqueue(new :Element) :void { 20 | inn := [new, inn] 21 | } 22 | 23 | to optDequeue() :nullOk[Element] { 24 | if (out == null) { 25 | while (inn =~ [elem, newIn]) { 26 | inn := newIn 27 | out := [elem, out] 28 | } 29 | } 30 | return if (out =~ [elem, newOut]) { 31 | out := newOut 32 | elem 33 | } 34 | } 35 | } 36 | return queue 37 | } 38 | } -------------------------------------------------------------------------------- /lib/org/erights/e/elib/vat/makeVatAuthor.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def makeVatAuthor() implements ExitViaHere { 7 | def makeVat { 8 | to getCurrentVat() { 9 | # Utterly Wrong but we're only pretending to support multiple vats at this time 10 | return makeVat.make("headless", null) 11 | } 12 | 13 | /** runnerKind is currently ignored */ 14 | to make(runnerKind :String, optName :nullOk[String]) { 15 | def pseudoVat { 16 | to __printOn(out :TextWriter) { 17 | out.print(">") 18 | } 19 | 20 | to seed(thunc) { 21 | return thunc <- () 22 | } 23 | 24 | # ... methods 25 | } 26 | 27 | return pseudoVat 28 | } 29 | } 30 | return makeVat 31 | } -------------------------------------------------------------------------------- /lib/org/quasiliteral/astro/makeAstroTagAuthor.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def makeAstroTagAuthor(TransparentStamp :DeepFrozen) { 7 | 8 | interface AstroTag :DeepFrozen guards AstroTagStamp :DeepFrozen { 9 | # XXX ... 10 | } 11 | 12 | def makeAstroTag implements DeepFrozen { 13 | to asType() { return AstroTag } 14 | /** Unlike E-on-Java, lack of a tag code is here represented by null, rather than -1; and lack of a data type is given by use of the nullOk guard. */ 15 | to run(optTagCode :nullOk[int >= 0], tagName :String, dataGuard :Guard) { 16 | /** An AstroTag, which in this E implementation serves only as the label on a Term. See E-on-Java for further information. */ 17 | def astroTag implements Selfless, AstroTagStamp, TransparentStamp { 18 | to __optUncall() { 19 | return [makeAstroTag, "run", [optTagCode, tagName, dataGuard]] 20 | } 21 | 22 | to __printOn(tw :TextWriter) { 23 | tw.write("<") 24 | tw.print(tagName) 25 | tw.write(">") 26 | } 27 | 28 | to getTagName() { return tagName } 29 | to getOptTagCode() { return optTagCode } 30 | to getDataGuard() { return dataGuard } 31 | 32 | /** Compare on tag names regardless of schema or tag codes. [XXX justify this] */ 33 | to op__cmp(other :AstroTag) { return tagName.op__cmp(other.getTagName()) } 34 | # to isTagForData 35 | } 36 | return astroTag 37 | } 38 | } 39 | return makeAstroTag 40 | } 41 | -------------------------------------------------------------------------------- /lib/org/quasiliteral/astro/makeBaseAstroBuilder.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | pragma.enable("accumulator") 6 | 7 | def EventuallyDeepFrozen :()[DeepFrozen."eventually"()] := DeepFrozen."eventually"() 8 | def root :DeepFrozen := 9 | 10 | def makeAstroTag :DeepFrozen := 11 | def AstroTag :DeepFrozen := makeAstroTag.asType() 12 | 13 | def Pass :DeepFrozen := any # marker that the guarding is to be handled by another method 14 | 15 | def SourceSpan := .asType() 16 | 17 | def makeBaseAstroBuilder implements DeepFrozen, ExitViaHere { 18 | to run(self, 19 | schema, # :AstroSchema 20 | [=> BAstroArg := any, 21 | => BAstro := any]) { 22 | 23 | def baseAstroBuilder extends root[self] implements EventuallyDeepFrozen { # implements AstroBuilder 24 | method __optSealedDispatch(brand) :any { 25 | if (brand == EventuallyDeepFrozen.getPeekBrand()) { 26 | EventuallyDeepFrozen.getPeekSealer().seal(meta.getState()) 27 | } 28 | } 29 | 30 | to attr(functor :Pass, value :Pass) { 31 | return self.term(self.leafTag(schema.obtainTagForName(".attr."), null), self.term(functor, value)) 32 | } 33 | 34 | to bag(args :BAstroArg) { 35 | return self.term(self.leafTag(schema.obtainTagForName(".bag."), null), args) 36 | } 37 | 38 | #to composite(functor, data, optSpan :nullOk[SourceSpan]) { 39 | # # xxx ... 40 | #} 41 | 42 | to start(root :BAstro) { return root } 43 | 44 | to term(functor :Pass) { return self.term(functor, self.empty()) } 45 | 46 | to tuple(args :BAstroArg) { 47 | return self.term(self.leafTag(schema.obtainTagForName(".tuple."), null), args) 48 | } 49 | } 50 | 51 | return baseAstroBuilder 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /lib/org/quasiliteral/base/type/MatchMaker.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def OneArgFunc := 7 | 8 | ( 9 | interface "org.quasiliteral.base.MatchMaker" { 10 | to matchBind(args :List, specimen :any, ejector :OneArgFunc) :List 11 | }) -------------------------------------------------------------------------------- /lib/org/quasiliteral/base/type/QuasiExprParser.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2002 Combex, Inc. under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def ValueMaker := 7 | 8 | ( 9 | /** 10 | * Given a template string in the language this quasi parser understands, 11 | * parse it into a ValueMaker which will generate objects of the form the 12 | * template describes. 13 | *

14 | * The template language is a value description language augmented with 15 | * $-holes, representing values to be provided at runtime to the ValueMaker. 16 | * 17 | * @author Mark S. Miller 18 | */ 19 | interface "org.quasiliteral.base.QuasiExprParser" { 20 | 21 | /** 22 | * For the i'th $-hole, dlrHoles[i] is the position of that hole in 23 | * template, and the character at that position in template must be '$'. 24 | *

25 | * '$' characters that don't correspond to positions in dlrHoles are 26 | * treated as part of the parser's normal language rather than indicating 27 | * $-holes. 28 | */ 29 | to valueMaker(template :Twine, dlrHoles :List[int]) :ValueMaker 30 | 31 | /** 32 | * In this old format, each $-hole is represented by a substring like 33 | * '${3}' for $-hole number 3 (the fourth hole). 34 | *

35 | * '$' and '@' characters that are not holes must be doubled. 36 | * 37 | * @deprecated 38 | */ 39 | to valueMaker(template :Twine) :ValueMaker 40 | }) -------------------------------------------------------------------------------- /lib/org/quasiliteral/base/type/QuasiPatternParser.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2002 Combex, Inc. under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def MatchMaker := 7 | 8 | ( 9 | /** 10 | * Given a template string in the language this quasi parser understands, 11 | * parse it into a MatchMaker which will match objects of the form the 12 | * template describes. The template language is a value description language 13 | * augmented with $-holes and @-holes, representing values to be provided at 14 | * runtime to the MatchMaker, or values for it to extract from the specimen, 15 | * respectively. 16 | * 17 | * @author Mark S. Miller 18 | */ 19 | interface "org.quasiliteral.base.QuasiPatternParser" { 20 | 21 | /** 22 | * For the i'th $-hole, dlrHoles[i] is the position of that hole in 23 | * template, and the character at that position in template must be '$'. 24 | *

25 | * '$' characters that don't correspond to positions in dlrHoles are 26 | * treated as part of the parser's normal language rather than indicating 27 | * $-holes. Likewise for embedded '@' characters and positions in 28 | * atHoles. 29 | */ 30 | to matchMaker(template :Twine, dlrHoles :List[int], atHoles :List[int]) :MatchMaker 31 | 32 | /** 33 | * In this old format, each $-hole is represented by a substring like 34 | * '${3}' for $-hole number 3 (the fourth hole). 35 | *

36 | * Likewise for embedded '@' characters and positions in atHoles. '$' and 37 | * '@' characters that are not holes must be doubled. 38 | * 39 | * @deprecated 40 | */ 41 | to matchMaker(template :Twine) :MatchMaker 42 | }) -------------------------------------------------------------------------------- /lib/org/quasiliteral/base/type/ValueMaker.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2002 Combex, Inc. under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | ( 7 | /** 8 | * Represents a template of a value (a quasi literal value) to be filled in 9 | * by args to make an actual value. 10 | * 11 | * @author Mark S. Miller 12 | */ 13 | interface "org.quasiliteral.base.ValueMaker" { 14 | 15 | /** 16 | * Each each arg to fill in the corresponding hole, and return the 17 | * resulting value. 18 | *

19 | * It is often appropriate to think of

    20 | *
  • a ValueMaker as an expression, 21 | *
  • substitution as expression evaluation, 22 | *
  • the 'args' array as the environment, 23 | *
  • dollar-holes as variable names (actually numbers) to be looked up 24 | * in the environment, and 25 | *
  • the result as the value the expression evaluated to. 26 | *
27 | * In this sense, we can think of E's quasiliteral framework as an means 28 | * for the non-privileged extension of the expression evaluation 29 | * machinery. 30 | */ 31 | to substitute(args :List) :any 32 | }) -------------------------------------------------------------------------------- /lib/org/quasiliteral/syntax/makeFileFeeder.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def LineFeeder := .asType() 7 | 8 | /** Java-E compatibility */ 9 | def makeFileFeeder implements DeepFrozen, ExitViaHere { 10 | to run(url, reader, optOuts) { 11 | def fileFeeder implements LineFeeder { 12 | /** Not part of the proper interface, but a trick to get rune working simply. Returns the entire contents. */ 13 | to _readText() { 14 | # file readers don't actually have readText in Java-E - XXX figure out the apparent mishmash of interfaces 15 | return reader.readText() 16 | } 17 | } 18 | return fileFeeder 19 | } 20 | } -------------------------------------------------------------------------------- /lib/org/quasiliteral/syntax/makeLineFeeder.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def LineFeeder :DeepFrozen := ( 7 | /** 8 | * XXX add documentation, methods 9 | */ 10 | interface "org.quasiliteral.syntax.LineFeeder" { 11 | }) 12 | 13 | # XXX why did we ever have a maker? does some Java code import statics? 14 | 15 | /** Java-E compatibility */ 16 | def makeLineFeeder implements DeepFrozen, ExitViaHere { 17 | to asType() { return LineFeeder } 18 | } -------------------------------------------------------------------------------- /lib/org/quasiliteral/syntax/makeTwineFeeder.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def LineFeeder :DeepFrozen := .asType() 7 | 8 | /** Java-E compatibility? */ 9 | def makeTwineFeeder implements DeepFrozen, ExitViaHere { 10 | to run(twine :Twine) { 11 | def twineFeeder implements LineFeeder { 12 | /** Not part of the proper interface, but a trick to get rune working simply. Returns the entire contents. */ 13 | to _readText() { 14 | return twine 15 | } 16 | } 17 | return twineFeeder 18 | } 19 | } -------------------------------------------------------------------------------- /lib/org/quasiliteral/syntax/makeURIKit.emaker: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | pragma.syntax("0.9") 5 | 6 | def makeURIKit implements DeepFrozen, ExitViaHere { 7 | to __printOn(out :TextWriter) { 8 | out.print("") 9 | } 10 | /** Check whether the string is made up entirely of 'uric's as defined in RFC 2396. 11 | * 12 | * XXX Currently does not check that % is followed by two hex digits. */ 13 | to isURICs(s :String) { 14 | # XXX profile, check if this is too slow for its uses 15 | for c ? ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0124356789;/?:@&=+$,-_.!~*'()%".indexOf1(c) == -1) in s { 16 | return false 17 | } 18 | return true 19 | } 20 | } -------------------------------------------------------------------------------- /lib/org/quasiliteral/text/makeFirstCharSplitter.emaker: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /lisp/bordeaux-threads-patch.lisp: -------------------------------------------------------------------------------- 1 | ; Copyright 2007 Kevin Reid, under the terms of the MIT X license 2 | ; found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | (in-package :e.util) 5 | 6 | (defglobal +sole-thread+ '#:sole-thread) 7 | 8 | #+#.(cl:handler-case 9 | (cl:progn (bordeaux-threads:current-thread) '(:or)) 10 | (cl:error () '(:and))) 11 | (defmethod bordeaux-threads:current-thread () 12 | "Patch by E-on-CL." 13 | +sole-thread+) 14 | 15 | 16 | 17 | #+#.(cl:handler-case 18 | (cl:progn (bordeaux-threads:make-condition-variable) '(:or)) 19 | (cl:error () '(:and))) 20 | (progn 21 | (defclass pseudo-condition-variable () ()) 22 | (defmethod bordeaux-threads:make-condition-variable () 23 | "Patch by E-on-CL." 24 | (make-instance 'pseudo-condition-variable))) 25 | -------------------------------------------------------------------------------- /lisp/compile-options.lisp: -------------------------------------------------------------------------------- 1 | ; Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | ; found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | (in-package :cl-user) 5 | 6 | ;(pushnew :e.instrument.ref-shorten-uses *features*) 7 | 8 | ;; The presence of this feature causes method bodies to be wrapped in (apply (named-lambda "fqn#method" (...) ...) args) instead of being direct CASE clause forms. This may be helpful for backtraces, but may have a speed/space penalty. 9 | ;; Default policy is to use this under OpenMCL, since OpenMCL is poor at displaying function arguments in backtraces. 10 | #+openmcl (pushnew :e.method-lambdas *features*) 11 | 12 | ;; The presence of this feature indicates that SXHASH is known to produce inadequately varying results for FUNCTIONs. SBCL currently does this. 13 | (when (= (sxhash (lambda ())) 42) 14 | (pushnew :e.function-sxhash-inadequate *features*)) -------------------------------------------------------------------------------- /lisp/final-init.lisp: -------------------------------------------------------------------------------- 1 | ; Copyright 2006-2007 Kevin Reid, under the terms of the MIT X license 2 | ; found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | (in-package :e.knot) 5 | 6 | (let ((process (run-program "rune" '("-show") :search t :wait nil :output :stream))) 7 | (loop for line = (read-line (external-process-output-stream process) nil) 8 | while line 9 | do 10 | (let ((match (nth-value 1 (cl-ppcre:scan-to-strings "^\s*-De.home=(.*)$" line)))) 11 | (when (plusp (length match)) 12 | (e.knot:found-e-on-java-home (native-pathname (elt match 0))) 13 | (loop-finish))))) 14 | 15 | -------------------------------------------------------------------------------- /lisp/jar.lisp: -------------------------------------------------------------------------------- 1 | ; Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | ; found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | (defpackage :e.jar 5 | (:use :cl :e.elib :zip) 6 | (:documentation "Access to jar/zip files, so that we can borrow Java E's emakers.") 7 | (:export)) 8 | 9 | (in-package :e.jar) 10 | 11 | (defun open-jar (pathname) 12 | (let ((zipfile (open-zipfile pathname))) 13 | ; XXX finalizer to close zip file 14 | (e-lambda "org.cubik.cle.prim.open-jar$jar" () 15 | (:|getOpt| ((subpath 'string)) 16 | "Return a file from the jar file, or null if it does not exist. Does not yet support getting directories." 17 | (let ((zip-entry (get-zipfile-entry subpath zipfile))) 18 | (when zip-entry 19 | (e-lambda |entry| () 20 | (:|_clFileWriteDate| () 21 | "XXX this interface to be revised. 22 | The modification date of an item in a jar is that of the jar itself, for our purposes." 23 | (file-write-date pathname)) 24 | (:|getText| () 25 | (let ((data (zipfile-entry-contents zip-entry))) 26 | ;; use sbcl's if it's available, because it's exported, 27 | ;; otherwise borrow zip's internals 28 | ;; XXX use flexi-streams directly instead 29 | #+sbcl (sb-ext:octets-to-string data :external-format :ascii) 30 | #-sbcl (zip::octets-to-string data :us-ascii))) 31 | (:|getTwine| () 32 | ;; XXX imitating EoJ jar uris; review 33 | (e. (e. |entry| |getText|) 34 | |asFrom| 35 | (format nil "jar:~A!~A" pathname subpath)))))))))) -------------------------------------------------------------------------------- /lisp/lazy.lisp: -------------------------------------------------------------------------------- 1 | ; Copyright 2007 Kevin Reid, under the terms of the MIT X license 2 | ; found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | (in-package :e.elib) 5 | 6 | (defclass lazy-ref (forwarding-ref) 7 | () 8 | (:documentation "A ref which waits until it is used to determine its referent. Useful subclasses should have an EVALUATE-LAZY-REF method. 9 | 10 | Also used as the result of operations likely to be chained, e.g. [].with(1).with(2).with(3), in which case the subclass overrides e-call-dispatch for the accumulation messages (with/1 in this example) and defines evaluate-lazy-ref to peek at the chain such that the result is computed without intermediate structures.")) 11 | 12 | (defmethod print-object ((ref lazy-ref) stream) 13 | ;; override method on REF, which performs ref-state and therefore would collapse the node unnecessarily 14 | (print-unreadable-object (ref stream :type t :identity t))) 15 | 16 | (defgeneric evaluate-lazy-ref (ref)) 17 | 18 | (defmethod %ref-shorten ((ref lazy-ref)) 19 | ;; XXX make robust against errors (convert to broken or kill vat) 20 | (let ((value (ref-shorten (evaluate-lazy-ref ref)))) 21 | (change-class ref 'resolved-ref :target value) 22 | value)) 23 | 24 | 25 | (defclass thunk-lazy-ref (lazy-ref) 26 | ((tlr-thunk :initarg :thunk :reader tlr-thunk))) 27 | 28 | (defmethod evaluate-lazy-ref ((ref thunk-lazy-ref)) 29 | (funcall (tlr-thunk ref))) 30 | 31 | 32 | (defclass with-node (lazy-ref) 33 | ((base :initarg :base :reader with-node-base))) 34 | -------------------------------------------------------------------------------- /lisp/lisp-test.lisp: -------------------------------------------------------------------------------- 1 | ; Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | ; found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | (cl:defpackage :e.lisp-test 5 | (:use :cl 6 | #+e.sb-rt :sb-rt #-e.sb-rt :rt 7 | :e.elib) 8 | (:export :system-test 9 | 10 | :collect-mismatches)) 11 | (cl:in-package :e.lisp-test) 12 | (export 'deftest) 13 | 14 | (defun test-once (system) 15 | (rem-all-tests) 16 | (let ((*package* #.*package*)) 17 | (map nil #'load 18 | (remove-if (lambda (p) (e.util:without-prefix (pathname-name p) ".")) 19 | (directory 20 | (merge-pathnames 21 | (make-pathname :name :wild 22 | :type "tlisp" 23 | :directory '(:relative "ltests")) 24 | (asdf:component-pathname system)))))) 25 | (do-tests)) 26 | 27 | (defun system-test (op system) 28 | "Invoked by an implementation of asdf:test-op." 29 | (declare (ignore op)) 30 | (with-simple-restart (continue "Proceed as if the lisp-side tests passed.") 31 | (loop 32 | (with-simple-restart (:retry "Retry the lisp-side tests.") 33 | (if (test-once system) 34 | (return) 35 | (error "Some tests failed."))))) 36 | (fresh-line) 37 | (rem-all-tests)) 38 | 39 | ;;; --- Utilities for tests --- 40 | 41 | (defun collect-mismatches (test key-1 key-2 inputs) 42 | "For each element of INPUTS, apply KEY-1 and KEY-2 to the element. Return a list of triples of element from INPUTS, result of KEY-1, and result of KEY-2, for each element where TEST yields false given the results of KEY-1 and KEY-2." 43 | (loop for input #-sbcl #-sbcl in (coerce inputs 'list) 44 | #+sbcl #+sbcl #+sbcl #+sbcl #+sbcl being the elements of inputs 45 | for a = (funcall key-1 input) 46 | for b = (funcall key-2 input) 47 | unless (funcall test a b) 48 | collect (list input a b))) 49 | -------------------------------------------------------------------------------- /lisp/random.lisp: -------------------------------------------------------------------------------- 1 | ; Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | ; found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | (in-package :e.elib) 5 | 6 | (def-vtable random-state 7 | (:|__printOn| (this (out +the-text-writer-guard+)) 8 | (with-standard-io-syntax 9 | (e. out |write| (prin1-to-string this)))) 10 | (:|nextSwiss| (this) 11 | (random +swiss-upper-bound+ this)) 12 | (:|nextInt| (this range) 13 | (random range this)) 14 | (:|diverge| (this) 15 | (make-random-state this))) -------------------------------------------------------------------------------- /lisp/runner-late.lisp: -------------------------------------------------------------------------------- 1 | ; Copyright 2007 Kevin Reid, under the terms of the MIT X license 2 | ; found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | (in-package :e.elib) 5 | 6 | (def-shorten-methods vr-add-io-handler 4) 7 | (def-shorten-methods vr-remove-io-handler 1) 8 | 9 | (defmethod make-runner-for-this-thread (&rest initargs &key &allow-other-keys) 10 | (locally ; sb-pcl is confused otherwise 11 | (declare #+sbcl (sb-ext:muffle-conditions sb-ext:code-deletion-note)) 12 | (apply #'make-instance 13 | (or #+(or sbcl cmu) 'serve-event-runner 14 | 'runner) 15 | initargs))) 16 | -------------------------------------------------------------------------------- /lisp/runner.lisp: -------------------------------------------------------------------------------- 1 | ; Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | ; found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | (in-package :e.elib) 5 | 6 | ;;; --- Runner protocol --- 7 | 8 | (defgeneric enqueue-turn (context function) 9 | (:documentation "Must be safe for being called from the wrong thread.")) 10 | 11 | ;;; XXX what does vr- stand for? 12 | (defgeneric vr-add-io-handler (context target direction function)) 13 | 14 | (defgeneric vr-remove-io-handler (handler)) 15 | 16 | (defgeneric enqueue-timed (context time func)) 17 | 18 | (defgeneric runner-loop (runner)) 19 | 20 | (defgeneric make-runner-for-this-thread (&key label)) 21 | 22 | (defvar *runner* nil) 23 | 24 | (defun top-loop () 25 | (runner-loop *runner*)) 26 | 27 | ;;; --- Basic runner --- 28 | 29 | (defclass runner () 30 | ((label :initarg :label 31 | :initform nil 32 | :type (or null string) 33 | :reader label) 34 | (sends :type queue 35 | :reader %runner-queue 36 | :initform (make-instance 'queue)))) 37 | 38 | (defmethod enqueue-turn ((runner runner) function) 39 | ;; relies on the send queue being thread-safe if applicable 40 | (enqueue (%runner-queue runner) function) 41 | (values)) 42 | 43 | (defmethod runner-loop ((runner runner)) 44 | (assert (eql runner *runner*)) 45 | (let ((queue (%runner-queue runner))) 46 | (loop 47 | (if (queue-null queue) 48 | (break "Ran out of things to do in ~S." runner) 49 | (funcall (dequeue queue)))))) 50 | -------------------------------------------------------------------------------- /lisp/universal.lisp: -------------------------------------------------------------------------------- 1 | ;;; Used for file compilation of E code without writing to a temporary .lisp file. 2 | 3 | (in-package :e.compiler) 4 | 5 | (macrolet ((it () 6 | *efasl-program*)) 7 | (it)) -------------------------------------------------------------------------------- /ltests/boolean.tlisp: -------------------------------------------------------------------------------- 1 | ; Copyright 2007 Kevin Reid, under the terms of the MIT X license 2 | ; found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | (defpackage :e.lisp-test.boolean 5 | (:use :cl :e.lisp-test :e.elib)) 6 | (in-package :e.lisp-test.boolean) 7 | 8 | (deftest boolean.same-coercion 9 | ;; test that e-is-true coerces in the usual way 10 | (collect-mismatches 11 | #'samep 12 | #'e-is-true 13 | (lambda (x) (e-is-true (e-coerce x 'e-boolean))) 14 | (list +e-true+ 15 | +e-false+ 16 | (make-instance 'e-boolean #| a bogus boolean |#) 17 | (e-lambda "$becomesBoolean" () 18 | (:|__conformTo| (guard) 19 | (declare (ignore guard)) 20 | +e-true+)))) 21 | ()) -------------------------------------------------------------------------------- /ltests/eq.tlisp: -------------------------------------------------------------------------------- 1 | ; Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | ; found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | (defpackage :e.lisp-test.eq 5 | (:use :cl :e.lisp-test :e.elib)) 6 | (cl:in-package :e.lisp-test.eq) 7 | 8 | (import 'e.elib::fast-sameness-test #.*package*) 9 | 10 | 11 | (defun resembles-constantly (value function) 12 | "returns T or the non-'constantly' function" 13 | (or (and (not (member function '(#.#'eql #.#'eq #.#'equal))) 14 | (eql value (funcall function 'foo 'bar 'baz 'whatever 1 2 3 4 5))) 15 | function)) 16 | 17 | 18 | (deftest fast-sameness-test.general 19 | (fast-sameness-test 't 't) 20 | #.#'samep) 21 | 22 | #-abcl ;; as of 0.0.9, ABCL's subtypep isn't smart enough for this 23 | (deftest fast-sameness-test.disjoint-eql 24 | (resembles-constantly nil (fast-sameness-test 'integer 'float)) 25 | t) 26 | 27 | (deftest fast-sameness-test.function-general 28 | (fast-sameness-test 'function 't) 29 | #.#'samep) 30 | 31 | (deftest fast-sameness-test.symbol-general 32 | (fast-sameness-test 'symbol 't) 33 | #.#'samep) 34 | 35 | (deftest fast-sameness-test.symbol 36 | (fast-sameness-test 'symbol 'symbol) 37 | #.#'eq) 38 | 39 | #-abcl ;; as of 0.0.9, ABCL's subtypep isn't smart enough for this 40 | (deftest fast-sameness-test.disjoint-general 41 | (resembles-constantly nil (fast-sameness-test 'symbol 'function)) 42 | t) 43 | 44 | (deftest fast-sameness-test.subrange-right 45 | (fast-sameness-test 'character '(member #\a)) 46 | #.#'eql) 47 | 48 | (deftest fast-sameness-test.subrange-left 49 | (fast-sameness-test 'bit 'integer) 50 | #.#'eql) 51 | -------------------------------------------------------------------------------- /ltests/fqn.tlisp: -------------------------------------------------------------------------------- 1 | ; Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | ; found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | (defpackage :e.lisp-test.fqn 5 | (:use :cl :e.lisp-test :e.elib)) 6 | (cl:in-package :e.lisp-test.fqn) 7 | 8 | (defmacro with-path (path-form &body body &aux (path-var (gensym))) 9 | `(let* ((,path-var ,path-form) 10 | (*compile-file-truename* ,path-var) 11 | (*load-truename* ,path-var)) 12 | ,@body)) 13 | 14 | (defun fqn-of (x) (e. (e. x |__getAllegedType|) |getFQName|)) 15 | 16 | (deftest fqn.default 17 | (fqn-of (with-path nil 18 | (eval `(e-lambda "$hello" ())))) 19 | "$hello") 20 | 21 | (deftest fqn.path 22 | (fqn-of (with-path (make-pathname :name "world") 23 | (eval `(e-lambda "$hello" ())))) 24 | "world$hello") 25 | 26 | (deftest fqn.nest 27 | (fqn-of (efuncall 28 | (with-path (make-pathname :name "world") 29 | (eval `(e-lambda "$hello" () (:|run| () (e-lambda "$sub" ()))))))) 30 | "world$hello$sub") 31 | -------------------------------------------------------------------------------- /ltests/knot.tlisp: -------------------------------------------------------------------------------- 1 | ; Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | ; found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | (defpackage :e.lisp-test.knot 5 | (:use :cl :e.lisp-test :e.elib :e.knot)) 6 | (in-package :e.lisp-test.knot) 7 | 8 | (deftest lazy.1 9 | (let ((slot (e.knot::make-lazy-apply-slot (lambda () (error "biff"))))) 10 | (flet ((foo () (handler-case 11 | (e. slot |get|) 12 | (error (c) 13 | (princ-to-string c))))) 14 | (values (foo) 15 | (foo)))) 16 | "biff" 17 | "biff") -------------------------------------------------------------------------------- /ltests/queues.tlisp: -------------------------------------------------------------------------------- 1 | ; Copyright 2007 Kevin Reid, under the terms of the MIT X license 2 | ; found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | (defpackage :e.test.util 5 | (:use :cl :e.lisp-test :bordeaux-threads :e.util)) 6 | (in-package :e.test.util) 7 | 8 | (when (handler-case 9 | (progn (make-thread (lambda ()) :name "threading existence test") 10 | t) 11 | (error () nil)) 12 | 13 | (deftest queue-unblocks 14 | (let ((q (make-instance 'queue))) 15 | (make-thread (lambda () (sleep 1) (enqueue q 1))) 16 | (dequeue-blocking q)) 17 | 1) 18 | 19 | #||#) ; end WHEN threads available 20 | -------------------------------------------------------------------------------- /ltests/sugar-delegate.tlisp: -------------------------------------------------------------------------------- 1 | ; Copyright 2007 Kevin Reid, under the terms of the MIT X license 2 | ; found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | (cl:in-package :e.lisp-test) 5 | 6 | (defmacro with-vat-1 (&body b) 7 | `(block nil 8 | (with-vat (:label ,(format nil "with-vat-1 form: ~S" b)) 9 | (return (progn ,@b))))) 10 | 11 | (defclass sugar-call-test () ()) 12 | (defclass sugar-fail-test () ()) 13 | 14 | (defmethod e-call-match (fail (rec sugar-call-test) mverb &rest args) 15 | (apply #'sugar-cache-call fail rec mverb 'sugar-call-test "org.cubik.cle.test.testSugar" args)) 16 | 17 | (defmethod e-call-match (fail (rec sugar-fail-test) mverb &rest args) 18 | (apply #'sugar-cache-call fail rec mverb 'sugar-fail-test "org.cubik.cle.test.nonexistentSugar" args)) 19 | 20 | (deftest sugar-call.simple 21 | (with-vat-1 (e. (make-instance 'sugar-call-test) |foo| "bar")) 22 | #("" "baz" "bar")) 23 | 24 | (deftest sugar-call.responds.true 25 | (with-vat-1 (e. (make-instance 'sugar-call-test) |__respondsTo| "foo" 1)) 26 | #.+e-true+) 27 | 28 | (deftest sugar-call.responds.false 29 | (with-vat-1 (e. (make-instance 'sugar-call-test) |__respondsTo| "bar" 1)) 30 | #.+e-false+) 31 | 32 | ;; XXX test existant sugar __getAllegedType 33 | 34 | (deftest sugar-call.fail.simple 35 | (with-vat-1 36 | (handler-case 37 | (e. (make-instance 'sugar-fail-test) |foo| "bar") 38 | (no-such-method-error () 'no-such-method))) 39 | no-such-method) 40 | 41 | (deftest sugar-call.fail.responds 42 | (with-vat-1 (e. (make-instance 'sugar-fail-test) |__respondsTo| "foo" 1)) 43 | #.+e-false+) 44 | 45 | (deftest sugar-call.fail.alleged 46 | (with-vat-1 (remove-if (lambda (x) (e.util:without-prefix x "__")) (e. (e. (e. (make-instance 'sugar-fail-test) |__getAllegedType|) |getMessageTypes|) |getKeys|))) 47 | #()) 48 | 49 | -------------------------------------------------------------------------------- /ltests/thread.tlisp: -------------------------------------------------------------------------------- 1 | ; Copyright 2007 Kevin Reid, under the terms of the MIT X license 2 | ; found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | (defpackage :e.test.util 5 | (:use :cl :e.lisp-test :bordeaux-threads :e.util)) 6 | (in-package :e.test.util) 7 | 8 | (deftest t-current-thread 9 | (collect-mismatches #'equal #'identity #'identity 10 | (list (list (current-thread) 11 | (current-thread)))) 12 | nil) 13 | 14 | (deftest t-make-condition-variable 15 | (progn (make-condition-variable) 16 | t) 17 | t) 18 | -------------------------------------------------------------------------------- /ltests/util.tlisp: -------------------------------------------------------------------------------- 1 | ; Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | ; found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | (cl:in-package :e.lisp-test) 5 | 6 | ;; NOTE: this file is hardly complete - it was just written to test the test framework 7 | 8 | (deftest defglobal.simple 9 | (let ((s (gensym))) 10 | (handler-bind ((warning #'muffle-warning)) 11 | (values (eval `(ignore-errors ,s)) 12 | (eval `(eql (e.util:defglobal ,s 44) ',s)) 13 | (eval `,s)))) 14 | nil 15 | t 16 | 44) 17 | 18 | (deftest without-suffix.empty-string 19 | (e.util:without-suffix "" "a") 20 | nil) 21 | 22 | (deftest without-suffix.empty-both 23 | (e.util:without-suffix "" "") 24 | "") 25 | 26 | (deftest without-suffix.empty-fix 27 | (e.util:without-suffix "quux" "") 28 | "quux") 29 | 30 | (deftest without-suffix.suffix 31 | (e.util:without-suffix "adfbce" "ce") 32 | "adfb") 33 | 34 | (deftest without-suffix.infix 35 | (e.util:without-suffix "adfbceg" "ce") 36 | nil) 37 | 38 | (deftest without-suffix.prefix 39 | (e.util:without-suffix "ceadfb" "ce") 40 | nil) 41 | 42 | (deftest without-prefix.empty-string 43 | (e.util:without-prefix "" "a") 44 | nil) 45 | 46 | (deftest without-prefix.empty-both 47 | (e.util:without-prefix "" "") 48 | "") 49 | 50 | (deftest without-prefix.empty-fix 51 | (e.util:without-prefix "quux" "") 52 | "quux") 53 | 54 | (deftest without-prefix.suffix 55 | (e.util:without-prefix "adfbce" "ce") 56 | nil) 57 | 58 | (deftest without-prefix.infix 59 | (e.util:without-prefix "adfbceg" "ce") 60 | nil) 61 | 62 | (deftest without-prefix.prefix 63 | (e.util:without-prefix "ceadfb" "ce") 64 | "adfb") 65 | 66 | (defun leql (ab) 67 | (destructuring-bind (a b) ab 68 | (eql a b))) 69 | 70 | (deftest mangle-verb.arity 71 | (remove-if #'leql 72 | (mapcar (lambda (n) 73 | (list (e.util:mangle-verb "foo" n) 74 | (intern (format nil "~A/~A" "foo" n) "KEYWORD"))) 75 | '(0 1 2 3 4 5 6 7 8 9 10 11 12 98 99 100 101 102 1234))) 76 | ()) 77 | 78 | (deftest unmangle-verb.slashed 79 | (e.util:unmangle-verb :|foo/bar/123|) 80 | "foo/bar" 81 | 123) 82 | -------------------------------------------------------------------------------- /tests/brand.updoc: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | Testing that the makeBrand implementation is in fact DeepFrozen. Ordinary makeBrand is merely stamped DeepFrozen since it is employed by the DeepFrozen auditor. 5 | 6 | ? (DeepFrozen) 7 | # value: 8 | 9 | ? def makeBrand := 10 | # value: 11 | 12 | ? def [aSealer, aUnsealer] := makeBrand("a") 13 | # value: 14 | 15 | ? def amplifiable { 16 | > to __optSealedDispatch(brand) :any { 17 | > if (brand == aSealer.getBrand()) { 18 | > return aSealer.seal("hi") 19 | > } 20 | > } 21 | > } 22 | # value: 23 | 24 | ? def brokenAmp { 25 | > to __optSealedDispatch(brand) :any { 26 | > if (brand == aSealer.getBrand()) { 27 | > return "grr" 28 | > } 29 | > } 30 | > } 31 | # value: 32 | 33 | ? [aUnsealer.amplify(amplifiable)] 34 | # value: [["hi"]] 35 | 36 | ? [aUnsealer.amplify("unamplifiable")] 37 | # value: [null] 38 | 39 | ? [aUnsealer.amplify(brokenAmp)] 40 | # problem: "grr" is not a a sealed box 41 | 42 | XXX test basic sealing/unsealing -------------------------------------------------------------------------------- /tests/captp/SwissTable.updoc: -------------------------------------------------------------------------------- 1 | # Copyright 2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | ? pragma.syntax("0.9") 5 | 6 | ? def makeSwissTable := 7 | # value: 8 | 9 | args 2 and 3 standing in for makeWeakKeyMap and makeWeakValueMap 10 | 11 | ? def swissTable := makeSwissTable(entropy, , ) 12 | # value: 13 | 14 | Bug: getNewSwiss and lookupSwiss would not accept promises 15 | 16 | ? def p 17 | > def swiss :int := swissTable.getNewSwiss(p) ;null 18 | 19 | ? swissTable.lookupSwiss(swiss) == p 20 | # value: true 21 | 22 | Bug: null was being used as a lookup failure marker in a way that only worked in the Java version. 23 | 24 | ? def faultHandler(hash) { 25 | > println(`faulting for $hash`) 26 | > } 27 | > swissTable.addFaultHandler(faultHandler) 28 | 29 | This should fault, and fail. 30 | 31 | ? swissTable.lookupSwiss(21561735424) 32 | # stdout: faulting for 995105635960187122290482398214630504868150852438 33 | # 34 | 35 | # problem: 21561735424 not found 36 | 37 | ? def p 38 | > def swiss :int := swissTable.getNewSwiss(p) ;null 39 | > bind p := null 40 | 41 | This should not fault. 42 | 43 | ? swissTable.lookupSwiss(swiss) == p 44 | # value: true 45 | 46 | ? swissTable.removeFaultHandler(faultHandler) 47 | 48 | XXX test case: register a promise, resolve it to null, the lookupSwiss it 49 | XXX test that the weak maps are used properly 50 | XXX write more tests; this covers only specific bugs found. -------------------------------------------------------------------------------- /tests/captp/other-objects.updoc: -------------------------------------------------------------------------------- 1 | # Copyright 2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | This is a placeholder. We *should* have tests for the operation of each of these tables, but they haven't been written yet; so we just check that they instantiate successfully. 5 | 6 | ? () 7 | # value: 8 | 9 | ? () 10 | # value: 11 | 12 | ? (def makeWeakPtr {}) 13 | # value: 14 | 15 | ? (def makeWeakPtr {}, def nonceLocatorPromise {}) 16 | # value: 17 | 18 | ? (def pgt {}, 19 | > def ngt {}, 20 | > "fake-id", 21 | > def capTPMgr {}, 22 | > def swissTable {}) 23 | # value: 24 | 25 | ? ("fake-id", def swissTable {}, def capTPMgr {}) 26 | # value: 27 | -------------------------------------------------------------------------------- /tests/captp/tracer.updoc: -------------------------------------------------------------------------------- 1 | # Copyright 2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | ? pragma.syntax("0.9") 5 | 6 | ? def deSubgraphKit := ; null 7 | ? def once := ; null 8 | 9 | Utility for producing traces of CapTP communication. 10 | 11 | ? def traceMessages := 12 | # value: 13 | 14 | ? def ctrace := traceMessages(stdout.println, 15 | > def sink { match msg { stderr.println(msg) }}) 16 | # value: > 17 | 18 | --- 19 | 20 | ? ctrace.GCAnswer(-3) 21 | # stdout: GCAnswer(-3) 22 | # 23 | 24 | # stderr: ["GCAnswer", [-3]] 25 | # 26 | 27 | ? ctrace.DeliverOnly(0, "foo", 28 | > once(fn b { 29 | > b.buildRoot(b.buildCall( 30 | > b.buildImport("__makeList"), 31 | > "run", 32 | > [b.buildLiteral("bar"), 33 | > b.buildCall(b.buildImport("CapTP_1_descs"), 34 | > "Incoming", 35 | > [b.buildLiteral(2)] )]))})) 36 | # stdout: DeliverOnly(0, "foo", ["bar", IncomingDesc(2)]) 37 | # 38 | 39 | # stderr: ["DeliverOnly", [0, "foo", ["bar", IncomingDesc(2)]]] 40 | # 41 | 42 | -------------------------------------------------------------------------------- /tests/character.updoc: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | Other tests of characters (those which are related to behavior of strings) may be found in literals.updoc. 5 | 6 | ? pragma.syntax("0.9") 7 | 8 | ? 'a' :DeepFrozen 9 | # value: 'a' 10 | 11 | ? E.toString('a') 12 | # value: "a" 13 | 14 | ? E.toQuote('a') 15 | # value: "'a'" 16 | 17 | next/previous 18 | 19 | ? 'a'.next() 20 | # value: 'b' 21 | 22 | ? 'b'.previous() 23 | # value: 'a' 24 | 25 | ? pragma.enable("accumulator") 26 | 27 | ? accum ' ' for x in 1..32 { _.previous() } 28 | # value: '\u0000' 29 | 30 | ? accum ' ' for x in 1..32 { _.previous() }.previous() 31 | # problem: there is no character before '\u0000' 32 | 33 | XXX test last-character.next() 34 | 35 | comparison 36 | 37 | ? 'a' < 'b' 38 | # value: true 39 | 40 | ? 'b' < 'a' 41 | # value: false 42 | 43 | ? 'b' < 'b' 44 | # value: false 45 | 46 | ? 'Q' > ' ' 47 | # value: true 48 | 49 | ? ' ' <=> ' ' 50 | # value: true 51 | 52 | ? ' ' <=> '4' 53 | # value: false 54 | 55 | add, subtract 56 | 57 | ? 'a' + 1 58 | # value: 'b' 59 | 60 | ? 'a' + 'b' 61 | # problem: the char 'b' doesn't coerce to an int 62 | 63 | ? 'b' - 'a' 64 | # value: 1 65 | 66 | ? 'a' - 'b' 67 | # value: -1 68 | 69 | ? 'b' - 1 70 | # value: 'a' 71 | 72 | ? 'a' + def foo {} 73 | # problem: the "__main$foo" doesn't coerce to an int 74 | 75 | ? 'a' - def foo {} 76 | # problem: the "__main$foo" doesn't coerce to an any[char, int] 77 | 78 | Character <-> codepoint 79 | 80 | ? def getCharacter :DeepFrozen := 81 | # value: 82 | 83 | XXX tests of getCharacter 84 | 85 | XXX tests of characters (move from literals.updoc) 86 | XXX do we really want to diverge from makeFoo naming scheme? 87 | idea: objects which provide collection/loader interfaces (get/optUnget/optUncall), one for Unicode codepoints and one for Unicode names 88 | or: eliminate getCharacter/makeCharacter and use only '\u0000' + n -------------------------------------------------------------------------------- /tests/data.updoc: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | ? Data 5 | # value: 6 | 7 | ? 1 :Data 8 | # value: 1 9 | 10 | ? fn {} :Data 11 | # problem: <__main$_> is not Data because <__main$_> is not 12 | 13 | ? [1] :Data 14 | # value: [1] 15 | 16 | ? [fn {}] :Data 17 | # problem: [<__main$_>] is not Data because <__main$_> is not 18 | 19 | ? {def x := [1, x, 2]} :Data 20 | # value: [1, <***CYCLE***>, 2] 21 | 22 | ? {def x := [1, x, fn {}]} :Data 23 | # problem: [1, <***CYCLE***>, <__main$_>] is not Data because <__main$_> is not 24 | 25 | ? {[def x := fn {}, x]} :Data 26 | # problem: [<__main$_>, <__main$_>] is not Data because <__main$_> is not 27 | 28 | ? :Data 29 | # value: 30 | 31 | x ? e`1 + 1` :Data 32 | x # value: e`1 + 1` 33 | -------------------------------------------------------------------------------- /tests/eio.updoc: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | ? EIO 5 | # value: 6 | 7 | ? [EIO.getALL()] 8 | # value: [null] 9 | 10 | ? EIO.getRange() 11 | # value: nullOk[(int >= 0)] 12 | 13 | XXX there should be more EIO tests eventually -------------------------------------------------------------------------------- /tests/encoding.updoc: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | ? pragma.enable("dot-props") 5 | > def ALL := EIO::ALL 6 | 7 | ? def charsets :DeepFrozen := 8 | # value: 9 | 10 | ? def ascii :DeepFrozen := charsets["US-ASCII"] 11 | # value: 12 | 13 | ? ascii == charsets["us-ascii"] 14 | # value: true 15 | 16 | ? def s := ascii.decode([97, 112, 112, 108, 101, 115, 32, 97, 110, 100, 32, 111, 114, 97, 110, 103, 101, 115].asStream(), [].asMap()) 17 | # value: <-from ASCII-[97, 112, 112, 108, 101, ...].asStream() 18 | 19 | ? EIO.takeAll(s) 20 | # value: "apples and oranges" 21 | 22 | x ? def s := ascii.decode([256].asStream(), [].asMap()) 23 | x > s.read(0, ALL) 24 | x > s 25 | x # problem: octet not in ASCII encoding: 256 26 | 27 | 28 | ? def s := ascii.encode("apples and oranges".asStream(), [].asMap()) 29 | # value: <-to ASCII-"apples and oranges".asStream() 30 | 31 | ? EIO.takeAll(s) 32 | # value: [97, 112, 112, 108, 101, 115, 32, 97, 110, 100, 32, 111, 114, 97, 110, 103, 101, 115] 33 | 34 | 35 | ? def utf_8 :DeepFrozen := charsets["UTF-8"] 36 | # value: 37 | 38 | ? def s := utf_8.decode([0xE2, 0x80, 0xA2, 0x20, 0x68, 0x6f, 0x6c, 0xc3, 0xa9, 0x73].asStream(), [].asMap()) 39 | # value: <-from UTF-8-[226, 128, 162, 32, 104, ...].asStream() 40 | 41 | ? EIO.takeAll(s) 42 | # value: "• holés" 43 | 44 | ? def s := utf_8.encode("ab•cdéfअ 𐐀".asStream(), [].asMap()) 45 | # value: <-to UTF-8-"ab•cdéfअ 𐐀".asStream() 46 | 47 | ? EIO.takeAll(s) 48 | # value: [97, 98, 226, 128, 162, 99, 100, 195, 169, 102, 224, 164, 133, 32, 240, 144, 144, 128] 49 | 50 | todo: 51 | ascii range limitation 52 | coding errors, un-codable element policies 53 | case-insensitive charset names and aliases 54 | other encodings 55 | length ratio estimation 56 | test all cases of utf-8 decoding and encoding -------------------------------------------------------------------------------- /tests/exception-data.updoc: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | ? def defineException := 5 | # value: 6 | 7 | ? def makeParseError := defineException( 8 | > ["org.cubik.cle.parser.makeLALR1Parser$ParseError"], 9 | > def pePrinter implements DeepFrozen { 10 | > to run(tw :TextWriter, [=> found, => expected]) :void { 11 | > tw.write("expected one of ") 12 | > tw.quote(expected.getElements()) 13 | > tw.write(", got ") 14 | > tw.quote(found) 15 | > }}) 16 | # value: 17 | 18 | ? def e := makeParseError(["found" => "{", "expected" => [";"].asSet()]) 19 | # value: problem: expected one of [";"], got "{" 20 | 21 | ? e.getExpected() 22 | # value: [";"].asSet() 23 | 24 | ? def defineExceptionGuard := 25 | # value: 26 | 27 | ? def ParseError := defineExceptionGuard(["org.cubik.cle.parser.makeLALR1Parser$ParseError"]) 28 | # value: ParseError 29 | 30 | ? "foo" :ParseError 31 | # problem: the String "foo" doesn't coerce to an E-structure-exception 32 | XXX possible error change later 33 | 34 | ? e :ParseError 35 | # value: problem: expected one of [";"], got "{" 36 | 37 | ? e.getFound() 38 | # value: "{" 39 | 40 | ? defineException([], def _(_,_):void{})([].asMap()) :ParseError 41 | # problem: <__main$_> is not DeepFrozen 42 | -------------------------------------------------------------------------------- /tests/extend.updoc: -------------------------------------------------------------------------------- 1 | # Copyright 2006-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | 'root' is used to produce more helpful no-such-method errors in objects using delegation. Without it, the error report uses the FQN of the last object in the 'extends' chain, making it more difficult to understand the error (especially in the presence of tail-call elimination). 5 | 6 | ? def root := 7 | # value: 8 | 9 | ? def self; def r := root[self]; def a1 extends r {} 10 | # value: 11 | 12 | ? bind self := def a2 extends a1 {} 13 | # value: 14 | 15 | ? r 16 | # value: > 17 | 18 | XXX wording of message to be revised 19 | ? a2.aardvarks(9) 20 | # problem: the __main$a2 does not understand aardvarks/1 [9] 21 | -------------------------------------------------------------------------------- /tests/guard-matching.updoc: -------------------------------------------------------------------------------- 1 | ? pragma.syntax("0.9") 2 | ? pragma.enable("call-pattern") 3 | 4 | NOTE: these tests do not distinguish between pattern failures and throws. 5 | 6 | List guard 7 | 8 | ? def List[a] := List[int]; a 9 | # value: int 10 | 11 | ? def List[a] := 1 12 | # problem: not a ListGuard 13 | 14 | ? def List[a] := List; a 15 | # value: any 16 | 17 | Map guard 18 | 19 | ? def Map[a, b] := Map[near, any]; [a, b] 20 | # value: [near, any] 21 | 22 | ? def Map[a, b] := 1 23 | # problem: Not stamped by org.erights.e.elib.slot.Map$MapGuard__T 24 | 25 | ? def Map[a, b] := Map; [a, b] 26 | # value: [any, any] 27 | 28 | nullOk guard 29 | 30 | ? def nullOk[a] := nullOk[int]; a 31 | # value: int 32 | 33 | ? def nullOk[a] := nullOk; a 34 | # problem: Not a parameterized nullOk 35 | XXX this could be defined to return the 'none' guard, which doesn't exist yet 36 | 37 | Set guard 38 | 39 | ? def Set[a] := Set[int]; a 40 | # value: int 41 | 42 | ? def Set[a] := 1 43 | # problem: Not stamped by org.erights.e.elib.tables.makeConstSetAuthor$makeConstSetAuthor$ConstSetGuard__T 44 | 45 | ? def Set[a] := Set; a 46 | # value: any 47 | 48 | Tuple guard 49 | 50 | ? def t := Tuple.of([any, int]) 51 | # value: Tuple[any, int] 52 | 53 | ? def Tuple.of([a, b]) := t; [a, b] 54 | # value: [any, int] 55 | 56 | ? def Tuple.of([a]) := t 57 | # problem: a 2 size list doesn't match a 1 size list pattern 58 | 59 | ? def Tuple.of([a]) := 1 60 | # problem: Not stamped by org.erights.e.elib.slot.Tuple$TupleGuard__T 61 | 62 | ? def Tuple.of([a]) := Tuple 63 | # problem: Not stamped by org.erights.e.elib.slot.Tuple$TupleGuard__T 64 | 65 | Union guard 66 | 67 | ? def t := any.of([nullOk, int]) 68 | # value: any[nullOk, int] 69 | 70 | ? def any.of([a, b]) := t; [a, b] 71 | # value: [nullOk, int] 72 | 73 | ? def any.of([a]) := t 74 | # problem: a 2 size list doesn't match a 1 size list pattern 75 | 76 | ? def any.of([a]) := 1 77 | # problem: Not stamped by org.erights.e.elib.slot.makeUnionGuard$UnionGuard__T 78 | 79 | ? def any.of([a]) := any 80 | # problem: Not stamped by org.erights.e.elib.slot.makeUnionGuard$UnionGuard__T 81 | 82 | -------------------------------------------------------------------------------- /tests/guard-subrange.updoc: -------------------------------------------------------------------------------- 1 | # Copyright 2008 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | ? def SubrangeGuard :DeepFrozen := 5 | # value: SubrangeGuard 6 | 7 | ? def t := int; def int :([t]) := t; null 8 | (int in the safeScope is a LazyEvalSlot and doesn't reveal its value (yet?), so we rebind it as a FinalSlot. XXX this is unpleasant) 9 | 10 | ? def SGInt :DeepFrozen := SubrangeGuard[int] 11 | # value: SubrangeGuard[int] 12 | 13 | ? Selfless.passes(SGInt) 14 | # value: true 15 | 16 | ? def Gzero implements SGInt {} 17 | # problem: __main$Gzero has no coerce/2 method 18 | 19 | ? def Gnoco implements SGInt { to coerce(foo, bar) { 20 | > return foo 21 | > }} 22 | # problem: __main$Gnoco does not have a determinable result guard, but <& any> :Same[<& any>] 23 | 24 | ? def Gresult implements SGInt { to coerce(specimen, ejector) :int { 25 | > return 42 26 | > }} 27 | # value: 28 | 29 | ? def Gbroader implements SubrangeGuard[DeepFrozen] { 30 | > to coerce(specimen, ejector) :int { 31 | > return 42 32 | > }} 33 | # value: 34 | 35 | -------------------------------------------------------------------------------- /tests/lang/ENodeCopyVisitor.updoc: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | ? pragma.syntax("0.9") 5 | 6 | ? def makeENodeCopyVisitor :DeepFrozen := 7 | # value: 8 | 9 | ? == makeENodeCopyVisitor 10 | # value: true 11 | 12 | ? def simple := makeENodeCopyVisitor(simple) 13 | # value: 14 | 15 | ? simple(e`def x := 1; def [y, z] := __makeList.run(x, x); __equalizer.sameEver(x, y)`) 16 | # value: e`def x := 1 17 | # def [y, z] := __makeList.run(x, x) 18 | # __equalizer.sameEver(x, y)` 19 | 20 | -------------------------------------------------------------------------------- /tests/lazy-slot.updoc: -------------------------------------------------------------------------------- 1 | # Copyright 2004 Hewlett Packard, Inc. under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | ? def makeLazySlot := 5 | # value: 6 | 7 | ? makeLazySlot :DeepFrozen 8 | # value: 9 | 10 | ? # Normal 11 | > def &foo := makeLazySlot(fn { println("foof"); "food" }) 12 | # value: 13 | 14 | ? (&foo).isFinal() 15 | # value: true 16 | 17 | ? (&foo).put("mood") 18 | # problem: this lazy Slot may not be changed 19 | 20 | ? foo 21 | # stdout: foof 22 | # 23 | 24 | # value: "food" 25 | 26 | ? foo 27 | # value: "food" 28 | 29 | ? # Throwing by maker 30 | > def &bar := makeLazySlot(fn { println("barn"); throw("bare") }) 31 | # value: 32 | 33 | ? bar 34 | # stdout: barn 35 | # 36 | 37 | # problem: bare 38 | 39 | ? bar 40 | # problem: bare 41 | 42 | ? # Ejecting by maker 43 | > def baz; escape out { bind baz := makeLazySlot(fn { out("bass") }); baz.get() } 44 | # value: "bass" 45 | 46 | ? baz.get() 47 | # problem: nonlocal exit by lazy slot's maker -------------------------------------------------------------------------------- /tests/native-quirks.updoc: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | ? __equalizer.foo() 5 | # problem: no such method: org.erights.e.elib.tables.makeEqualizer$equalizer#foo/0 -------------------------------------------------------------------------------- /tests/overflow.updoc: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | ? 5 | # value: -------------------------------------------------------------------------------- /tests/priority-queue.updoc: -------------------------------------------------------------------------------- 1 | ? def makePriorityQueue := 2 | # value: 3 | 4 | ? def q := makePriorityQueue() 5 | # value: 6 | 7 | ? q.put(10, 'a') 8 | 9 | ? q.peek(fn { 0 }) 10 | # value: [10, 'a'] 11 | 12 | ? q.pop() 13 | # value: [10, 'a'] 14 | 15 | ? q.peek(fn { 0 }) 16 | # value: 0 17 | 18 | ? q.put(10, 'a'); q.asList() 19 | # value: [[10, 'a']] 20 | 21 | ? q.put(20, 'b'); q.asList() 22 | # value: [[10, 'a'], [20, 'b']] 23 | 24 | ? q.put(14, 'c'); q.asList() 25 | # value: [[10, 'a'], [14, 'c'], [20, 'b']] 26 | 27 | ? q.put(15, 'd'); q.asList() 28 | # value: [[10, 'a'], [14, 'c'], [15, 'd'], [20, 'b']] 29 | 30 | ? q.put(9, 'e'); q.asList() 31 | # value: [[9, 'e'], [10, 'a'], [14, 'c'], [15, 'd'], [20, 'b']] 32 | 33 | ? q.put(21, 'f'); q.asList() 34 | # value: [[9, 'e'], [10, 'a'], [14, 'c'], [15, 'd'], [20, 'b'], [21, 'f']] 35 | 36 | ? q.pop() 37 | # value: [9, 'e'] 38 | 39 | ? q.asList() 40 | # value: [[10, 'a'], [14, 'c'], [15, 'd'], [20, 'b'], [21, 'f']] -------------------------------------------------------------------------------- /tests/properties.updoc: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | ? var xStore := 0 5 | # value: 0 6 | 7 | ? var yStore := 0.0 8 | # value: 0.0 9 | 10 | ? def autoPropObj { 11 | > to getX() :any { return xStore } 12 | > to setX(new) :void { xStore := new } 13 | > to getY() :any { return yStore } 14 | > } 15 | # value: 16 | 17 | ? def &xx := __getPropertySlot(autoPropObj, "x") 18 | # value: _::&x 19 | 20 | ? xx 21 | # value: 0 22 | 23 | ? xx := 2 24 | # value: 2 25 | 26 | ? xStore 27 | # value: 2 28 | 29 | ? (&xx).isFinal() 30 | # value: false 31 | 32 | ? def &yy := __getPropertySlot(autoPropObj, "y") 33 | # value: _::&y 34 | 35 | ? yy 36 | # value: 0.0 37 | 38 | ? yy := 3.14 39 | # problem: no such method: __main$autoPropObj#setY/1 40 | 41 | ? yStore := 3.14 42 | # value: 3.14 43 | 44 | ? yy 45 | # value: 3.14 46 | 47 | isFinal means will not change, not not-changable-by-this-interface 48 | ? (&yy).isFinal() 49 | # value: false 50 | 51 | ? __getPropertySlot(autoPropObj, 43) 52 | # problem: the int 43 doesn't coerce to a String 53 | 54 | x ? __getPropertySlot(autoPropObj, "name syntax test") 55 | x # value: _::&"name syntax test" 56 | -------------------------------------------------------------------------------- /tests/protocol-desc.updoc: -------------------------------------------------------------------------------- 1 | XXX not complete 2 | 3 | ? interface Foo guards FooStamp {} 4 | # value: Foo 5 | 6 | ? interface Bar {} 7 | # value: 8 | 9 | ? Foo :DeepFrozen 10 | # value: Foo 11 | 12 | ? FooStamp :DeepFrozen 13 | # value: 14 | 15 | ? [Foo.getDocComment()] 16 | # value: [null] 17 | 18 | ? [Bar.getDocComment()] 19 | # value: [null] 20 | 21 | -------------------------------------------------------------------------------- /tests/proxy-delaying.updoc: -------------------------------------------------------------------------------- 1 | # Copyright 2008 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | ? def makeDelayingRef := 5 | # value: 6 | 7 | ? def recipient match msg { 8 | > stdout.println(msg) 9 | > E.callWithPair(__identityFunc, msg) 10 | > }; null 11 | 12 | ? def [dr, resolver] := makeDelayingRef(false) 13 | # value: [, ] 14 | 15 | ? makeDelayingRef(true) 16 | # value: [, ] 17 | 18 | ? dr(2) 19 | # problem: not synchronously callable: .run(2) 20 | 21 | ? def x := dr <- (2) 22 | # value: 23 | 24 | ? 25 | ? 26 | ? 27 | ? x 28 | # value: 29 | 30 | ? resolver.resolveSoFar(recipient) 31 | > x 32 | # value: 33 | 34 | # stdout: ["run", [2]] 35 | # 36 | 37 | The buffered messages are delivered as sends, so x is not immediately resolved. 38 | 39 | ? x 40 | # value: 2 41 | 42 | Different target 43 | 44 | ? def x := dr <- (2) 45 | # value: 46 | 47 | ? resolver.resolveSoFar(fn x { x + 1 }) 48 | 49 | ? x 50 | # value: 3 51 | 52 | Verifying sendOnly support 53 | 54 | ? def x := E.sendOnly(dr, "run", ["run"]) 55 | ? resolver.resolveSoFar(recipient) 56 | # stdout: ["run", ["run"]] 57 | # 58 | 59 | ? [x] 60 | # value: [null] 61 | -------------------------------------------------------------------------------- /tests/random.updoc: -------------------------------------------------------------------------------- 1 | # Copyright 2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | ? entropy 5 | # value: 6 | 7 | (XXX This is a bug: privilegedScope entropy should take external sources etc. and otherwise do all the things a cryptographic-quality RNG should do. Compare E-on-Java's ESecureRandom. The print above is a warning.) 8 | 9 | 0 is excluded from the allowed range on the motivation that it is far more likely that zeros will be erroneously generated than that the RNG picks it correctly. 10 | 11 | ? def v := entropy.nextSwiss(); null 12 | 13 | ? if ((1..!2**160)(v)) { "OK" } else { [v] } 14 | # value: "OK" 15 | 16 | ? var seen := [].asSet() 17 | > for _ in 1..1000 { seen with= entropy.nextInt(4) } 18 | > require(seen.sort() == [0,1,2,3].asSet(), fn { `nextInt(4) probably broken: expected results [0,1,2,3].asSet() but got ${seen.sort()}` }) -------------------------------------------------------------------------------- /tests/region.updoc: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | ? int.getTheTrivialValue() 5 | # value: 0 6 | 7 | ? (int >= 0).getTheTrivialValue() 8 | # value: 0 9 | 10 | ? (int > 0).getTheTrivialValue() 11 | # problem: trivial value 0 is not available in region (int >= 1) 12 | 13 | ? (-3..30).getTheTrivialValue() 14 | # value: 0 15 | 16 | ? (1..5).getTheTrivialValue() 17 | # problem: trivial value 0 is not available in region 1..!6 18 | 19 | ? def SubrangeGuard := ; null 20 | 21 | ? 1..!10 :SubrangeGuard[] 22 | # value: 1..!10 23 | 24 | ? 1..!10 :SubrangeGuard[DeepFrozen] 25 | # value: 1..!10 26 | 27 | ? 1..!10 :SubrangeGuard[] 28 | # problem: 1..!10 isn't approved as a SubrangeGuard[char] 29 | 30 | ? 'a'..!'z' :SubrangeGuard[] 31 | # value: a..!z 32 | -------------------------------------------------------------------------------- /tests/rx.updoc: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | XXX move simple__quasiParser testing elsewhere 5 | 6 | ? def `abc` := "abc" 7 | # value: "abc" 8 | 9 | ? def `abc` := "abcdef" 10 | # problem: extra text at end of specimen: def 11 | 12 | ? {def `abc@x` := "abcdef"; x} 13 | # value: "def" 14 | 15 | ? {def `abc@{x}ghi` := "abcdghefghi"; x} 16 | # value: "dghef" 17 | 18 | 19 | XXX this is a rather implementation-specific test result (but the implementation is E code from Java-E) 20 | ? rx__quasiParser 21 | # value: 22 | 23 | ? def rx`abc` := "abc" 24 | # value: "abc" 25 | 26 | ? def rx`abc?` := "ab" 27 | # value: "ab" 28 | 29 | ? {def rx`x=(@x.*)` := "x=y"; x} 30 | # value: "y" 31 | 32 | part of the expansion of the above - for tracking down a "such-that expression was false" bug 33 | ? rx__quasiParser.matchMaker("x=(@{0}.*)").matchBind(__makeList.run(), "x=y", null) 34 | # value: ["y"] 35 | 36 | ? {def rx`(@{a}a.)(@{b}b.)?(@{c}c.)*(@{d}d.)+(@{e}e.)` := "a1c2c3d4d5e6"; [a,b,c,d,e]} 37 | # value: ["a1", null, "c3", "d5", "e6"] 38 | 39 | Bug: bad double-unquoting of $ hole syntax - this would die 40 | 41 | ? def rx`a\$$b` := "a$b" 42 | # value: "a$b" 43 | 44 | Bug: pattern not anchored - this would succeed 45 | ? def rx`b` := "abc" 46 | # problem: Doesn't match: abc 47 | 48 | -------------------------------------------------------------------------------- /tests/stream/append.updoc: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | makeAppendStream takes a FlexList or other object providing valueType/0 and append/1 and produces an output stream appending to it. 5 | 6 | ? def makeAppendStream :DeepFrozen := 7 | # value: 8 | 9 | ? def reporter { 10 | > to valueType() { println("valueType"); return int } 11 | > match msg { println(msg) } 12 | > } 13 | # value: 14 | 15 | ? def s := makeAppendStream(reporter) 16 | # stdout: valueType 17 | # 18 | 19 | # value: ->(, ...) 20 | 21 | XXX This print syntax reflects its implementation using makeWriterStream, and should be changed. XXX should we print the target list or not? (i.e. revealing existing contents) 22 | 23 | ? s.getChunkType() 24 | # value: List[int] 25 | 26 | ? s.reserve().resolve([10]); "return" 27 | # stdout: ["append", [[10]]] 28 | # 29 | 30 | # value: "return" 31 | 32 | Delivery occurs synchronously with the resolve message. 33 | 34 | Flushing does not notify the target. 35 | 36 | ? s.flush() 37 | 38 | Closure affects the stream, but does not notify the target. 39 | 40 | ? s.reserve().resolve(null) 41 | 42 | ? [s.reserve()] 43 | # value: [null] 44 | 45 | ? def s := makeAppendStream(reporter) 46 | > s.reserve().resolve(Ref.broken("boing")) 47 | > [s.reserve()] 48 | # stdout: valueType 49 | # 50 | 51 | # value: [] 52 | -------------------------------------------------------------------------------- /tests/stream/asNear.updoc: -------------------------------------------------------------------------------- 1 | # Copyright 2008 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | ? def makePseudoFarRef := 5 | # value: 6 | 7 | ? def makeWriterStream := 8 | # value: 9 | 10 | These utilities convert eventual references to streams to near streams, and near references are left alone. 11 | 12 | asNearIn 13 | 14 | ? def b := EIO.asNearIn(def a := [1].asStream()) 15 | # value: [1].asStream() 16 | 17 | ? b == a 18 | # value: true 19 | 20 | ? def inStreamVow 21 | > def inNear := EIO.asNearIn(inStreamVow) 22 | # value: 23 | 24 | This is the best we can do for a chunk type. 25 | 26 | ? def type := inNear.getChunkType() 27 | # value: 28 | 29 | ? def chunk := inNear.takeAtMost(1) 30 | # value: 31 | 32 | ? bind inStreamVow := [1,2,3].asStream() 33 | # value: [1, 2, 3].asStream() 34 | 35 | ? interp.waitAtTop(chunk) 36 | ? chunk 37 | # value: [1] 38 | 39 | ? type 40 | # value: ConstList 41 | 42 | ? inNear.takeAtMost(1) 43 | # value: [2] 44 | 45 | asNearOut 46 | 47 | ? def b := EIO.asNearOut(def a := makeWriterStream(String, E.call, stdout)) 48 | # value: ->(, ...) 49 | 50 | ? b == a 51 | # value: true 52 | 53 | ? def outStreamVow 54 | > def outNear := EIO.asNearOut(outStreamVow) 55 | # value: 56 | 57 | ? def type := outNear.getChunkType() 58 | # value: 59 | 60 | ? def resolver := outNear.reserve() 61 | # value: 62 | 63 | ? bind outStreamVow := a 64 | # value: ->(, ...) 65 | 66 | ? resolver 67 | # value: 68 | 69 | ? resolver.resolve("ping. ") 70 | # stdout: ping. 71 | 72 | -------------------------------------------------------------------------------- /tests/stream/map.updoc: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | ? pragma.enable("dot-props") 5 | > def ALL := EIO::ALL 6 | > null 7 | 8 | ? def mapStream :DeepFrozen := 9 | # value: 10 | 11 | ? def s := mapStream(List, [1, 2, 3].asStream(), __makeList) 12 | # value: <--[1, 2, 3].asStream() 13 | 14 | ? s.getChunkType() 15 | # value: List[List] 16 | 17 | ? EIO.takeAll(s) 18 | # value: [[1], [2], [3]] 19 | 20 | ? pragma.enable("accumulator") 21 | > def s := mapStream.chunked(List[int], 22 | > [1, 2, 3].asStream(), 23 | > def chunkFunc(es) :any { 24 | > return accum [] for x in es { _.with(x+1) }}) 25 | # value: <--[1, 2, 3].asStream() 26 | 27 | ? EIO.takeAll(s) 28 | # value: [2, 3, 4] 29 | 30 | Closure 31 | 32 | ? def [bo, bi] := EIO.pipe([].asMap()) 33 | > def bm := mapStream(any, bi, __makeList) 34 | > bo.reserve() <- resolve(null) 35 | > interp.waitAtTop(def r := bm.takeAtMost(1)) 36 | ? [r] 37 | # value: [null] 38 | 39 | XXX closing map stream propagates 40 | 41 | Erroneous chunk functions 42 | 43 | ? EIO.takeAll(mapStream.chunked(List[int], [1].asStream(), fn _ { [2, 3] })) 44 | # problem: mapStream chunk function <__main$_> produced 2 elements instead of 0, [] to [2, 3] 45 | 46 | ? EIO.takeAll(mapStream.chunked(List[int], [1].asStream(), fn _ { [] })) 47 | # problem: mapStream chunk function <__main$_> produced 0 elements instead of 1, [1] to [] 48 | 49 | -------------------------------------------------------------------------------- /tests/stream/trickle.updoc: -------------------------------------------------------------------------------- 1 | # Copyright 2008 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | ? pragma.syntax("0.9") 5 | 6 | trickleIn wraps an input stream to produce maximally eventual behavior: no prompt responses are given, and chunks alternate between 0 and 1 elements. 7 | 8 | ? def ALL := EIO.getALL() 9 | 10 | ? def trickleIn :DeepFrozen := 11 | # value: 12 | 13 | ? def s := trickleIn([0, 1, 2, 3, 4, 5, 6, 7, 8, 9].asStream()) 14 | # value: <-trickling-[0, 1, 2, 3, 4, ...].asStream() 15 | 16 | ? interp.waitAtTop(def x := s.takeAtMost(1)); x 17 | # value: 18 | 19 | ? x 20 | # value: [] 21 | 22 | ? interp.waitAtTop(def x := s.takeAtMost(1)); x 23 | # value: 24 | 25 | ? x 26 | # value: [0] 27 | 28 | ? interp.waitAtTop(def x := s.takeAtMost(1)) 29 | ? x 30 | # value: [] 31 | 32 | ? interp.waitAtTop(def x := s.takeAtMost(1)) 33 | ? x 34 | # value: [1] 35 | 36 | ? interp.waitAtTop(def x := s.takeAtMost(1)) 37 | ? x 38 | # value: [] 39 | 40 | ? interp.waitAtTop(def x := s.takeAtMost(1)) 41 | ? x 42 | # value: [2] 43 | -------------------------------------------------------------------------------- /tests/stream/types.updoc: -------------------------------------------------------------------------------- 1 | # Copyright 2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | ? 5 | # value: stream 6 | 7 | ? 8 | # value: inStream 9 | 10 | ? 11 | # value: outStream 12 | 13 | -------------------------------------------------------------------------------- /tests/symbol.updoc: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | ? def makeSymbol := lisp["CL", "MAKE-SYMBOL"].getFunction(); null 5 | 6 | ? def foo := makeSymbol("foo") 7 | # value: foo 8 | 9 | ? foo :DeepFrozen 10 | # value: foo 11 | -------------------------------------------------------------------------------- /tests/table-lists.updoc: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | ? ['a'] * 2 5 | # value: ['a', 'a'] 6 | 7 | ? [44, "45"].snapshot() 8 | # value: [44, "45"] 9 | 10 | ? def fl := [44, "45"].diverge() 11 | # value: [44, "45"].diverge() 12 | 13 | ? fl.push(null) 14 | 15 | ? fl 16 | # value: [44, "45", null].diverge() 17 | 18 | ? fl.size() 19 | # value: 3 20 | 21 | ? fl[0] 22 | # value: 44 23 | 24 | ? fl[def _{to __conformTo(_) :any { return 1 }}] 25 | # value: "45" 26 | 27 | ? fl["45"] 28 | # problem: the String "45" doesn't coerce to an int 29 | 30 | ? def cfl := fl.snapshot() 31 | # value: [44, "45", null] 32 | 33 | ? fl.push(2) 34 | 35 | ? cfl 36 | # value: [44, "45", null] 37 | 38 | ? def FlexList := 39 | # value: FlexList 40 | 41 | XXX more FlexList guard tests -------------------------------------------------------------------------------- /tests/table-streams.updoc: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | ConstList streams 5 | 6 | ? pragma.enable("dot-props") 7 | > def ALL := EIO::ALL 8 | 9 | ? def text := "Teh quike bruin fax jimp't ovah thy lizy dugz." 10 | # value: "Teh quike bruin fax jimp't ovah thy lizy dugz." 11 | 12 | ? def s := text.asStream() 13 | # value: "Teh quike bruin fax \...".asStream() 14 | 15 | ? s.getChunkType() 16 | # value: String 17 | 18 | ? s.takeAtMost(10) 19 | # value: "Teh quike " 20 | 21 | ? s 22 | # value: "bruin fax jimp't ova\...".asStream() 23 | 24 | ? s.takeAtMost(ALL) 25 | # value: "bruin fax jimp't ovah thy lizy dugz." 26 | 27 | ? s 28 | # value: "".asStream() 29 | 30 | ? [s.takeAtMost(1)] 31 | # value: [null] 32 | 33 | List stream fail/1 34 | 35 | ? def s := text.asStream() 36 | > s.fail("foo") 37 | > s 38 | # value: "".asStream() 39 | 40 | ? [s.takeAtMost(1)] 41 | # value: [null] 42 | 43 | List stream close/0 44 | 45 | ? def s := text.asStream() 46 | > s.close() 47 | > s 48 | # value: "".asStream() 49 | 50 | ? [s.takeAtMost(1)] 51 | # value: [null] 52 | 53 | 54 | XXX Should FlexLists have asStream? If so, what would it mean? 55 | XXX all varieties of map streams (pairs, values, keys)? 56 | XXX Set streams 57 | XXX turning streams into tables 58 | XXX other stream methods -------------------------------------------------------------------------------- /tests/term/base.updoc: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | ? def := ; null 5 | ? def makeBaseAstroBuilder := 6 | # value: 7 | 8 | ? makeBaseAstroBuilder :DeepFrozen 9 | # value: 10 | 11 | ? def testBuilder := makeBaseAstroBuilder(null, null, [].asMap()) 12 | # value: -------------------------------------------------------------------------------- /tests/term/lexer.updoc: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | ? def := ; null 5 | 6 | ? def makeTermLexer := ; null 7 | 8 | ? def lex(twine) :any { return EIO.takeAll(makeTermLexer(false)(twine.asStream())) }; null 9 | 10 | ? lex("foo") 11 | # value: [["Tag", [["Ident", "foo"]]]] 12 | 13 | ? lex("(,)[{:]}+*?") 14 | # value: [["("], [","], [")"], ["["], ["{"], [":"], ["]"], ["}"], ["+"], ["*"], ["?"]] 15 | 16 | ? lex("foo(bar)") 17 | # value: [["Tag", [["Ident", "foo"]]], ["("], ["Tag", [["Ident", "bar"]]], [")"]] 18 | 19 | ? lex(".foo. .bar.baz") 20 | # value: [["Tag", [["Ident", ".foo."]]], ["Tag", [["Ident", ".bar.baz"]]]] 21 | 22 | ? lex("${9} @{10} ") 23 | # value: [["Quasi$", 9], ["Quasi@", 10]] 24 | 25 | ? lex("0 1 2 107 -1 3 000") 26 | # value: [["Integer", 0], ["Integer", 1], ["Integer", 2], ["Integer", 107], ["Integer", -1], ["Integer", 3], ["Integer", 0]] 27 | 28 | ? lex("+3") 29 | # value: [["+"], ["Integer", 3]] 30 | 31 | ? lex("\"foo\"") 32 | # value: [["String", "foo"]] 33 | 34 | ? lex("\"foo\\t\"") 35 | # value: [["String", "foo\t"]] 36 | 37 | ? lex("\"foo\\\"\"") 38 | # value: [["String", "foo\""]] 39 | XXX EoJ term lexer returns terms 40 | XXX token types: float, char, more strings, tag, punct, chars 41 | XXX consequence of loose ::, or malformed tags in general 42 | XXX consequence of non-token characters 43 | -------------------------------------------------------------------------------- /tests/timer.updoc: -------------------------------------------------------------------------------- 1 | ? timer 2 | # value: 3 | 4 | ? def t := timer.now(); t =~ tt :int ? (t == tt) 5 | # value: true 6 | 7 | ? t > 1117718697755 8 | # value: true 9 | 10 | ? timer.now() >= t 11 | # value: true 12 | 13 | ? def r1 := timer.whenPast(def expected := timer.now() + 1000, fn { 14 | > def delta := timer.now() - expected 15 | > println(`thunk 1 (${if (delta > 500) {delta}})`) 16 | > 11 17 | > }) 18 | # value: 19 | 20 | ? interp.waitAtTop(r1); r1 21 | # value: 22 | 23 | # stdout: thunk 1 (null) 24 | # 25 | 26 | ? timer.now() > (t + 1000) 27 | # value: true 28 | 29 | ? r1 30 | # value: 11 31 | 32 | ? def r2 := timer.whenPast((def base := timer.now()) + 2000, fn {println("timing test 1")}) 33 | # value: 34 | 35 | ? def r3 := timer.whenPast(base + 1000, fn {println("timing test 2")}) 36 | # value: 37 | 38 | ? interp.waitAtTop(r2) 39 | 40 | # stdout: timing test 2 41 | # timing test 1 42 | # -------------------------------------------------------------------------------- /tests/unicode.updoc: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | E syntax 5 | 6 | ? def pp := ; null 7 | ? def dumpENodes := ; null 8 | ? def t(s) :any { return dumpENodes(pp.run(s), stdout) }; null 9 | 10 | ? t("π") 11 | # stdout: NounE. π 12 | 13 | ? t("`π`") 14 | # stdout: QuasiE. 15 | # null 16 | # [] QuasiText π 17 | 18 | ? t("`$π`") 19 | # stdout: QuasiE. 20 | # null 21 | # [] QuasiE.Hole NounE. π 22 | 23 | 24 | Sam Ruby's test string ' 25 | ? def t := "Iñtërnâtiônàlizætiøn" 26 | # value: "Iñtërnâtiônàlizætiøn" 27 | 28 | Check that a single big-char is retrieved properly 29 | ? t[1] 30 | # value: 'ñ' 31 | 32 | ? t[1] == 'ñ' 33 | # value: true 34 | 35 | Check that a substring is retrieved properly 36 | ? t(18) 37 | # value: "øn" 38 | 39 | Using Unicode letters in nouns 40 | 41 | ? def π := 3.14159 42 | # value: 3.14159 43 | 44 | ? def π2 := π * 2 45 | # value: 6.28318 46 | 47 | ? e`def π2 := π * 2`.asKernelE() 48 | # value: e`def π2 := π.multiply(2)` 49 | 50 | Codepoints 51 | 52 | ? for c in " !Az~ ¡þÿ" { print(" ", c.getCodepoint().toString(["base" => 16])) } 53 | # stdout: 20 21 41 7a 7e a0 a1 fe ff 54 | 55 | XXX more general unicode tests as I think of them 56 | XXX support Unicode normalization as guards, then ensure that it's used for nouns, to avoid surprises -------------------------------------------------------------------------------- /tests/updoc.updoc: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | ? print("hi") 5 | # stdout: hi 6 | 7 | ? println("hi") 8 | # stdout: hi 9 | # 10 | 11 | ? if (E.toQuote(interp) !~ `>`) { [interp] } 12 | 13 | This should be successful: 14 | 15 | ? interp.pushTestStep(e`1 + 1`, [["value", "2"]]) 16 | 17 | This should fail: 18 | 19 | x ? interp.pushTestStep(e`1 + 1`, [["value", "You should see a failure report, expecting the value 2."]]) 20 | 21 | 22 | ? "something after pushed tests" 23 | # value: "something after pushed tests" 24 | 25 | XXX as shown by the disabled 'should fail' test, in order to do this properly we need to create a nested updoc runner and verify its output 26 | 27 | --- 28 | 29 | Pragmas should persist across steps 30 | 31 | ? accum 0 for x in 1..4 { _ + x } 32 | # problem: (line 1)@31: The optional "accumulator" syntax is currently off. 33 | 34 | ? pragma.enable("accumulator") 35 | > accum 0 for x in 1..4 { _ + x } 36 | # value: 10 37 | 38 | ? accum 0 for x in 1..4 { _ + x } 39 | # value: 10 40 | 41 | ? pragma.disable("accumulator") 42 | 43 | ? accum 0 for x in 1..4 { _ + x } 44 | # problem: (line 1)@31: The optional "accumulator" syntax is currently off. 45 | 46 | --- 47 | 48 | waitAtTop / timing tests: 49 | 50 | ? print <- ("hello") 51 | # value: 52 | 53 | # stdout: hello 54 | 55 | ? fn { print <- ("world") } <- () 56 | # value: 57 | 58 | ? 1 59 | # stdout: world 60 | 61 | # value: 1 62 | 63 | ? interp.waitAtTop(fn { print <- ("now"); 0 } <- ()); 2 64 | # value: 2 65 | 66 | # stdout: now 67 | 68 | ? 3 69 | # value: 3 70 | 71 | Bug: resolved promise for null not treated equivalently to null: 72 | 73 | ? def p; bind p := null; p 74 | -------------------------------------------------------------------------------- /tests/valueThunk.updoc: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | ? pragma.syntax("0.9") 5 | 6 | org.erights.e.elib.base.makeValueThunk provides thunks which evaluate to an existing value, and are pass-by-construction. 7 | 8 | ? def makeValueThunk := 9 | # value: makeValueThunk 10 | 11 | ? def th := makeValueThunk(21489) 12 | # value: makeValueThunk(21489) 13 | 14 | ? th.run() 15 | # value: 21489 16 | 17 | ? th :pbc == th 18 | # value: true 19 | 20 | XXX should be Selfless but isn't yet 21 | x ? th :PassByCopy == th 22 | x # value: true 23 | 24 | ? th.__optUncall() 25 | # value: [makeValueThunk, "run", [21489]] 26 | 27 | ? .optUncall(makeValueThunk) 28 | # value: [, "get", ["org.erights.e.elib.base.makeValueThunk"]] 29 | 30 | ? def ValueThunk := makeValueThunk.asType() 31 | # value: ValueThunk 32 | 33 | ? th :ValueThunk == th 34 | # value: true 35 | 36 | ? 21489 :ValueThunk 37 | # problem: Not stamped by org.erights.e.elib.base.makeValueThunk$ValueThunk__T 38 | 39 | XXX E-on-Java compatibility; ought to be renamed, if provided at all 40 | XXX once Selfless, compare directly rather than by uncall 41 | ? makeValueThunk.getNULL_THUNK().__optUncall() == makeValueThunk(null).__optUncall() 42 | # value: true 43 | 44 | XXX these should be the same 45 | x ? makeValueThunk.getNULL_THUNK() == makeValueThunk.getNULL_THUNK() 46 | x # value: true 47 | -------------------------------------------------------------------------------- /tests/vat/comm.updoc: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | ? def makeVat := 5 | # value: 6 | 7 | ? def vat := makeVat(null, "testvat") 8 | # value: 9 | 10 | ? def remote := vat <- seedEval(e`def remote(o) :void { o <- run("ping") }`) 11 | # value: 12 | 13 | ? interp.waitAtTop(remote) 14 | 15 | ? remote 16 | # value: 17 | 18 | ? interp.waitAtTop(def res := remote <- run(println)); res 19 | # value: 20 | 21 | # stdout: ping 22 | # 23 | 24 | x ? vat <- shutdown("bye") 25 | x 26 | x ? interp.waitAtTop(def res := remote <- run(println)); res 27 | x # value: 28 | x 29 | x ? res 30 | x # value: 31 | x 32 | x ? null 33 | x # value: null -------------------------------------------------------------------------------- /tests/vat/sharing.updoc: -------------------------------------------------------------------------------- 1 | # Copyright 2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | Objects which can be safely shared among threads are marked with ThreadSharableStamp. 5 | 6 | The stamp applies only to the parts of the object which are not exposed via its uncall, whether or not the object is also Selfless, DeepFrozen, etc. 7 | 8 | This file tests whether objects which should be marked sharable are. 9 | 10 | ? def TSS := lisp["E.ELIB", "+THREAD-SHARABLE-STAMP+"].get() 11 | # value: 12 | 13 | ? for specimen in [ 14 | > 1, 15 | > 1.0, 16 | > ' ', 17 | > "", 18 | > null, 19 | > [], 20 | > [1], 21 | > , 22 | > (null, 1, null), 23 | > false, 24 | > true, 25 | > ] { 26 | > if (!__auditedBy(TSS, specimen)) { println("Should be TS: ", E.toQuote(specimen)) } 27 | > } 28 | > print("end") 29 | # stdout: end -------------------------------------------------------------------------------- /tests/vattp/messages.updoc: -------------------------------------------------------------------------------- 1 | # Copyright 2008 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | A VatTP connection runs on top of some secure reliable stream protocol (e.g. SSL/TLS over TCP), whereas it provides unlimited-size ordered messages. This component provides the subdivision. 5 | 6 | ? def takeOne(inStream) { 7 | > return when (def r := EIO.takeRange(1, 1, inStream)) -> { 8 | > if (r =~ [x]) { x } else { Ref.broken("end of stream") } 9 | > } 10 | > }; null 11 | 12 | ? def messageJoining := 13 | # value: 14 | 15 | ? def [i, o] := EIO.pipe(["Chunk" => List[0..255]]) 16 | > def [j, p] := [messageJoining.makeJoiner(i), messageJoining.makeSplitter(o)] 17 | # value: [, ] 18 | 19 | ? def send(msg) { return when (def mos := takeOne(j)) -> { EIO.join(msg.asStream(), mos) }} 20 | > def receive() { return when (def mis := takeOne(p)) -> { traceln(`got one $mis`); EIO.takeAll(mis) }} 21 | > null 22 | 23 | ? send([97]) 24 | # value: 25 | 26 | ? interp.waitAtTop(def r := receive()) 27 | ? r 28 | # value: [97] 29 | 30 | ? when (send([1, 2, 3, 4])) -> 31 | > {send([97, 98, 99])} 32 | # value: 33 | 34 | ? interp.waitAtTop(def r := receive()) 35 | ? r 36 | # value: [1, 2, 3, 4] 37 | 38 | ? interp.waitAtTop(def r := receive()) 39 | ? r 40 | # value: [97, 98, 99] 41 | 42 | -------------------------------------------------------------------------------- /tests/weak.updoc: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | 5 | ? def makeWeakRef := 6 | # value: 7 | 8 | ? 9 | # value: 10 | 11 | ? def x {} 12 | # value: 13 | 14 | ? def weakRef := makeWeakRef(x, null) 15 | # value: > 16 | 17 | ? weakRef.get() == x 18 | # value: true 19 | 20 | ? def x := 44 21 | # value: 44 22 | 23 | XXX separate test for interp.gc() 24 | ? interp.gc() 25 | 26 | x ? [weakRef.get()] 27 | x # value: [null] 28 | x 29 | x ? weakRef 30 | x # value: 31 | -------------------------------------------------------------------------------- /toptests/dead.updoc: -------------------------------------------------------------------------------- 1 | ? def x := throw("oops") 2 | # problem: will be "oops", not this 3 | 4 | ? x 5 | # value: 6 | 7 | ? def x := 1 8 | # value: 1 9 | 10 | ? x 11 | # value: 1 12 | -------------------------------------------------------------------------------- /toptests/fail.updoc: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | ? 43 5 | # value: 44 6 | 7 | ? "no-result" 8 | -------------------------------------------------------------------------------- /toptests/hello.e: -------------------------------------------------------------------------------- 1 | println(".i coi munje .iji'a me " + interp.getArgs()) -------------------------------------------------------------------------------- /toptests/stdin.updoc: -------------------------------------------------------------------------------- 1 | # Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license 2 | # found at http://www.opensource.org/licenses/mit-license.html ................ 3 | 4 | ? interp.waitAtTop(stdin.whenAvailable(6, fn { print("hello " + stdin.read(6, 6))})) 5 | # stdout: hello world 6 | # --------------------------------------------------------------------------------