nomennescio 2019-10-18 15:04:41 +02:00
commit a7f5684c1e
261 changed files with 6567 additions and 3452 deletions

View File

@ -1,109 +1,119 @@
./library/compiler/simplifier.factor:! $Id: simplifier.factor,v 1.3 2004/12/18 00:27:26 spestov Exp $
./library/compiler/simplifier.factor:! $Id: simplifier.factor,v 1.4 2004/12/19 01:24:45 spestov Exp $
./library/compiler/xt.factor:! $Id: xt.factor,v 1.6 2004/12/17 00:57:03 spestov Exp $
./library/compiler/assembler.factor:! $Id: assembler.factor,v 1.6 2004/12/11 00:29:02 spestov Exp $
./library/compiler/assembly-x86.factor:! $Id: assembly-x86.factor,v 1.14 2004/12/13 21:28:28 spestov Exp $
./library/compiler/generator-x86.factor:! $Id: generator-x86.factor,v 1.13 2004/12/17 00:57:02 spestov Exp $
./library/compiler/alien-types.factor:! $Id: alien-types.factor,v 1.14 2004/12/14 00:14:02 spestov Exp $
./library/compiler/generator.factor:! $Id: generator.factor,v 1.5 2004/12/11 00:29:03 spestov Exp $
./library/compiler/alien.factor:! $Id: alien.factor,v 1.12 2004/12/18 05:38:47 spestov Exp $
./library/compiler/optimizer.factor:! $Id: optimizer.factor,v 1.12 2004/12/13 21:28:28 spestov Exp $
./library/compiler/compiler.factor:! $Id: compiler.factor,v 1.27 2004/12/18 02:46:18 spestov Exp $
./library/compiler/linearizer.factor:! $Id: linearizer.factor,v 1.17 2004/12/18 00:27:16 spestov Exp $
./library/vectors.factor:! $Id: vectors.factor,v 1.19 2004/12/15 21:57:27 spestov Exp $
./library/kernel.factor:! $Id: kernel.factor,v 1.9 2004/12/17 00:56:55 spestov Exp $
./library/httpd/file-responder.factor:! $Id: file-responder.factor,v 1.15 2004/12/11 00:29:03 spestov Exp $
./library/httpd/http-common.factor:! $Id: http-common.factor,v 1.16 2004/12/11 00:29:03 spestov Exp $
./library/httpd/inspect-responder.factor:! $Id: inspect-responder.factor,v 1.4 2004/12/11 00:29:03 spestov Exp $
./library/compiler/assembler.factor:! $Id: assembler.factor,v 1.8 2004/12/25 07:55:03 spestov Exp $
./library/compiler/assembly-x86.factor:! $Id: assembly-x86.factor,v 1.15 2004/12/31 07:17:43 spestov Exp $
./library/compiler/generator-x86.factor:! $Id: generator-x86.factor,v 1.19 2004/12/31 07:17:43 spestov Exp $
./library/compiler/alien-types.factor:! $Id: alien-types.factor,v 1.17 2004/12/29 08:35:44 spestov Exp $
./library/compiler/generator.factor:! $Id: generator.factor,v 1.9 2004/12/31 07:17:43 spestov Exp $
./library/compiler/alien.factor:! $Id: alien.factor,v 1.22 2004/12/31 07:17:43 spestov Exp $
./library/compiler/optimizer.factor:! $Id: optimizer.factor,v 1.14 2005/01/01 22:20:47 spestov Exp $
./library/compiler/compiler.factor:! $Id: compiler.factor,v 1.32 2004/12/27 20:27:17 spestov Exp $
./library/compiler/linearizer.factor:! $Id: linearizer.factor,v 1.19 2005/01/01 22:20:47 spestov Exp $
./library/vectors.factor:! $Id: vectors.factor,v 1.25 2004/12/30 07:40:13 spestov Exp $
./library/kernel.factor:! $Id: kernel.factor,v 1.16 2004/12/31 07:17:43 spestov Exp $
./library/win32/win32-io.factor:! $Id: win32-io.factor,v 1.3 2004/12/29 07:16:03 eiz Exp $
./library/win32/win32-errors.factor:! $Id: win32-errors.factor,v 1.3 2004/12/29 07:16:03 eiz Exp $
./library/win32/winsock.factor:! $Id: winsock.factor,v 1.2 2004/12/29 07:16:03 eiz Exp $
./library/httpd/file-responder.factor:! $Id: file-responder.factor,v 1.16 2004/12/19 08:04:02 spestov Exp $
./library/httpd/http-common.factor:! $Id: http-common.factor,v 1.17 2004/12/19 08:04:02 spestov Exp $
./library/httpd/quit-responder.factor:! $Id: quit-responder.factor,v 1.6 2004/12/11 00:29:03 spestov Exp $
./library/httpd/responder.factor:! $Id: responder.factor,v 1.18 2004/12/11 00:29:03 spestov Exp $
./library/httpd/resource-responder.factor:! $Id: resource-responder.factor,v 1.4 2004/12/11 00:29:03 spestov Exp $
./library/httpd/default-responders.factor:! $Id: default-responders.factor,v 1.11 2004/12/11 00:29:03 spestov Exp $
./library/httpd/html.factor:! $Id: html.factor,v 1.20 2004/12/11 23:18:41 spestov Exp $
./library/httpd/default-responders.factor:! $Id: default-responders.factor,v 1.12 2004/12/24 07:52:00 spestov Exp $
./library/httpd/html.factor:! $Id: html.factor,v 1.22 2004/12/24 07:52:00 spestov Exp $
./library/httpd/test-responder.factor:! $Id: test-responder.factor,v 1.5 2004/12/11 00:29:03 spestov Exp $
./library/httpd/httpd.factor:! $Id: httpd.factor,v 1.21 2004/12/11 00:29:03 spestov Exp $
./library/httpd/url-encoding.factor:! $Id: url-encoding.factor,v 1.10 2004/12/11 00:29:03 spestov Exp $
./library/math/arc-trig-hyp.factor:! $Id: arc-trig-hyp.factor,v 1.6 2004/12/11 00:29:04 spestov Exp $
./library/math/generic.factor:! $Id: generic.factor,v 1.5 2004/12/15 21:57:28 spestov Exp $
./library/httpd/httpd.factor:! $Id: httpd.factor,v 1.23 2004/12/26 02:28:46 spestov Exp $
./library/httpd/url-encoding.factor:! $Id: url-encoding.factor,v 1.13 2004/12/29 08:35:44 spestov Exp $
./library/math/arc-trig-hyp.factor:! $Id: arc-trig-hyp.factor,v 1.7 2004/12/29 08:35:45 spestov Exp $
./library/math/float.factor:! $Id: float.factor,v 1.1 2004/12/19 04:18:31 spestov Exp $
./library/math/complex.factor:! $Id: complex.factor,v 1.6 2004/12/31 07:17:45 spestov Exp $
./library/math/constants.factor:! $Id: constants.factor,v 1.2 2004/09/19 02:29:28 spestov Exp $
./library/math/math-combinators.factor:! $Id: math-combinators.factor,v 1.8 2004/12/11 00:29:04 spestov Exp $
./library/math/integer.factor:! $Id: integer.factor,v 1.4 2004/12/31 01:46:20 spestov Exp $
./library/math/math-combinators.factor:! $Id: math-combinators.factor,v 1.11 2004/12/29 08:35:45 spestov Exp $
./library/math/pow.factor:! $Id: pow.factor,v 1.9 2004/12/11 00:29:04 spestov Exp $
./library/math/math.factor:! $Id: math.factor,v 1.10 2004/12/11 00:29:04 spestov Exp $
./library/math/arithmetic.factor:! $Id: arithmetic.factor,v 1.16 2004/12/11 02:39:18 spestov Exp $
./library/math/math.factor:! $Id: math.factor,v 1.14 2004/12/30 07:40:14 spestov Exp $
./library/math/ratio.factor:! $Id: ratio.factor,v 1.3 2004/12/31 07:17:45 spestov Exp $
./library/math/trig-hyp.factor:! $Id: trig-hyp.factor,v 1.9 2004/12/11 00:29:04 spestov Exp $
./library/errors.factor:! $Id: errors.factor,v 1.17 2004/12/15 21:57:26 spestov Exp $
./library/random.factor:! $Id: random.factor,v 1.8 2004/12/11 02:39:11 spestov Exp $
./library/combinators.factor:! $Id: combinators.factor,v 1.17 2004/12/15 21:57:26 spestov Exp $
./library/words.factor:! $Id: words.factor,v 1.16 2004/12/16 23:36:06 spestov Exp $
./library/errors.factor:! $Id: errors.factor,v 1.18 2004/12/24 07:51:58 spestov Exp $
./library/random.factor:! $Id: random.factor,v 1.9 2004/12/29 08:35:43 spestov Exp $
./library/combinators.factor:! $Id: combinators.factor,v 1.18 2004/12/24 07:51:58 spestov Exp $
./library/words.factor:! $Id: words.factor,v 1.21 2004/12/31 07:17:43 spestov Exp $
./library/continuations.factor:! $Id: continuations.factor,v 1.6 2004/12/11 00:29:00 spestov Exp $
./library/assoc.factor:! $Id: assoc.factor,v 1.10 2004/12/11 02:39:11 spestov Exp $
./library/logic.factor:! $Id: logic.factor,v 1.5 2004/12/11 00:29:01 spestov Exp $
./library/list-namespaces.factor:! $Id: list-namespaces.factor,v 1.12 2004/12/11 02:39:11 spestov Exp $
./library/inference/words.factor:! $Id: words.factor,v 1.13 2004/12/11 02:39:17 spestov Exp $
./library/inference/dataflow.factor:! $Id: dataflow.factor,v 1.17 2004/12/13 21:28:28 spestov Exp $
./library/assoc.factor:! $Id: assoc.factor,v 1.13 2005/01/01 22:20:46 spestov Exp $
./library/list-namespaces.factor:! $Id: list-namespaces.factor,v 1.13 2004/12/23 06:14:04 spestov Exp $
./library/inference/words.factor:! $Id: words.factor,v 1.34 2004/12/31 07:17:44 spestov Exp $
./library/inference/dataflow.factor:! $Id: dataflow.factor,v 1.21 2004/12/26 06:42:08 spestov Exp $
./library/inference/stack.factor:! $Id: stack.factor,v 1.10 2004/12/11 00:29:03 spestov Exp $
./library/inference/branches.factor:! $Id: branches.factor,v 1.17 2004/12/13 21:28:28 spestov Exp $
./library/inference/inference.factor:! $Id: inference.factor,v 1.15 2004/12/11 02:39:17 spestov Exp $
./library/vocabularies.factor:! $Id: vocabularies.factor,v 1.20 2004/12/18 04:02:18 spestov Exp $
./library/generic/object.factor:! $Id: object.factor,v 1.1 2004/12/13 05:13:54 spestov Exp $
./library/generic/builtin.factor:! $Id: builtin.factor,v 1.1 2004/12/13 05:13:54 spestov Exp $
./library/generic/generic.factor:! $Id: generic.factor,v 1.2 2004/12/15 21:57:27 spestov Exp $
./library/generic/predicate.factor:! $Id: predicate.factor,v 1.1 2004/12/13 05:13:54 spestov Exp $
./library/generic/traits.factor:! $Id: traits.factor,v 1.2 2004/12/15 21:57:27 spestov Exp $
./library/lists.factor:! $Id: lists.factor,v 1.36 2004/12/15 21:57:27 spestov Exp $
./library/stack.factor:! $Id: stack.factor,v 1.5 2004/12/11 02:39:11 spestov Exp $
./library/primitives.factor:! $Id: primitives.factor,v 1.7 2004/12/11 00:29:01 spestov Exp $
./library/cons.factor:! $Id: cons.factor,v 1.7 2004/12/15 21:57:26 spestov Exp $
./library/bootstrap/boot-stage2.factor:! $Id: boot-stage2.factor,v 1.19 2004/12/18 02:46:18 spestov Exp $
./library/bootstrap/image.factor:! $Id: image.factor,v 1.10 2004/12/15 21:57:27 spestov Exp $
./library/bootstrap/init-stage2.factor:! $Id: init-stage2.factor,v 1.11 2004/12/18 04:02:19 spestov Exp $
./library/bootstrap/primitives.factor:! $Id: primitives.factor,v 1.1 2004/12/15 21:57:27 spestov Exp $
./library/bootstrap/init.factor:! $Id: init.factor,v 1.5 2004/12/18 02:46:18 spestov Exp $
./library/bootstrap/boot.factor:! $Id: boot.factor,v 1.11 2004/12/18 04:02:19 spestov Exp $
./library/sdl/sdl-video.factor:! $Id: sdl-video.factor,v 1.12 2004/12/18 05:38:51 spestov Exp $
./library/inference/branches.factor:! $Id: branches.factor,v 1.39 2005/01/01 22:20:47 spestov Exp $
./library/inference/inference.factor:! $Id: inference.factor,v 1.27 2004/12/31 07:17:44 spestov Exp $
./library/inference/types.factor:! $Id: types.factor,v 1.2 2004/12/31 07:17:44 spestov Exp $
./library/vocabularies.factor:! $Id: vocabularies.factor,v 1.22 2004/12/25 23:08:18 spestov Exp $
./library/generic/object.factor:! $Id: object.factor,v 1.6 2004/12/29 23:01:22 spestov Exp $
./library/generic/builtin.factor:! $Id: builtin.factor,v 1.10 2004/12/29 23:01:22 spestov Exp $
./library/generic/generic.factor:! $Id: generic.factor,v 1.16 2005/01/01 22:20:47 spestov Exp $
./library/generic/predicate.factor:! $Id: predicate.factor,v 1.9 2004/12/31 07:17:43 spestov Exp $
./library/generic/traits.factor:! $Id: traits.factor,v 1.6 2005/01/01 23:02:22 spestov Exp $
./library/generic/union.factor:! $Id: union.factor,v 1.6 2004/12/29 23:01:22 spestov Exp $
./library/lists.factor:! $Id: lists.factor,v 1.44 2005/01/01 22:20:46 spestov Exp $
./library/stack.factor:! $Id: stack.factor,v 1.8 2004/12/24 07:51:59 spestov Exp $
./library/primitives.factor:! $Id: primitives.factor,v 1.20 2004/12/31 07:17:43 spestov Exp $
./library/cons.factor:! $Id: cons.factor,v 1.12 2005/01/01 22:20:46 spestov Exp $
./library/bootstrap/boot-stage2.factor:! $Id: boot-stage2.factor,v 1.31 2004/12/31 07:17:43 spestov Exp $
./library/bootstrap/win32-io.factor:! $Id: win32-io.factor,v 1.3 2004/12/29 07:15:59 eiz Exp $
./library/bootstrap/image.factor:! $Id: image.factor,v 1.15 2005/01/01 22:20:47 spestov Exp $
./library/bootstrap/init-stage2.factor:! $Id: init-stage2.factor,v 1.23 2004/12/29 08:35:43 spestov Exp $
./library/bootstrap/primitives.factor:! $Id: primitives.factor,v 1.11 2005/01/01 22:20:47 spestov Exp $
./library/bootstrap/init.factor:! $Id: init.factor,v 1.6 2004/12/24 04:55:21 spestov Exp $
./library/bootstrap/boot.factor:! $Id: boot.factor,v 1.16 2004/12/31 23:51:30 spestov Exp $
./library/sdl/sdl-video.factor:! $Id: sdl-video.factor,v 1.13 2004/12/25 23:08:19 spestov Exp $
./library/sdl/sdl.factor:! $Id: sdl.factor,v 1.5 2004/12/18 05:38:51 spestov Exp $
./library/sdl/sdl-gfx.factor:! $Id: sdl-gfx.factor,v 1.5 2004/12/18 04:02:19 spestov Exp $
./library/sdl/sdl-utils.factor:! $Id: sdl-utils.factor,v 1.6 2004/12/11 00:29:04 spestov Exp $
./library/sdl/sdl-utils.factor:! $Id: sdl-utils.factor,v 1.8 2004/12/26 23:52:58 spestov Exp $
./library/sdl/sdl-keysym.factor:! $Id: sdl-keysym.factor,v 1.1 2004/11/10 02:51:43 spestov Exp $
./library/sdl/sdl-keyboard.factor:! $Id: sdl-keyboard.factor,v 1.1 2004/12/26 23:52:58 spestov Exp $
./library/sdl/sdl-event.factor:! $Id: sdl-event.factor,v 1.9 2004/12/18 04:02:19 spestov Exp $
./library/format.factor:! $Id: format.factor,v 1.5 2004/12/11 00:29:01 spestov Exp $
./library/tools/jedit-wire.factor:! $Id: jedit-wire.factor,v 1.8 2004/12/11 23:18:43 spestov Exp $
./library/tools/heap-stats.factor:! $Id: heap-stats.factor,v 1.3 2004/12/11 00:29:07 spestov Exp $
./library/tools/inspector.factor:! $Id: inspector.factor,v 1.4 2004/12/11 02:39:18 spestov Exp $
./library/tools/debugger.factor:! $Id: debugger.factor,v 1.11 2004/12/13 04:49:44 spestov Exp $
./library/tools/jedit-wire.factor:! $Id: jedit-wire.factor,v 1.10 2005/01/01 22:20:48 spestov Exp $
./library/tools/heap-stats.factor:! $Id: heap-stats.factor,v 1.6 2004/12/29 08:35:46 spestov Exp $
./library/tools/debugger.factor:! $Id: debugger.factor,v 1.20 2004/12/29 08:35:45 spestov Exp $
./library/tools/profiler.factor:! $Id: profiler.factor,v 1.2 2004/12/11 00:29:07 spestov Exp $
./library/tools/jedit.factor:! $Id: jedit.factor,v 1.2 2004/12/11 00:29:07 spestov Exp $
./library/tools/listener.factor:! $Id: listener.factor,v 1.9 2004/12/13 20:37:49 spestov Exp $
./library/tools/interpreter.factor:! $Id: interpreter.factor,v 1.10 2004/12/18 02:46:19 spestov Exp $
./library/tools/word-tools.factor:! $Id: word-tools.factor,v 1.4 2004/12/18 04:02:19 spestov Exp $
./library/tools/telnetd.factor:! $Id: telnetd.factor,v 1.4 2004/12/11 00:29:07 spestov Exp $
./library/hashtables.factor:! $Id: hashtables.factor,v 1.13 2004/12/18 04:02:18 spestov Exp $
./library/syntax/prettyprint.factor:! $Id: prettyprint.factor,v 1.7 2004/12/13 04:49:44 spestov Exp $
./library/syntax/see.factor:! $Id: see.factor,v 1.4 2004/12/13 04:49:44 spestov Exp $
./library/tools/jedit.factor:! $Id: jedit.factor,v 1.3 2004/12/19 08:04:03 spestov Exp $
./library/tools/listener.factor:! $Id: listener.factor,v 1.13 2005/01/02 21:31:43 spestov Exp $
./library/tools/interpreter.factor:! $Id: interpreter.factor,v 1.13 2005/01/01 23:02:23 spestov Exp $
./library/tools/word-tools.factor:! $Id: word-tools.factor,v 1.7 2005/01/01 22:20:48 spestov Exp $
./library/tools/telnetd.factor:! $Id: telnetd.factor,v 1.5 2004/12/29 08:35:46 spestov Exp $
./library/hashtables.factor:! $Id: hashtables.factor,v 1.15 2004/12/28 05:04:19 spestov Exp $
./library/syntax/prettyprint.factor:! $Id: prettyprint.factor,v 1.12 2004/12/29 23:01:22 spestov Exp $
./library/syntax/see.factor:! $Id: see.factor,v 1.7 2004/12/30 07:40:14 spestov Exp $
./library/syntax/parse-syntax.factor:! $Id: parse-syntax.factor,v 1.7 2004/12/15 21:57:29 spestov Exp $
./library/syntax/parse-numbers.factor:! $Id: parse-numbers.factor,v 1.3 2004/12/16 23:36:26 spestov Exp $
./library/syntax/parse-stream.factor:! $Id: parse-stream.factor,v 1.3 2004/12/11 02:39:18 spestov Exp $
./library/syntax/parser.factor:! $Id: parser.factor,v 1.4 2004/12/15 21:57:29 spestov Exp $
./library/syntax/unparser.factor:! $Id: unparser.factor,v 1.5 2004/12/15 21:57:29 spestov Exp $
./library/gensym.factor:! $Id: gensym.factor,v 1.3 2004/12/11 00:29:01 spestov Exp $
./library/strings.factor:! $Id: strings.factor,v 1.22 2004/12/15 21:57:27 spestov Exp $
./library/in-thread.factor:! $Id: in-thread.factor,v 1.3 2004/12/11 00:29:01 spestov Exp $
./library/cli.factor:! $Id: cli.factor,v 1.5 2004/12/18 02:46:18 spestov Exp $
./library/eval-catch.factor:! $Id: eval-catch.factor,v 1.4 2004/12/11 00:29:01 spestov Exp $
./library/threads.factor:! $Id: threads.factor,v 1.2 2004/12/11 00:29:01 spestov Exp $
./library/sbuf.factor:! $Id: sbuf.factor,v 1.14 2004/12/11 00:29:01 spestov Exp $
./library/namespaces.factor:! $Id: namespaces.factor,v 1.19 2004/12/15 21:57:27 spestov Exp $
./library/syntax/parse-numbers.factor:! $Id: parse-numbers.factor,v 1.4 2004/12/19 04:18:32 spestov Exp $
./library/syntax/parse-stream.factor:! $Id: parse-stream.factor,v 1.4 2004/12/29 08:35:45 spestov Exp $
./library/syntax/parser.factor:! $Id: parser.factor,v 1.5 2004/12/29 08:35:45 spestov Exp $
./library/syntax/unparser.factor:! $Id: unparser.factor,v 1.8 2004/12/29 08:35:45 spestov Exp $
./library/gensym.factor:! $Id: gensym.factor,v 1.4 2004/12/29 08:35:43 spestov Exp $
./library/strings.factor:! $Id: strings.factor,v 1.29 2004/12/31 07:17:43 spestov Exp $
./library/in-thread.factor:! $Id: in-thread.factor,v 1.4 2004/12/26 02:28:46 spestov Exp $
./library/cli.factor:! $Id: cli.factor,v 1.10 2004/12/29 08:35:43 spestov Exp $
./library/eval-catch.factor:! $Id: eval-catch.factor,v 1.5 2004/12/26 02:28:46 spestov Exp $
./library/threads.factor:! $Id: threads.factor,v 1.4 2004/12/27 11:56:05 eiz Exp $
./library/sbuf.factor:! $Id: sbuf.factor,v 1.15 2004/12/19 08:04:01 spestov Exp $
./library/namespaces.factor:! $Id: namespaces.factor,v 1.21 2004/12/29 08:35:43 spestov Exp $
./library/io/vocabulary-style.factor:! $Id: vocabulary-style.factor,v 1.2 2004/12/11 00:29:04 spestov Exp $
./library/io/ansi.factor:! $Id: ansi.factor,v 1.5 2004/12/11 23:18:42 spestov Exp $
./library/io/network.factor:! $Id: network.factor,v 1.4 2004/12/11 23:18:42 spestov Exp $
./library/io/ansi.factor:! $Id: ansi.factor,v 1.8 2004/12/29 08:35:45 spestov Exp $
./library/io/win32-io-internals.factor:! $Id: win32-io-internals.factor,v 1.4 2004/12/29 07:16:03 eiz Exp $
./library/io/network.factor:! $Id: network.factor,v 1.5 2004/12/27 11:56:05 eiz Exp $
./library/io/win32-stream.factor:! $Id: win32-stream.factor,v 1.6 2005/01/02 21:14:21 eiz Exp $
./library/io/stdio-binary.factor:! $Id: stdio-binary.factor,v 1.2 2004/12/11 00:29:04 spestov Exp $
./library/io/io-internals.factor:! $Id: io-internals.factor,v 1.3 2004/12/15 21:57:28 spestov Exp $
./library/io/presentation.factor:! $Id: presentation.factor,v 1.2 2004/12/11 00:29:04 spestov Exp $
./library/io/io-internals.factor:! $Id: io-internals.factor,v 1.5 2004/12/27 11:56:05 eiz Exp $
./library/io/presentation.factor:! $Id: presentation.factor,v 1.3 2004/12/20 20:29:54 spestov Exp $
./library/io/stream-impl.factor:! $Id: stream-impl.factor,v 1.5 2004/12/11 23:18:42 spestov Exp $
./library/io/stream.factor:! $Id: stream.factor,v 1.5 2004/12/15 21:57:28 spestov Exp $
./library/io/files.factor:! $Id: files.factor,v 1.3 2004/12/15 21:57:28 spestov Exp $
./library/io/buffer.factor:! $Id: buffer.factor,v 1.4 2005/01/02 21:14:21 eiz Exp $
./library/io/stream.factor:! $Id: stream.factor,v 1.8 2004/12/29 08:35:45 spestov Exp $
./library/io/files.factor:! $Id: files.factor,v 1.5 2005/01/01 22:20:47 spestov Exp $
./library/io/logging.factor:! $Id: logging.factor,v 1.3 2004/12/11 00:29:04 spestov Exp $
./library/io/stdio.factor:! $Id: stdio.factor,v 1.5 2004/12/11 23:18:42 spestov Exp $
./factor/ExternalFactor.java: * $Id: ExternalFactor.java,v 1.7 2004/12/10 07:41:43 spestov Exp $
./library/io/stdio.factor:! $Id: stdio.factor,v 1.8 2004/12/29 08:35:45 spestov Exp $
./library/io/win32-console.factor:! $Id: win32-console.factor,v 1.5 2004/12/29 08:35:45 spestov Exp $
./library/io/win32-server.factor:! $Id: win32-server.factor,v 1.3 2005/01/02 21:14:21 eiz Exp $
./factor/ExternalFactor.java: * $Id: ExternalFactor.java,v 1.12 2005/01/02 21:22:11 spestov Exp $
./factor/math/Complex.java: * $Id: Complex.java,v 1.1.1.1 2004/07/16 06:26:13 spestov Exp $
./factor/math/FactorNumber.java: * $Id: FactorNumber.java,v 1.1.1.1 2004/07/16 06:26:12 spestov Exp $
./factor/math/NumberParser.java: * $Id: NumberParser.java,v 1.2 2004/08/07 22:45:47 spestov Exp $
@ -114,21 +124,21 @@
./factor/FactorSymbolDefinition.java:* $Id: FactorSymbolDefinition.java,v 1.4 2004/12/06 00:42:55 spestov Exp $
./factor/FactorLib.java: * $Id: FactorLib.java,v 1.8 2004/11/17 04:04:50 spestov Exp $
./factor/ReadTable.java: * $Id: ReadTable.java,v 1.4 2004/09/06 00:14:36 spestov Exp $
./factor/FactorReader.java: * $Id: FactorReader.java,v 1.14 2004/12/12 21:32:38 spestov Exp $
./factor/FactorReader.java: * $Id: FactorReader.java,v 1.15 2004/12/20 21:06:42 spestov Exp $
./factor/FactorParsingDefinition.java: * $Id: FactorParsingDefinition.java,v 1.3 2004/11/17 04:04:50 spestov Exp $
./factor/FactorTraitsDefinition.java:* $Id: FactorTraitsDefinition.java,v 1.1 2004/12/06 00:42:55 spestov Exp $
./factor/Cons.java: * $Id: Cons.java,v 1.3 2004/11/17 04:04:50 spestov Exp $
./factor/FactorGenericDefinition.java:* $Id: FactorGenericDefinition.java,v 1.1 2004/12/06 00:42:55 spestov Exp $
./factor/FactorCompoundDefinition.java:* $Id: FactorCompoundDefinition.java,v 1.7 2004/12/06 00:42:55 spestov Exp $
./factor/DefaultVocabularyLookup.java: * $Id: DefaultVocabularyLookup.java,v 1.3 2004/12/12 21:32:38 spestov Exp $
./factor/DefaultVocabularyLookup.java: * $Id: DefaultVocabularyLookup.java,v 1.5 2004/12/20 00:36:10 spestov Exp $
./factor/parser/ComplexLiteral.java: * $Id: ComplexLiteral.java,v 1.4 2004/11/17 04:04:50 spestov Exp $
./factor/parser/Base.java: * $Id: Base.java,v 1.3 2004/11/17 04:04:50 spestov Exp $
./factor/parser/Symbol.java: * $Id: Symbol.java,v 1.5 2004/12/06 00:42:55 spestov Exp $
./factor/parser/NoParsing.java: * $Id: NoParsing.java,v 1.3 2004/11/17 04:04:50 spestov Exp $
./factor/parser/Traits.java: * $Id: Traits.java,v 1.2 2004/12/12 21:32:46 spestov Exp $
./factor/parser/Traits.java: * $Id: Traits.java,v 1.3 2004/12/20 02:07:16 spestov Exp $
./factor/parser/StringLiteral.java: * $Id: StringLiteral.java,v 1.3 2004/11/17 04:04:50 spestov Exp $
./factor/parser/Bar.java: * $Id: Bar.java,v 1.3 2004/11/17 04:04:50 spestov Exp $
./factor/parser/BeginMethod.java: * $Id: BeginMethod.java,v 1.2 2004/12/12 21:32:46 spestov Exp $
./factor/parser/BeginMethod.java: * $Id: BeginMethod.java,v 1.3 2004/12/23 03:16:44 spestov Exp $
./factor/parser/Def.java: * $Id: Def.java,v 1.8 2004/12/06 00:42:55 spestov Exp $
./factor/parser/F.java: * $Id: F.java,v 1.3 2004/11/17 04:04:50 spestov Exp $
./factor/parser/CharLiteral.java: * $Id: CharLiteral.java,v 1.6 2004/11/17 04:04:50 spestov Exp $
@ -147,18 +157,19 @@
./factor/parser/In.java: * $Id: In.java,v 1.5 2004/12/12 21:32:46 spestov Exp $
./factor/parser/BeginVector.java: * $Id: BeginVector.java,v 1.2 2004/11/17 04:04:50 spestov Exp $
./factor/FactorWord.java: * $Id: FactorWord.java,v 1.10 2004/12/05 23:33:19 spestov Exp $
./factor/VocabularyLookup.java: * $Id: VocabularyLookup.java,v 1.1 2004/11/26 02:53:27 spestov Exp $
./factor/VocabularyLookup.java: * $Id: VocabularyLookup.java,v 1.3 2004/12/20 00:36:10 spestov Exp $
./factor/jedit/FactorAsset.java: * $Id: FactorAsset.java,v 1.5 2004/11/19 22:28:23 spestov Exp $
./factor/jedit/FactorParsedData.java: * $Id: FactorParsedData.java,v 1.3 2004/09/04 05:05:49 spestov Exp $
./factor/jedit/FactorParsedData.java: * $Id: FactorParsedData.java,v 1.4 2004/12/19 06:48:31 spestov Exp $
./factor/jedit/RestartableFactorScanner.java: * $Id: RestartableFactorScanner.java,v 1.3 2004/12/12 21:32:46 spestov Exp $
./factor/jedit/FactorSideKickParser.java: * $Id: FactorSideKickParser.java,v 1.17 2004/11/26 01:37:04 spestov Exp $
./factor/jedit/EditWordDialog.java: * $Id: EditWordDialog.java,v 1.5 2004/11/26 01:37:04 spestov Exp $
./factor/jedit/FactorPlugin.java: * $Id: FactorPlugin.java,v 1.30 2004/12/15 21:57:26 spestov Exp $
./factor/jedit/FactorSideKickParser.java: * $Id: FactorSideKickParser.java,v 1.22 2004/12/24 04:55:21 spestov Exp $
./factor/jedit/EditWordDialog.java: * $Id: EditWordDialog.java,v 1.6 2004/12/20 00:36:10 spestov Exp $
./factor/jedit/FactorPlugin.java: * $Id: FactorPlugin.java,v 1.39 2005/01/02 21:31:43 spestov Exp $
./factor/jedit/FactorOptionPane.java: * $Id: FactorOptionPane.java,v 1.2 2004/11/27 03:23:55 spestov Exp $
./factor/jedit/FactorShell.java: * $Id: FactorShell.java,v 1.8 2004/12/06 00:42:55 spestov Exp $
./factor/jedit/FactorCompletion.java: * $Id: FactorCompletion.java,v 1.7 2004/11/26 01:37:04 spestov Exp $
./factor/jedit/FactorShell.java: * $Id: FactorShell.java,v 1.10 2004/12/29 23:01:22 spestov Exp $
./factor/jedit/FactorCompletion.java: * $Id: FactorCompletion.java,v 1.9 2004/12/31 01:46:19 spestov Exp $
./factor/jedit/WordPreview.java: * $Id: WordPreview.java,v 1.9 2004/12/05 23:33:19 spestov Exp $
./factor/jedit/WordListDialog.java: * $Id: WordListDialog.java,v 1.2 2004/09/04 05:05:49 spestov Exp $
./factor/jedit/WordListDialog.java: * $Id: WordListDialog.java,v 1.4 2004/12/20 02:06:55 spestov Exp $
./factor/jedit/WordPopup.java: * $Id: WordPopup.java,v 1.1 2004/12/20 23:02:42 spestov Exp $
./factor/jedit/ListenerAttributeSet.java: * $Id: ListenerAttributeSet.java,v 1.4 2004/11/26 04:14:16 spestov Exp $
./factor/jedit/FactorWordRenderer.java: * $Id: FactorWordRenderer.java,v 1.13 2004/12/06 00:42:55 spestov Exp $
./factor/jedit/InsertUseDialog.java: * $Id: InsertUseDialog.java,v 1.3 2004/09/04 05:05:49 spestov Exp $

View File

@ -23,7 +23,8 @@ OBJS = native/arithmetic.o native/array.o native/bignum.o \
native/unix/signal.o \
native/unix/read.o \
native/unix/write.o \
native/unix/ffi.o
native/unix/ffi.o \
native/debug.o
default:
@echo "Run 'make' with one of the following parameters:"

20
README.WIN32.txt Normal file
View File

@ -0,0 +1,20 @@
FACTOR ON WINDOWS
The Windows port of Factor requires Windows 2000 or later. If you are
using Windows 95, 98 or NT, you might be able to get the Unix port of
Factor running inside Cygwin. Or you might not.
A precompiled factor.exe is included with the download, along with
SDL.dll and SDL_gfx.dll. The SDL libraries are required for the
interactive interpreter. Factor does not use the Windows console,
because it does not support asynchronous I/O.
To run the Windows port, open a DOS prompt and type:
cd <directory where Factor is installed>
factor.exe boot.image.le32
... Files are loaded and factor.image is written.
factor.exe factor.image
... Factor starts the SDL console now.

View File

@ -1,39 +1,17 @@
[error] AWT-EventQueue-0: java.lang.NullPointerException
[error] AWT-EventQueue-0: at org.gjt.sp.jedit.Buffer.markTokens(Buffer.java:2109)
[error] AWT-EventQueue-0: at factor.jedit.WordPreview.getWordAtCaret(WordPreview.java:95)
[error] AWT-EventQueue-0: at factor.jedit.WordPreview.showPreview(WordPreview.java:137)
[error] AWT-EventQueue-0: at factor.jedit.WordPreview.actionPerformed(WordPreview.java:79)
[error] AWT-EventQueue-0: at javax.swing.Timer.fireActionPerformed(Timer.java:271)
+ compiler:
+ inference/dataflow:
- type inference
- handle odd base cases, with code after ifte
- handle recursion with when, when* etc
+ linearizer/generator:
- peephole optimizer
- optimize away dispatch
- getenv/setenv: if literal arg, compile as a load/store
- compiler: drop literal peephole optimization
+ compiler frontend:
- assembler opcodes dispatch on operand types
- save code in image
- compile word twice; no more 'cannot compile' error!
+ oop:
- union metaclass
- make M: order-independent
- bootstrapping generic words
- 2generic
- move generic, 2generic from kernel vocabulary
- generic = hashcode and math ops
- make see work with union, builtin, predicate
- doc comments of generics
+ ffi:
- figure out how to load an image referring to missing libraries
- is signed -vs- unsigned pointers an issue?
- bitfields in C structs
- SDL_Rect** type
@ -42,40 +20,33 @@
+ listener/plugin:
- word added >1
- sidekick: still parsing too much
- WordPreview calls markTokens() -> NPE
- stream server can hang because of exception handler limitations
- listener should be multithreaded
- compile all, infer all commands
- faster completion
- errors don't always disappear
- console: wrong history
- listener: if too many things popped off the stack, complain
- NPE in ErrorHighlight
- some way to not have previous definitions from a source file
clutter the namespace
- maple-like: press enter at old commands to evaluate there
- completion in the listener
- special completion for USE:/IN:
+ kernel:
- profiler is inaccurate: wrong word on cs
- do partial objects cause problems?
- better i/o scheduler
- remove sbufs
- cat, reverse-cat primitives
- first-class hashtables
- rewrite accessors and mutators in Factor, with slot/set-slot primitive
- replace -export-dynamic with sundry-xt
- add a socket timeout
+ misc:
- step: print NEXT word to execute, not word that JUST executed
- perhaps /i should work with all numbers
- unit test weirdness: 2 lines appears at end
- jedit ==> jedit-word, jedit takes a file name
- command line parsing cleanup
- nicer way to combine two paths
- ditch object paths
- browser responder for word links in HTTPd; inspect responder for
objects
- browser responder for word links in HTTPd
- worddef props
- prettyprint: when unparse called due to recursion, write a link

View File

@ -49,7 +49,7 @@
</ACTION>
<ACTION NAME="factor-see">
<CODE>
FactorPlugin.factorWordOutputOp(view,"see");
WordPopup.showWordPopup(textArea);
</CODE>
</ACTION>
<ACTION NAME="factor-edit">

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -28,9 +28,8 @@ IN: browser
USE: html
USE: cont-responder
USE: cont-utils
USE: stack
USE: kernel
USE: stdio
USE: combinators
USE: namespaces
USE: words
USE: lists

View File

@ -25,7 +25,7 @@
IN: cont-examples
USE: cont-responder
USE: html
USE: stack
USE: kernel
USE: stdio
USE: html
USE: lists

View File

@ -40,7 +40,6 @@ USE: parser
USE: html
USE: cont-responder
USE: cont-utils
USE: stack
USE: stdio
USE: namespaces

View File

@ -28,16 +28,12 @@ USE: httpd
USE: httpd-responder
USE: math
USE: random
USE: continuations
USE: namespaces
USE: stack
USE: combinators
USE: streams
USE: lists
USE: strings
USE: html
USE: kernel
USE: logic
USE: html
USE: logging
USE: url-encoding

View File

@ -86,7 +86,7 @@
! etc.
IN: cont-responder
USE: namespaces
USE: stack
USE: kernel
USE: combinators
USE: stdio

View File

@ -28,10 +28,9 @@ USE: html
USE: cont-responder
USE: lists
USE: stdio
USE: stack
USE: kernel
USE: namespaces
USE: html
USE: combinators
: simple-page ( title quot -- )
#! Call the quotation, with all output going to the
@ -86,7 +85,7 @@ USE: combinators
#! Run the quotation inside an HTML stream wrapped
#! around stdio.
<pre>
"stdio" get <html-stream> [
stdio get <html-stream> [
call
] with-stream
</pre> ;

View File

@ -27,7 +27,7 @@ IN: eval-responder
USE: html
USE: cont-responder
USE: cont-utils
USE: stack
USE: kernel
USE: stdio
USE: namespaces
USE: streams
@ -36,7 +36,6 @@ USE: lists
USE: errors
USE: strings
USE: logic
USE: combinators
USE: live-updater
USE: prettyprint
USE: unparser

View File

@ -30,7 +30,6 @@ USE: namespaces
USE: html
USE: words
USE: stdio
USE: stack
USE: kernel
USE: cont-utils
USE: cont-responder
@ -42,7 +41,7 @@ USE: prettyprint
<namespace> [
"responder" "inspect" put
<pre>
"stdio" get <html-stream> [
stdio get <html-stream> [
apropos.
] with-stream
</pre>

View File

@ -24,7 +24,7 @@
! cont-responder code for display forms and anchors that use XMLHttpRequest
! and the 'liveUpdater.js' code.
IN: live-updater
USE: stack
USE: kernel
USE: streams
USE: strings
USE: html
@ -32,7 +32,6 @@ USE: cont-responder
USE: stdio
USE: namespaces
USE: lists
USE: combinators
: get-live-updater-js* ( stream -- string )
#! Read all lines from the stream, creating a string of the result.

View File

@ -23,12 +23,11 @@
!
! Start an httpd server and some words to re-load the continuation
! server files.
USE: kernel
USE: httpd-responder
USE: httpd
USE: threads
USE: stack
USE: prettyprint
USE: combinators
USE: errors
USE: stdio

View File

@ -32,18 +32,15 @@ USE: html
USE: cont-utils
USE: html
USE: stdio
USE: stack
USE: strings
USE: namespaces
USE: inspector
USE: lists
USE: combinators
USE: cont-examples
USE: regexp
USE: prettyprint
USE: todo
USE: math
USE: logic
USE: kernel
: todo-stylesheet ( -- string )
@ -191,12 +188,19 @@ USE: kernel
: valid-username-char ( ch -- b )
#! Return true if the character is valid to appear in a username.
[
[ letter? ] [ drop t ]
[ LETTER? ] [ drop t ]
[ digit? ] [ drop t ]
[ ] [ drop f ]
] cond ;
dup letter? [
drop t
] [
dup LETTER? [
drop t
] [
digit? [
t
] [
f
] ifte
] ifte
] ifte ;
: replace-invalid-username-chars ( str -- str )
#! Return a string with invalid username characters mapped to underscores.

View File

@ -26,7 +26,6 @@
! complete.
IN: todo
USE: parser
USE: stack
USE: strings
USE: streams
USE: namespaces
@ -37,9 +36,7 @@ USE: kernel
USE: prettyprint
USE: unparser
USE: url-encoding
USE: combinators
USE: files
USE: logic
USE: hashtables
: <todo> ( user password -- <todo> )

124
doc/bootstrap.txt Normal file
View File

@ -0,0 +1,124 @@
THE BOOTSTRAP PROCESS
* Why bother?
Factor cannot be built entirely from source. That is, certain parts -- such as the parser itself -- are written in entirely in Factor, thus to build a new Factor system, one needs to be running an existing Factor system.
The Factor runtime, coded in C, knows nothing of the syntax of Factor source files, or even the organization of words into vocabularies. Most conventional languages fall into two implementation styles:
- A single monolithic executable is shipped, with most of the language written in low level code. This includes Python, Perl, and so on. This approach has the disadvantage that the language is less flexible, due to the large native substrate.
- A smaller interpreter/compiler is shipped, that reads bytecode or source files from disk, and constructs the standard library on startup. This has the disadvantage of slow startup time. This includes Java.
* How does it work?
Factor takes a superior approach, used by Lisp and Smalltalk implementations, where initialization consists of loading a memory image. Execution then begins immediately. New images can be generated in one of two ways:
- Saving the current memory heap to disk as a new image file.
This is easily done and easily implemented:
"foo.image" save-image
Since this simply saves a copy of the entire heap to a file, no more will be said about it here.
- Generating a new image from sources.
If the former was the only way to save code changes to an image, things would be out of hand. For example, if the runtime's object format has to change, one would have to write a tool to read an image, convert each object, and write it out again. Or if new primitives were added, or the major parts of the library needed a reorganization... things would get messy.
Generating a new image from source is called 'bootstrapping'. Bootstrapping is the topic of the remainder of this document.
Some terminology: the current running Factor image, the one generating the bootstrap image, is a 'host' image; the bootstrap image being generated is a 'target' image.
* General overview of the bootstrap process
While Factor cannot be built entirely from source, bootstrapping allows one to use an existing Factor implementation, that is up to date with respect to the sources one is bootstrapping from, to build a new image in a reasonably clean and controlled manner.
Bootstrapping proceeds in two stages:
- In first stage, the make-image word is used to generate a stage 1 image. The make-image word is defined in /library/bootstrap, and is called like so:
"foo.image" make-image
Unlike save-image, make-image actually writes out each object 'manually', without dumping memory; this allows the object format to be changed, by modifying /library/bootstrap/image.factor.
- In the second stage, one runs the Factor interpreter, passing the stage 1 image on the command line. The stage 1 image then proceeds to load remaining source files from disk, finally producing a completed image, that can in turn make new images, etc.
Now, lets look at each stage in detail.
* Stage 1 bootstrap
The first stage is by far the most interesting.
Take a careful look at the words for searching vocabularies in /library/vocabularies.factor.
They all access the vocabulary hash by accessing the 'vocabulary' variable in the current namespace; so if one calls these words in a dynamic scope where this variable is set to something other than the global vocabulary hash, interesting things can happen.
(Note there is little risk of accidental capture here; you can name a variable 'vocabularies', and it won't clash unless you actually define it as a symbol in the 'words' vocabulary, which you won't do.)
** Setting up the target environment
After initializing some internal objects, make-image runs the file /library/bootstrap/boot.factor. Bootstrapping is performed in new dynamic scope, so that vocabularies can be overriden.
The first file run by bootstrapping is /library/bootstrap/primitives.factor.
This file sets up an initially empty target image vocabulary hash; then, it copies 'syntax' and 'generic' vocabularies from the host vocabulary hash to the target vocabulary hash. Then, it adds new words, one for each primitive, to the target vocabulary hash.
Files are run after being fully parsed; since the host vocabulary hash is in scope when primitives.factor is parsed, primitives.factor can still make use of host words. However, after primitives.factor is run, the bootstrap vocabulary is very bare; containing syntax parsing and primitives only.
** Bootstrapping the core library
Bootstrapping then continues, and loads various source files into the target vocabulary hash. Each file loaded must only refer to primitive words, and words loaded from previous files. So by reading through each file referenced by boot.factor, you can see the entire construction of the core of Factor, from the bottom up!
After most files being loaded, there is still a problem; the 'syntax' and 'generic' vocabularies in the target image were copied from the host image, and not loaded from source. The generic vocabulary is overwritten near the end of bootstrap, by loading in the relevant source files.
(The reason 'generic' words have to be copied first, and not loaded in order, is that the parsing words in this vocabulary are used to define dispatch classes. This will be documented separately.)
** Bootstrapping syntax parsing words
So much for 'generic'. Bootstrapping the syntax words is a slightly tougher problem. Since the syntax vocabulary parses source files itself, a delicate trick must be performed.
Take a look at the start of /library/syntax/parse-syntax.factor:
IN: !syntax
USE: syntax
This file defines parsing words such as [ ] : ; and so on. As you can see, the file itself is parsed using the host image 'syntax' vocabulary, but the new parsing words are defined in a '!syntax' vocabulary.
After loading parse-syntax.factor, boot.factor then flips the two vocabularies, and renames each word in '!syntax':
vocabularies get [
"!syntax" get "syntax" set
"syntax" get [
cdr dup word? [
"syntax" "vocabulary" set-word-property
] [
drop
] ifte
] hash-each
] bind
"!syntax" vocabularies get remove-hash
The reason parse-syntax.factor can't do IN: syntax is that because about half way through parsing it, its own words would start executing. But we can *never* execute target image words in the host image -- for example, the target image might have a different set of primitives, different runtime layout, and so on.
* Saving the stage 1 image
Once /library/bootstrap/boot.factor completes executing, make-image resumes, and it now has a nice, shiny new vocabularies hash ready to save to a target image. It then outputs this hash to a file, along with various auxilliary objects, using the precise object format required by the runtime.
It also outputs a 'boot quotation'. The boot quotation is executed by the interpreter as soon as the target image is loaded, and leads us to stage 2; but first, a little hack.
** The transfer hack
Some parsing words generate code in the target image vocabulary. However, since the host image parsing words are actually executing during bootstrap, the generated code refers to host image words. The bootstrapping code performs a 'transfer' where each host image word that is referred to in the target image is replaced with the identically-named target image word.
* On to stage 2
The boot quotation left behind from stage 1 simply runs the /library/bootstrap/boot-stage2.factor file.
This file begins by reloading each source file loaded in stage 1. This is for convinience; after changing some core library files, it is faster for the developer to just redo stage 2, and get an up to date image, instead of doing the whole stage 1 process again.
After stage 1 has been redone, stage 2 proceeds to load more library files. Basically, stage 1 only has barely enough to begin parsing source files from disk; stage 2 loads everything else, like development tools, the compiler, HTTP server. etc.
Stage 2 finishes by running /library/bootstrap/init-stage2.factor, which infers stack effects and performs various cleanup tasks. Then, it uses the 'save-image' word to save a memory dump, which becomes a shiny new 'factor.image', ready for hacking, and ready for bootstrapping more new images!

View File

@ -334,12 +334,7 @@ matters (\texttt{-} and \texttt{/}), the operands are taken in the natural order
\textbf{111}
\end{alltt}
The \texttt{neg} unary operator negates the number at the top of the stack (that is, multiplies it by -1). Two unary operators \texttt{pred} and \texttt{succ} subtract 1 and add 1, respectively, to the number at the top of the stack.
\begin{alltt}
\textbf{ok} 5 pred pred succ neg .
\textbf{-4}
\end{alltt}
The \texttt{neg} word negates the number at the top of the stack (that is, multiplies it by -1).
This type of arithmetic is called \emph{postfix}, because the operator
follows the operands. Contrast this with \emph{infix} notation used
@ -693,6 +688,10 @@ Entering colon definitions at the listener is very convenient for quick testing,
Lets put our program for solving quadratic equations in a source file. Create a file named \texttt{quadratic.factor} in your favorite editor, and add the following content:
\begin{verbatim}
IN: quadratic
USE: math
USE: kernel
: quadratic-e ( b a -- -b/2a )
2 * / neg ;

Binary file not shown.

After

Width:  |  Height:  |  Size: 333 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 165 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 174 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 288 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 288 B

BIN
doc/devel-guide/ch_end.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 171 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 278 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 190 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 333 B

BIN
doc/devel-guide/image.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 244 B

BIN
doc/devel-guide/index.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 246 B

BIN
doc/devel-guide/next.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 245 B

BIN
doc/devel-guide/next_g.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 272 B

BIN
doc/devel-guide/nx_grp.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 314 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 386 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 333 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 332 B

BIN
doc/devel-guide/prev.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 279 B

BIN
doc/devel-guide/prev_g.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 327 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 332 B

BIN
doc/devel-guide/pv_grp.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 352 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 430 B

BIN
doc/devel-guide/redball.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 332 B

BIN
doc/devel-guide/up.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 211 B

BIN
doc/devel-guide/up_g.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 231 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 229 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 333 B

272
doc/generic.txt Normal file
View File

@ -0,0 +1,272 @@
THE FACTOR GENERIC WORD SYSTEM
Factor's generic word system is a very abstract generalization of
"object oriented" features found in other programming languges.
To use the generic word system, you must put the following near the
beginning of your source file:
USE: generic
The key motivation is that sometimes, you want to write a word that has
differing behavior depending on the class of its argument. For example,
in a game, a 'draw' word could take different action if given a ship, a
weapon, a planet, etc.
Duplicating 'type case' logic is undesirable and also results in
unnecessary coupling -- adding support for a new type of graphical
object would require modifying the original definition of 'draw', for
example.
* Types
In Factor, the idea of a 'type' refers to a very concrete concept. The
type of an object is its representation in runtime object memory. Types
include fixnums, bignums, cons cells, vectors, strings, and so on. The
set of available types is fixed; adding a new type requires modifying
the runtime source written in C.
* Classes
In Factor, a 'class' is just a predicate that categorizes objects as
being a member of the class or not. To be useful, it must be consistent
-- for a given object, it must always return the same truth value.
Examples of classes might include:
- Cons cells where both elements are integers
- Floating point numbers between -1 and 1
- Hash tables holding a certain key
- Any object that occurs as a member of a certain global variable
holding a list.
- ... and so on.
As you can see, a class of objects does not need to be a subset or a
superset of a type of objects.
Classes, unlike types, can be defined by the user.
* Generic words
A generic word is a word whose behavior depends on the class of the
object at the top of the stack.
Generic words are defined using the following syntax:
GENERIC: draw ( actor -- )
#! Draw the actor.
A stack effect comment, as above, is not required but recommended.
* Methods
A method associates behavior to a generic word. Methods are defined by
writing M:, followed by a class name, followed by the name of a
previously-defined generic word.
One of the main benefits of generic words is that each method definition
can potentially occur in a different source file. Generic word
definitions also hide conditionals.
Here are two methods for the generic 'draw' word:
M: ship draw ( actor -- )
[
surface get screen-xy radius get color get
filledCircleColor
] bind ;
M: plasma draw ( actor -- )
[
surface get screen-xy dup len get + color get
vlineColor
] bind ;
Here, 'ship' and 'class' are user-defined classes.
* Metaclasses
To understand what classes already exist, and how to define your own
classes, the concept of a 'metaclass' must be grasped first. Roughly
speaking, a metaclass is a class of classes.
New metaclasses can be defined by the user, but its an involved process
that requires a deeper understanding of the generic word systsem than
can be given here.
** The object class
Every object is a member of the object class. The object class is also a
metaclass, and it is the one and only instance of itself.
Confusing? The idea is pretty simple. If you define a method on
'object', it will be called when no more specific method is available:
GENERIC: describe
M: number describe "The number " write . ;
M: object describe "I don't know anything about " write . ;
Since the only instance of the object metaclass is itself, you cannot
define new classes in the object metaclass.
** The builtin metaclass
The builtin metaclass contains precisely the following classes; each
class corresponds to a runtime type:
alien
array
bignum
complex
cons
dll
f
fixnum
float
port
ratio
sbuf
string
t
vector
word
Each builtin class has a corresponding membership test predicate, named
after the builtin class suffixed with '?'. For example, cons?, word?,
etc.
Adding new classes to the builtin metaclass requires modifications to
the C code comprising Factor's runtime.
** The union metaclass
The union metaclass contains classes whose members are defined to be the
aggregate of the members of a list of existing classes.
For example, the Factor library defines some unions over numeric types:
UNION: integer fixnum bignum ;
UNION: rational integer ratio ;
UNION: real rational float ;
UNION: number real complex ;
Now, the absolute value function can be defined in an efficient manner
for real numbers, and in a more general fashion for complex numbers:
GENERIC: abs ( z -- |z| )
M: real abs dup 0 < [ neg ] when ;
M: complex abs >rect mag2 ;
New unions can be defined by you, and the numerical types example above
gives the syntax: you write UNION: followed by the name of the union,
followed by its members. The list of members is terminated with a
semi-colon.
A predicate named after the union followed by '?' is
automatically-defined. For example, the following definition of 'real?'
was automatically created:
: real?
dup rational? [
drop t
] [
dup float? [
drop t
] [
drop f
] ifte
] ifte ;
** The predicate metaclass
The predicate metaclass contains classes whose membership test is an
arbitrary expression. To speed up dispatch, each predicate must be
defined as a subclass of some other class. That way predicates
subclassing from disjoint builtin classes do not need to be
simultaenously tested.
The library/strings.factor module defines some subclasses of integer,
classifying the different types of ASCII characters:
PREDICATE: integer blank " \t\n\r" str-contains? ;
PREDICATE: integer letter CHAR: a CHAR: z between? ;
PREDICATE: integer LETTER CHAR: A CHAR: Z between? ;
PREDICATE: integer digit CHAR: 0 CHAR: 9 between? ;
PREDICATE: integer printable CHAR: \s CHAR: ~ between? ;
Each predicate defines a corresponding predicate word whose name is
suffixed with '?'; for example, a 'digit?' word is automatically
defined:
: digit?
dup integer? [
CHAR: 0 CHAR: 9 between?
] [
drop f
] ifte ;
For obvious reasons, the predicate definition must consume and produce
exactly one value on the stack.
** The traits metaclass
(The name for this metaclass is wrong and will change eventually. The
original idea was to allow an object to inherit any number of 'traits',
thus they would behave like mixins. This never materialized.)
The traits metaclass allows one to associate more fine-grained behavior,
specifically with hashtables.
New classes can be defined like so:
TRAITS: plasma
In terms of behavior, this is actually identical to the following:
PREDICATE: hashtable plasma \ traits swap hash plasma = ;
However, it is far more efficient (and less verbose).
You can define methods as usual:
GENERIC: collide ( actor1 actor2 -- )
M: plasma collide ( actor1 actor2 -- )
#! Remove the other actor.
deactivate deactivate ;
How does one actually get an object that plasma? responds with t to? You
define a constructor word by writing C: followed by the class name:
C: plasma ( actor dy -- plasma )
[
velocity set
actor-xy
blue color set
10 len set
5 radius set
active on
] extend ;
The constructor word is named after the class, surrounded in angle
brackets (< and >). For example, the above actually creates a word named
<plasma>.
The constructor's definition begins with the parameters given by the
user, underneath a blank plasma object.
That is, a dummy constructor just returns a blank hashtable that
responds t to the corresponding membership predicate:
TRAITS: foo
C: foo ;
<foo> foo? .
==> t
"hello" foo? .
==> f

View File

@ -1,9 +1,15 @@
! DeJong attractor renderer.
! To run this code, start your interpreter like so:
!
! ./f -libraries:sdl=libSDL.so -libraries:sdl-gfx=libSDL_gfx.so
! To run this code, bootstrap Factor like so:
!
! Then, enter this at the interpreter prompt:
! ./f boot.image.le32
! -libraries:sdl:name=libSDL.so
! -libraries:sdl-gfx:name=libSDL_gfx.
!
! (But all on one line)
!
! Then, start Factor as usual (./f factor.image) and enter this
! at the listener:
!
! "examples/dejong.factor" run-file
@ -19,6 +25,8 @@ USE: sdl-video
USE: namespaces
USE: math
USE: kernel
USE: test
USE: compiler
SYMBOL: a
SYMBOL: b
@ -58,6 +66,6 @@ SYMBOL: d
<event> event-loop
SDL_Quit
] with-screen ;
] with-screen ; compiled
dejong
[ dejong ] time

View File

@ -1,8 +1,15 @@
! A simple space shooter.
!
! To play the game:
! To run this code, bootstrap Factor like so:
!
! ./f factor.image -libraries:sdl=libSDL.so -libraries:sdl-gfx=libSDL_gfx.so
! ./f boot.image.le32
! -libraries:sdl:name=libSDL.so
! -libraries:sdl-gfx:name=libSDL_gfx.
!
! (But all on one line)
!
! Then, start Factor as usual (./f factor.image) and enter this
! at the listener:
!
! "examples/factoroids.factor" run-file

View File

@ -8,7 +8,7 @@ USE: words
: vector-peek ( vector -- obj )
#! Get value at end of vector without removing it.
dup vector-length pred swap vector-nth ;
dup vector-length 1 - swap vector-nth ;
SYMBOL: exprs
DEFER: infix

View File

@ -1,9 +1,15 @@
! Graphical mandelbrot fractal renderer.
! To run this code, start your interpreter like so:
!
! ./f -libraries:sdl=libSDL.so -libraries:sdl-gfx=libSDL_gfx.so
! To run this code, bootstrap Factor like so:
!
! Then, enter this at the interpreter prompt:
! ./f boot.image.le32
! -libraries:sdl:name=libSDL.so
! -libraries:sdl-gfx:name=libSDL_gfx.
!
! (But all on one line)
!
! Then, start Factor as usual (./f factor.image) and enter this
! at the listener:
!
! "examples/mandel.factor" run-file
@ -38,7 +44,7 @@ USE: test
: <color-map> ( nb-cols -- map )
[
dup [
360 * over succ / 360 / sat val
360 * over 1 + / 360 / sat val
hsv>rgb 1.0 scale-rgba ,
] times*
] make-list list>vector nip ;
@ -49,8 +55,8 @@ USE: test
over absq 4 >= over 0 = or [
nip nip
] [
pred >r sq dupd + r> iter
] ifte ; compiled
1 - >r sq dupd + r> iter
] ifte ;
: max-color 360 ;
@ -71,17 +77,16 @@ SYMBOL: center
x-inc get * center get real x-inc get width get 2 / * - + >float
r>
y-inc get * center get imaginary y-inc get height get 2 / * - + >float
rect> ; compiled
rect> ;
: render ( -- )
init-mandel
width get height get [
c 0 nb-iter get iter dup 0 = [
drop 0
] [
cols get [ vector-length mod ] keep vector-nth
] ifte
] with-pixels ;
] with-pixels ; compiled
: mandel ( -- )
640 480 32 SDL_HWSURFACE [
@ -89,6 +94,7 @@ SYMBOL: center
0.8 zoom-fact set
-0.65 center set
100 nb-iter set
init-mandel
[ render ] time
"Done." print flush
] with-surface

View File

@ -14,7 +14,7 @@ USE: namespaces
: random-element ( list -- random )
#! Returns a random element from the given list.
dup >r length pred 0 swap random-int r> nth ;
dup >r length 1 - 0 swap random-int r> nth ;
: random-subset ( list -- list )
#! Returns a random subset of the given list. Each item is

View File

@ -2,7 +2,6 @@
IN: timesheet
USE: errors
USE: format
USE: kernel
USE: lists
USE: math
@ -31,7 +30,7 @@ USE: vectors
! Printing the timesheet.
: hh ( duration -- str ) 60 /i ;
: mm ( duration -- str ) 60 mod unparse 2 digits ;
: mm ( duration -- str ) 60 mod unparse 2 "0" pad ;
: hh:mm ( millis -- str ) [ dup hh , ":" , mm , ] make-list ;
: print-entry ( duration description -- )

21
factor.sln Normal file
View File

@ -0,0 +1,21 @@
Microsoft Visual Studio Solution File, Format Version 8.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "factor", "factor.vcproj", "{3AE5FAF6-99AC-4B8F-9107-8A346B3D87A4}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
Debug = Debug
Release = Release
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{3AE5FAF6-99AC-4B8F-9107-8A346B3D87A4}.Debug.ActiveCfg = Debug|Win32
{3AE5FAF6-99AC-4B8F-9107-8A346B3D87A4}.Debug.Build.0 = Debug|Win32
{3AE5FAF6-99AC-4B8F-9107-8A346B3D87A4}.Release.ActiveCfg = Release|Win32
{3AE5FAF6-99AC-4B8F-9107-8A346B3D87A4}.Release.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal

492
factor.vcproj Normal file
View File

@ -0,0 +1,492 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="factor"
ProjectGUID="{3AE5FAF6-99AC-4B8F-9107-8A346B3D87A4}"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="FFI;WIN32;F_DEBUG"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="5"
UsePrecompiledHeader="0"
WarningLevel="1"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/factor.exe"
LinkIncremental="2"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/factor.pdb"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="3"
GlobalOptimizations="TRUE"
InlineFunctionExpansion="1"
OmitFramePointers="TRUE"
PreprocessorDefinitions="FFI;WIN32;F_DEBUG"
StringPooling="TRUE"
RuntimeLibrary="4"
EnableFunctionLevelLinking="TRUE"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/factor.exe"
LinkIncremental="1"
GenerateDebugInformation="TRUE"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm">
<File
RelativePath="native\arithmetic.c">
</File>
<File
RelativePath="native\array.c">
</File>
<File
RelativePath="native\bignum.c">
</File>
<File
RelativePath="native\boolean.c">
</File>
<File
RelativePath="native\compiler.c">
</File>
<File
RelativePath="native\complex.c">
</File>
<File
RelativePath="native\cons.c">
</File>
<File
RelativePath=".\native\debug.c">
</File>
<File
RelativePath="native\error.c">
</File>
<File
RelativePath="native\factor.c">
</File>
<File
RelativePath="native\ffi.c">
</File>
<File
RelativePath="native\fixnum.c">
</File>
<File
RelativePath="native\float.c">
</File>
<File
RelativePath="native\gc.c">
</File>
<File
RelativePath="native\image.c">
</File>
<File
RelativePath="native\memory.c">
</File>
<File
RelativePath="native\misc.c">
</File>
<File
RelativePath="native\port.c">
</File>
<File
RelativePath="native\primitives.c">
</File>
<File
RelativePath="native\ratio.c">
</File>
<File
RelativePath="native\relocate.c">
</File>
<File
RelativePath="native\run.c">
</File>
<File
RelativePath="native\s48_bignum.c">
</File>
<File
RelativePath="native\sbuf.c">
</File>
<File
RelativePath="native\stack.c">
</File>
<File
RelativePath="native\string.c">
</File>
<File
RelativePath="native\types.c">
</File>
<File
RelativePath="native\vector.c">
</File>
<File
RelativePath="native\word.c">
</File>
<Filter
Name="win32"
Filter="">
<File
RelativePath=".\native\win32\ffi.c">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)2.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)2.obj"/>
</FileConfiguration>
</File>
<File
RelativePath="native\win32\file.c">
</File>
<File
RelativePath="native\win32\io.c">
</File>
<File
RelativePath=".\native\win32\misc.c">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
</File>
<File
RelativePath="native\win32\read.c">
</File>
<File
RelativePath="native\win32\write.c">
</File>
</Filter>
<Filter
Name="unix"
Filter="">
<File
RelativePath=".\native\unix\ffi.c">
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
</File>
<File
RelativePath="native\unix\file.c">
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
</File>
<File
RelativePath="native\unix\io.c">
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
</File>
<File
RelativePath="native\unix\read.c">
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
</File>
<File
RelativePath="native\unix\signal.c">
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"/>
</FileConfiguration>
</File>
<File
RelativePath="native\unix\socket.c">
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"/>
</FileConfiguration>
</File>
<File
RelativePath="native\unix\write.c">
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
</File>
</Filter>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc">
<File
RelativePath="native\arithmetic.h">
</File>
<File
RelativePath="native\array.h">
</File>
<File
RelativePath="native\bignum.h">
</File>
<File
RelativePath="native\boolean.h">
</File>
<File
RelativePath="native\compiler.h">
</File>
<File
RelativePath="native\complex.h">
</File>
<File
RelativePath="native\cons.h">
</File>
<File
RelativePath=".\native\debug.h">
</File>
<File
RelativePath="native\error.h">
</File>
<File
RelativePath="native\factor.h">
</File>
<File
RelativePath="native\ffi.h">
</File>
<File
RelativePath="native\file.h">
</File>
<File
RelativePath="native\fixnum.h">
</File>
<File
RelativePath="native\float.h">
</File>
<File
RelativePath="native\gc.h">
</File>
<File
RelativePath="native\image.h">
</File>
<File
RelativePath="native\io.h">
</File>
<File
RelativePath="native\memory.h">
</File>
<File
RelativePath="native\misc.h">
</File>
<File
RelativePath="native\port.h">
</File>
<File
RelativePath="native\primitives.h">
</File>
<File
RelativePath="native\ratio.h">
</File>
<File
RelativePath="native\read.h">
</File>
<File
RelativePath="native\relocate.h">
</File>
<File
RelativePath="native\run.h">
</File>
<File
RelativePath="native\s48_bignum.h">
</File>
<File
RelativePath="native\s48_bignumint.h">
</File>
<File
RelativePath="native\sbuf.h">
</File>
<File
RelativePath="native\signal.h">
</File>
<File
RelativePath="native\socket.h">
</File>
<File
RelativePath="native\stack.h">
</File>
<File
RelativePath="native\string.h">
</File>
<File
RelativePath="native\types.h">
</File>
<File
RelativePath="native\vector.h">
</File>
<File
RelativePath="native\word.h">
</File>
<File
RelativePath="native\write.h">
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -188,6 +188,14 @@ public class DefaultVocabularyLookup implements VocabularyLookup
}
} //}}}
//{{{ forget() method
public void forget(FactorWord word)
{
Map vocab = (Map)vocabularies.get(word.vocabulary);
if(vocab != null)
vocab.remove(word.name);
} //}}}
//{{{ getVocabularies() method
public Cons getVocabularies()
{
@ -199,8 +207,27 @@ public class DefaultVocabularyLookup implements VocabularyLookup
} //}}}
//{{{ getCompletions() method
public void getCompletions(String vocab, String word, Set completions,
boolean anywhere)
/**
* @param use A list of vocabularies.
* @param word A substring of the word name to complete
* @param anywhere If true, matches anywhere in the word name are
* returned; otherwise, only matches from beginning.
* @param completions Set to add completions to
*/
public void getCompletions(Cons use, String word, boolean anywhere,
Set completions) throws Exception
{
while(use != null)
{
String vocab = (String)use.car;
getCompletions(vocab,word,anywhere,completions);
use = use.next();
}
} //}}}
//{{{ getCompletions() method
public void getCompletions(String vocab, String word, boolean anywhere,
Set completions) throws Exception
{
Map v = (Map)vocabularies.get(vocab);
if(v == null)

View File

@ -40,39 +40,55 @@ import org.gjt.sp.util.Log;
public class ExternalFactor extends DefaultVocabularyLookup
{
//{{{ ExternalFactor constructor
/**
* We are given two streams that point to a bare REPL.
*/
public ExternalFactor(Process proc, InputStream in, OutputStream out)
public ExternalFactor(int port)
{
if(proc == null || in == null || out == null)
closed = true;
else
{
this.proc = proc;
/* Start stream server */;
streamServer = port;
for(int i = 1; i < 6; i++)
{
Log.log(Log.DEBUG,this,"Factor connection, try #" + i);
try
{
this.in = new DataInputStream(in);
this.out = new DataOutputStream(out);
out.write("USE: jedit wire-server\n".getBytes("ASCII"));
out.flush();
waitForAck();
/* Start stream server */
streamServer = 9999;
eval("USE: telnetd [ 9999 telnetd ] in-thread");
/* Ensure we're ready for a connection immediately */
eval("nop");
Thread.sleep(1000);
openWire();
Log.log(Log.DEBUG,this,"Connection established");
return;
}
catch(Exception e)
{
close();
Log.log(Log.ERROR,this,e);
}
}
Log.log(Log.ERROR,this,"Cannot connect to Factor on port " + port);
if(in != null && out != null)
close();
} //}}}
//{{{ openWireSocket() method
/**
* Return a listener stream.
*/
public Socket openWireSocket() throws IOException
{
if(closed)
throw new IOException("Socket closed");
return new Socket("localhost",streamServer);
} //}}}
//{{{ openWire() method
private void openWire() throws Exception
{
Socket client = openWireSocket();
in = new DataInputStream(new BufferedInputStream(
client.getInputStream()));
out = new DataOutputStream(new BufferedOutputStream(
client.getOutputStream()));
out.write("USE: jedit wire-server\n".getBytes("ASCII"));
out.flush();
waitForAck();
} //}}}
//{{{ waitForAck() method
@ -88,6 +104,7 @@ public class ExternalFactor extends DefaultVocabularyLookup
byte[] discard = new byte[2048];
int len = in.read(discard,0,discard.length);
discardStr = new String(discard,0,len);
Log.log(Log.DEBUG,this,"Waiting for ACK: " + discardStr);
}
} //}}}
@ -132,22 +149,16 @@ public class ExternalFactor extends DefaultVocabularyLookup
*/
public FactorStream openStream()
{
if(closed)
return null;
else
try
{
try
{
Socket client = new Socket("localhost",streamServer);
return new FactorStream(client);
}
catch(Exception e)
{
Log.log(Log.ERROR,this,"Cannot open stream connection to "
+ "external Factor:");
Log.log(Log.ERROR,this,e);
return null;
}
return new FactorStream(openWireSocket());
}
catch(Exception e)
{
Log.log(Log.ERROR,this,"Cannot open stream connection to "
+ "external Factor:");
Log.log(Log.ERROR,this,e);
return null;
}
} //}}}
@ -178,6 +189,21 @@ public class ExternalFactor extends DefaultVocabularyLookup
return vocabs;
} //}}}
//{{{ makeWord() method
/**
* Make a word from an info list returned by Factor.
*/
public synchronized FactorWord makeWord(Cons info)
{
String vocabulary = (String)info.car;
String name = (String)info.next().car;
FactorWord w = super.searchVocabulary(new Cons(vocabulary,null),name);
if(w == null)
w = new FactorWord(vocabulary,name);
w.stackEffect = (String)info.next().next().car;
return w;
} //}}}
//{{{ searchVocabulary() method
/**
* Search through the given vocabulary list for the given word.
@ -185,71 +211,58 @@ public class ExternalFactor extends DefaultVocabularyLookup
public synchronized FactorWord searchVocabulary(Cons vocabulary, String name)
{
FactorWord w = super.searchVocabulary(vocabulary,name);
if(w != null)
return w;
if(closed)
return define("#<unknown>",name);
try
{
if(!closed)
{
Cons result = parseObject(eval(FactorReader.unparseObject(name)
+ " "
+ FactorReader.unparseObject(vocabulary)
+ " jedit-lookup ."));
if(result.car == null)
return null;
result = (Cons)result.car;
w = new FactorWord(
(String)result.car,
(String)result.next().car);
w.stackEffect = (String)result.next().next().car;
return w;
}
Cons result = parseObject(eval(FactorReader.unparseObject(name)
+ " "
+ FactorReader.unparseObject(vocabulary)
+ " search jedit-lookup ."));
if(result.car == null)
return null;
return makeWord((Cons)result.car);
}
catch(Exception e)
{
Log.log(Log.ERROR,this,e);
return null;
}
return new FactorWord("unknown",name);
} //}}}
//{{{ getCompletions() method
public synchronized void getCompletions(String vocab, String word, Set completions,
boolean anywhere)
public synchronized void getCompletions(Cons use, String word,
boolean anywhere, Set completions) throws Exception
{
super.getCompletions(vocab,word,completions,anywhere);
super.getCompletions(use,word,anywhere,completions);
if(closed)
return;
try
{
/* We can't send words across the socket at this point in
human history, because of USE: issues. so we send name/vocab
pairs. */
Cons moreCompletions = (Cons)parseObject(eval(
FactorReader.unparseObject(word)
+ " "
+ FactorReader.unparseObject(vocab)
+ " "
+ (anywhere ? "vocab-apropos" : "vocab-completions")
+ " [ dup word-name swap word-vocabulary 2list ] map .")).car;
/* We can't send words across the socket at this point in
human history, because of USE: issues. so we send name/vocab
pairs. */
Cons moreCompletions = (Cons)parseObject(eval(
FactorReader.unparseObject(word)
+ " "
+ FactorReader.unparseObject(Boolean.valueOf(anywhere))
+ " "
+ FactorReader.unparseObject(use)
+ " completions .")).car;
while(moreCompletions != null)
{
Cons completion = (Cons)moreCompletions.car;
FactorWord w = searchVocabulary(completion.next(),
(String)completion.car);
if(w != null)
completions.add(w);
moreCompletions = moreCompletions.next();
}
}
catch(Exception e)
while(moreCompletions != null)
{
Log.log(Log.ERROR,this,e);
Cons completion = (Cons)moreCompletions.car;
FactorWord w = makeWord(completion);
if(w != null)
completions.add(w);
moreCompletions = moreCompletions.next();
}
} //}}}
@ -277,7 +290,6 @@ public class ExternalFactor extends DefaultVocabularyLookup
try
{
proc.waitFor();
in.close();
out.close();
}
@ -287,7 +299,6 @@ public class ExternalFactor extends DefaultVocabularyLookup
Log.log(Log.DEBUG,this,e);
}
proc = null;
in = null;
out = null;
} //}}}
@ -301,7 +312,6 @@ public class ExternalFactor extends DefaultVocabularyLookup
//{{{ Private members
private boolean closed;
private Process proc;
private DataInputStream in;
private DataOutputStream out;

View File

@ -40,6 +40,7 @@ public class FactorReader
{
private VocabularyLookup lookup;
private FactorScanner scanner;
private ParseState topState;
private Cons states;
/**
@ -52,6 +53,8 @@ public class FactorReader
private String in;
private int base = 10;
private Cons definedWords;
//{{{ getUnreadableString() method
public static String getUnreadableString(String str)
{
@ -162,6 +165,7 @@ public class FactorReader
this.lookup = lookup;
this.scanner = scanner;
pushState(toplevel,null);
topState = (ParseState)states.car;
this.alwaysDocComments = alwaysDocComments;
this.in = DefaultVocabularyLookup.DEFAULT_IN;
this.use = DefaultVocabularyLookup.DEFAULT_USE;
@ -217,7 +221,8 @@ public class FactorReader
if(next())
{
// eof.
return popState(toplevel,toplevel).first;
popState(toplevel,toplevel);
return topState.first;
}
}
} //}}}
@ -233,17 +238,29 @@ public class FactorReader
public FactorWord intern(String name, boolean define)
throws Exception
{
FactorWord word;
if(define)
return lookup.define(getIn(),name);
{
word = lookup.define(getIn(),name);
definedWords = new Cons(word,definedWords);
}
else
{
FactorWord word = searchVocabulary(getUse(),name);
word = searchVocabulary(getUse(),name);
if(word == null)
error("Undefined: " + name);
return word;
}
return word;
} //}}}
//{{{ getDefinedWords() method
public Cons getDefinedWords()
{
return definedWords;
} //}}}
//{{{ nextWord() method
/**
* Read a word from the scanner and intern it. Returns null on EOF.

View File

@ -36,18 +36,31 @@ public interface VocabularyLookup
{
public FactorWord define(String in, String word)
throws Exception;
public FactorWord searchVocabulary(Cons use, String word)
throws Exception;
public void forget(FactorWord word);
/**
* @param use A list of vocabularies.
* @param word A substring of the word name to complete
* @param anywhere If true, matches anywhere in the word name are
* returned; otherwise, only matches from beginning.
* @param completions Set to add completions to
*/
public void getCompletions(Cons use, String word, boolean anywhere,
Set completions) throws Exception;
/**
* @param vocab The vocabulary name
* @param word A substring of the word name to complete
* @param completions List to add completions to
* @param anywhere If true, word name will be matched anywhere, otherwise, just at
* the beginning of the name.
* @param completions Set to add completions to
*/
public void getCompletions(String vocab, String word, Set completions,
boolean anywhere) throws Exception;
public void getCompletions(String vocab, String word, boolean anywhere,
Set completions) throws Exception;
public Cons getVocabularies() throws Exception;
}

View File

@ -126,6 +126,8 @@ public class EditWordDialog extends WordListDialog
list.setSelectedIndex(0);
list.ensureIndexIsVisible(0);
}
updatePreview();
} //}}}
//{{{ UpdateTimer class

View File

@ -61,14 +61,23 @@ public class FactorCompletion extends SideKickCompletion
public void insert(int index)
{
Macros.Recorder recorder = view.getMacroRecorder();
FactorWord selected = ((FactorWord)get(index));
String insert = selected.name.substring(word.length());
String insert = ((FactorWord)get(index)).name.substring(
word.length());
Buffer buffer = textArea.getBuffer();
if(recorder != null)
recorder.recordInput(insert,false);
textArea.setSelectedText(insert);
try
{
buffer.beginCompoundEdit();
textArea.setSelectedText(insert);
if(!FactorPlugin.isUsed(view,selected.vocabulary))
FactorPlugin.insertUse(view,selected.vocabulary);
}
finally
{
buffer.endCompoundEdit();
}
}
public int getTokenLength()
@ -79,21 +88,21 @@ public class FactorCompletion extends SideKickCompletion
public boolean handleKeystroke(int selectedIndex, char keyChar)
{
if(keyChar == '\t' || keyChar == '\n')
{
insert(selectedIndex);
return false;
}
else if(keyChar == ' ')
{
insert(selectedIndex);
textArea.userInput(' ');
return false;
}
else
{
Macros.Recorder recorder = view.getMacroRecorder();
if(recorder != null)
recorder.recordInput(1,keyChar,false);
textArea.userInput(keyChar);
return true;
}
boolean ws = (ReadTable.DEFAULT_READTABLE
.getCharacterType(keyChar)
== ReadTable.WHITESPACE);
return !ws;
}
public ListCellRenderer getRenderer()

View File

@ -37,7 +37,7 @@ public class FactorParsedData extends SideKickParsedData
public FactorSideKickParser parser;
public String in;
public Cons use;
FactorParsedData(FactorSideKickParser parser, String fileName)
{
super(fileName);

View File

@ -42,6 +42,8 @@ import sidekick.*;
public class FactorPlugin extends EditPlugin
{
private static ExternalFactor external;
private static Process process;
private static int PORT = 9999;
//{{{ getPluginPath() method
private String getPluginPath()
@ -73,8 +75,25 @@ public class FactorPlugin extends EditPlugin
public void stop()
{
stopExternalInstance();
Buffer buffer = jEdit.getFirstBuffer();
while(buffer != null)
{
buffer.setProperty(FactorSideKickParser.WORDS_PROPERTY,null);
buffer = buffer.getNext();
}
} //}}}
//{{{ addNonEmpty() method
private static void addNonEmpty(String[] input, List output)
{
for(int i = 0; i < input.length; i++)
{
if(input[i].length() != 0)
output.add(input[i]);
}
} //}}}
//{{{ getExternalInstance() method
/**
* Returns the object representing a connection to an external Factor instance.
@ -84,33 +103,40 @@ public class FactorPlugin extends EditPlugin
{
if(external == null)
{
Process p = null;
InputStream in = null;
OutputStream out = null;
try
{
String[] args = jEdit.getProperty("factor.external.args","-jedit")
String exePath = jEdit.getProperty(
"factor.external.program");
String imagePath = jEdit.getProperty(
"factor.external.image");
List args = new ArrayList();
args.add(exePath);
args.add(imagePath);
args.add("-shell=telnet");
args.add("-telnetd-port=" + PORT);
String[] extraArgs = jEdit.getProperty(
"factor.external.args")
.split(" ");
String[] nargs = new String[args.length + 3];
nargs[0] = jEdit.getProperty("factor.external.program");
nargs[1] = jEdit.getProperty("factor.external.image");
nargs[2] = "-no-ansi";
System.arraycopy(args,0,nargs,3,args.length);
p = Runtime.getRuntime().exec(nargs);
p.getErrorStream().close();
addNonEmpty(extraArgs,args);
process = Runtime.getRuntime().exec(
(String[])args.toArray(
new String[args.size()]),
null,
new File(MiscUtilities
.getParentOfPath(imagePath)));
in = p.getInputStream();
out = p.getOutputStream();
external = new ExternalFactor(PORT);
}
catch(IOException io)
catch(Exception e)
{
Log.log(Log.ERROR,FactorPlugin.class,
"Cannot start external Factor:");
Log.log(Log.ERROR,FactorPlugin.class,io);
Log.log(Log.ERROR,FactorPlugin.class,e);
process = null;
}
external = new ExternalFactor(p,in,out);
}
return external;
@ -133,7 +159,19 @@ public class FactorPlugin extends EditPlugin
if(external != null)
{
external.close();
try
{
process.getErrorStream().close();
process.getInputStream().close();
process.getOutputStream().close();
process.waitFor();
}
catch(Exception e)
{
Log.log(Log.DEBUG,FactorPlugin.class,e);
}
external = null;
process = null;
}
} //}}}
@ -165,9 +203,9 @@ public class FactorPlugin extends EditPlugin
} //}}}
//{{{ evalInWire() method
public static void evalInWire(String cmd) throws IOException
public static String evalInWire(String cmd) throws IOException
{
getExternalInstance().eval(cmd);
return getExternalInstance().eval(cmd);
} //}}}
//{{{ lookupWord() method
@ -275,37 +313,15 @@ public class FactorPlugin extends EditPlugin
* returned; otherwise, only matches from beginning.
*/
public static Set getCompletions(String word, boolean anywhere)
{
try
{
return getCompletions(getExternalInstance().getVocabularies(),word,
anywhere);
}
catch(Exception e)
{
throw new RuntimeException(e);
}
} //}}}
//{{{ getCompletions() method
/**
* @param anywhere If true, matches anywhere in the word name are
* returned; otherwise, only matches from beginning.
*/
public static Set getCompletions(Cons use, String word, boolean anywhere)
{
try
{
Set completions = new HashSet();
while(use != null)
{
String vocab = (String)use.car;
getExternalInstance().getCompletions(
vocab,word,completions,anywhere);
use = use.next();
}
getExternalInstance().getCompletions(
getExternalInstance().getVocabularies(),
word,
anywhere,
completions);
return completions;
}
catch(Exception e)
@ -314,6 +330,26 @@ public class FactorPlugin extends EditPlugin
}
} //}}}
//{{{ getWordStartIndex() method
public static int getWordStartOffset(String line, int caret)
{
ReadTable readtable = ReadTable.DEFAULT_READTABLE;
int start = caret;
while(start > 0)
{
if(readtable.getCharacterType(line.charAt(start - 1))
== ReadTable.WHITESPACE)
{
break;
}
else
start--;
}
return start;
} //}}}
//{{{ getWordAtCaret() method
public static String getWordAtCaret(JEditTextArea textArea)
{
@ -338,17 +374,7 @@ public class FactorPlugin extends EditPlugin
return null;
}
int start = caret;
while(start > 0)
{
if(readtable.getCharacterType(line.charAt(start - 1))
== ReadTable.WHITESPACE)
{
break;
}
else
start--;
}
int start = getWordStartOffset(line,caret);
int end = caret;
do
@ -375,7 +401,7 @@ public class FactorPlugin extends EditPlugin
} //}}}
//{{{ isUsed() method
private static boolean isUsed(View view, String vocab)
public static boolean isUsed(View view, String vocab)
{
SideKickParsedData data = SideKickParsedData
.getParsedData(view);

View File

@ -2,7 +2,7 @@
plugin.factor.jedit.FactorPlugin.activate=startup
plugin.factor.jedit.FactorPlugin.name=Factor
plugin.factor.jedit.FactorPlugin.version=0.70
plugin.factor.jedit.FactorPlugin.version=0.71
plugin.factor.jedit.FactorPlugin.author=Slava Pestov
plugin.factor.jedit.FactorPlugin.docs=/doc/jedit/index.html

View File

@ -82,6 +82,7 @@ public class FactorShell extends Shell
try
{
state = getConsoleState(console);
state.openStream();
state.packetLoop(output);
}
catch(Exception e)
@ -210,14 +211,14 @@ public class FactorShell extends Shell
}
else
{
/* try
try
{
packetLoop(output);
}
catch(Exception e)
{
Log.log(Log.ERROR,this,e);
} */
}
}
}
@ -247,11 +248,16 @@ public class FactorShell extends Shell
Cons pair = FactorPlugin.getExternalInstance()
.parseObject(w.getText());
String write = (String)pair.car;
AttributeSet attrs = new ListenerAttributeSet(
(Cons)pair.next().car);
output.writeAttrs(attrs,write);
if(pair.car instanceof String)
{
String write = (String)pair.car;
AttributeSet attrs = new ListenerAttributeSet(
(Cons)pair.next().car);
output.writeAttrs(attrs,write);
}
else
Log.log(Log.ERROR,this,"Malformed write packet: " + pair);
}
void packetLoop(Output output) throws Exception
@ -259,8 +265,6 @@ public class FactorShell extends Shell
if(waitingForInput)
return;
openStream();
if(stream == null)
return;

View File

@ -40,14 +40,12 @@ import sidekick.*;
public class FactorSideKickParser extends SideKickParser
{
private Map previewMap;
/**
* When we parse a file, we store the <word,worddef> pairs in this
* map, so that completion popups show the latest stack effects,
* and not whatever they were the last time the source was run-file'd.
* We store the file's parse tree in this property.
*/
private Map worddefs;
public static String WORDS_PROPERTY = "factor-parsed";
private Map previewMap;
//{{{ FactorSideKickParser constructor
public FactorSideKickParser()
@ -100,6 +98,10 @@ public class FactorSideKickParser extends SideKickParser
public SideKickParsedData parse(Buffer buffer,
DefaultErrorSource errorSource)
{
Object words = buffer.getProperty(WORDS_PROPERTY);
if(words instanceof Cons)
forgetWords((Cons)words);
FactorParsedData d = new FactorParsedData(
this,buffer.getPath());
@ -116,6 +118,8 @@ public class FactorSideKickParser extends SideKickParser
buffer.readUnlock();
}
FactorReader r = null;
try
{
/* of course wrapping a string reader in a buffered
@ -124,14 +128,13 @@ public class FactorSideKickParser extends SideKickParser
buffer.getPath(),
new BufferedReader(new StringReader(text)),
errorSource);
FactorReader r = new FactorReader(scanner,
false,FactorPlugin.getExternalInstance());
r = new FactorReader(scanner,false,FactorPlugin.getExternalInstance());
Cons parsed = r.parse();
d.in = r.getIn();
d.use = r.getUse();
addWordDefNodes(d,parsed,buffer);
}
catch(FactorParseException pe)
@ -148,12 +151,28 @@ public class FactorSideKickParser extends SideKickParser
Log.log(Log.DEBUG,this,e);
}
if(r != null)
buffer.setProperty(WORDS_PROPERTY,r.getDefinedWords());
return d;
} //}}}
//{{{ forgetWords() method
private void forgetWords(Cons words)
{
while(words != null)
{
FactorWord word = (FactorWord)words.car;
// We're not allowed to forget parsing words.
if(word.parsing != null)
return;
FactorPlugin.getExternalInstance().forget(word);
words = words.next();
}
} //}}}
//{{{ addWordDefNodes() method
private void addWordDefNodes(SideKickParsedData d, Cons parsed,
Buffer buffer)
private void addWordDefNodes(FactorParsedData d, Cons parsed, Buffer buffer)
{
FactorAsset last = null;
@ -168,19 +187,17 @@ public class FactorSideKickParser extends SideKickParser
FactorWord word = def.word;
/* word lines are indexed from 1 */
int startLine = Math.min(
int startLine = Math.max(0,Math.min(
buffer.getLineCount() - 1,
word.line - 1);
int startLineLength = buffer.getLineLength(
startLine);
int startCol = Math.min(word.col,
startLineLength);
word.line - 1));
int startLineLength = buffer.getLineLength(startLine);
int startCol = Math.min(word.col,startLineLength);
int start = buffer.getLineStartOffset(startLine)
+ startCol;
if(last != null)
last.end = buffer.createPosition(start - 1);
last.end = buffer.createPosition(Math.max(0,start - 1));
last = new FactorAsset(word,buffer.createPosition(start));
d.root.add(new DefaultMutableTreeNode(last));
@ -275,8 +292,7 @@ public class FactorSideKickParser extends SideKickParser
return null;
FactorWord[] completions = FactorPlugin.toWordArray(
FactorPlugin.getCompletions(
data.use,word,false));
FactorPlugin.getCompletions(word,false));
if(completions.length == 0)
return null;

View File

@ -31,16 +31,19 @@ package factor.jedit;
import factor.*;
import javax.swing.border.*;
import javax.swing.event.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import org.gjt.sp.jedit.gui.EnhancedDialog;
import org.gjt.sp.jedit.*;
import org.gjt.sp.util.Log;
public abstract class WordListDialog extends EnhancedDialog
{
protected View view;
protected JList list;
protected JTextArea preview;
protected JButton ok, cancel;
//{{{ WordListDialog constructor
@ -55,13 +58,49 @@ public abstract class WordListDialog extends EnhancedDialog
content.setBorder(new EmptyBorder(12,12,12,12));
setContentPane(content);
content.add(BorderLayout.CENTER,new JScrollPane(
list = new JList()));
JScrollPane listScroll = new JScrollPane(
list = new JList());
list.setCellRenderer(new FactorWordRenderer(parser,true));
list.addListSelectionListener(new ListHandler());
JScrollPane previewScroll = new JScrollPane(
preview = new JTextArea(12,60));
preview.setEditable(false);
listScroll.setPreferredSize(previewScroll.getPreferredSize());
JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
listScroll,previewScroll);
split.setDividerLocation(0.5);
split.setResizeWeight(0.5);
content.add(BorderLayout.CENTER,split);
content.add(BorderLayout.SOUTH,createButtonPanel());
} //}}}
//{{{ updatePreview() method
protected void updatePreview()
{
FactorWord word = (FactorWord)list.getSelectedValue();
if(word == null)
{
preview.setText("");
return;
}
try
{
String text = FactorPlugin.evalInWire(
FactorPlugin.factorWord(word) + " see").trim();
preview.setText(text);
preview.setCaretPosition(text.length());
}
catch(Exception e)
{
Log.log(Log.ERROR,this,e);
}
} //}}}
//{{{ createButtonPanel() method
private Box createButtonPanel()
{
@ -91,4 +130,13 @@ public abstract class WordListDialog extends EnhancedDialog
cancel();
}
} //}}}
//{{{ ListHandler class
class ListHandler implements ListSelectionListener
{
public void valueChanged(ListSelectionEvent evt)
{
updatePreview();
}
} //}}}
}

114
factor/jedit/WordPopup.java Normal file
View File

@ -0,0 +1,114 @@
/* :folding=explicit:collapseFolds=1: */
/*
* $Id$
*
* Copyright (C) 2004 Slava Pestov.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* DEVELOPERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package factor.jedit;
import factor.*;
import java.awt.event.*;
import java.awt.*;
import java.io.IOException;
import javax.swing.*;
import org.gjt.sp.jedit.textarea.JEditTextArea;
import org.gjt.sp.jedit.*;
import org.gjt.sp.util.Log;
public class WordPopup extends JWindow
{
private View view;
private JTextArea preview;
//{{{ showWordPopup() method
public static void showWordPopup(JEditTextArea textArea)
{
View view = GUIUtilities.getView(textArea);
String def;
try
{
def = FactorPlugin.evalInWire(
FactorPlugin.factorWord(view)
+ " see").trim();
}
catch(IOException io)
{
def = io.toString();
Log.log(Log.ERROR,WordPopup.class,io);
}
WordPopup popup = new WordPopup(view,def);
int line = textArea.getCaretLine();
String lineText = textArea.getLineText(line);
int caret = textArea.getCaretPosition()
- textArea.getLineStartOffset(line);
int start = FactorPlugin.getWordStartOffset(lineText,caret);
Point loc = textArea.offsetToXY(line,start);
loc.y += textArea.getPainter().getFontMetrics().getHeight();
SwingUtilities.convertPointToScreen(loc,textArea.getPainter());
popup.setLocation(loc);
popup.show();
} //}}}
//{{{ WordPopup constructor
public WordPopup(View view, String text)
{
super(view);
this.view = view;
preview = new JTextArea(text);
preview.setEditable(false);
getContentPane().add(BorderLayout.CENTER,new JScrollPane(preview));
pack();
KeyHandler keyHandler = new KeyHandler();
addKeyListener(keyHandler);
preview.addKeyListener(keyHandler);
view.setKeyEventInterceptor(keyHandler);
GUIUtilities.requestFocus(this,preview);
} //}}}
//{{{ KeyHandler class
class KeyHandler extends KeyAdapter
{
//{{{ keyPressed() method
public void keyPressed(KeyEvent evt)
{
switch(evt.getKeyCode())
{
case KeyEvent.VK_TAB:
case KeyEvent.VK_ENTER:
case KeyEvent.VK_ESCAPE:
dispose();
view.setKeyEventInterceptor(null);
evt.consume();
break;
}
} //}}}
} //}}}
}

View File

@ -48,7 +48,7 @@ public class BeginMethod extends FactorParsingDefinition
if(type == null)
return;
FactorWord generic = reader.nextWord(true);
FactorWord generic = reader.nextWord(false);
if(generic == null)
return;

View File

@ -42,6 +42,9 @@ public class Traits extends FactorParsingDefinition
throws Exception
{
FactorWord w = reader.nextWord(true);
if(w == null)
return;
w.def = new FactorTraitsDefinition(w);
reader.intern("<" + w.name + ">",true);
reader.intern(w.name + "?",true);

View File

@ -70,9 +70,26 @@ USE: kernel
#! corresponding quotation, the value is popped off the
#! stack.
swap [
over >r unswons rot assoc* dup [
unswons rot assoc* dup [
cdr call
] [
2drop
] ifte r>
] each drop ;
] ifte
] each-with ;
: 2cons ( car1 car2 cdr1 cdr2 -- cons1 cons2 )
rot swons >r cons r> ;
: zip ( list list -- list )
#! Make a new list containing pairs of corresponding
#! elements from the two given lists.
dup [
2uncons zip >r cons r> cons
] [
2drop [ ]
] ifte ;
: unzip ( assoc -- keys values )
#! Split an association list into two lists of keys and
#! values.
[ uncons >r uncons r> unzip 2cons ] [ [ ] [ ] ] ifte* ;

View File

@ -30,28 +30,36 @@ USE: kernel
USE: lists
USE: parser
USE: stdio
USE: words
USE: namespaces
"Cold boot in progress..." print
! vocabularies get [
! "generic" off
! ] bind
[
"/library/generic/generic.factor"
"/library/generic/object.factor"
"/library/generic/builtin.factor"
"/library/generic/predicate.factor"
"/library/generic/union.factor"
"/library/generic/traits.factor"
"/version.factor"
"/library/stack.factor"
"/library/combinators.factor"
"/library/kernel.factor"
"/library/logic.factor"
"/library/cons.factor"
"/library/assoc.factor"
"/library/math/generic.factor"
"/library/words.factor"
"/library/math/arithmetic.factor"
"/library/math/math-combinators.factor"
"/library/math/math.factor"
"/library/math/integer.factor"
"/library/math/ratio.factor"
"/library/math/float.factor"
"/library/math/complex.factor"
"/library/words.factor"
"/library/math/math-combinators.factor"
"/library/lists.factor"
"/library/vectors.factor"
"/library/strings.factor"
@ -70,10 +78,7 @@ USE: stdio
"/library/syntax/parse-numbers.factor"
"/library/syntax/parser.factor"
"/library/syntax/parse-stream.factor"
"/library/bootstrap/init.factor"
! "/library/syntax/parse-syntax.factor"
"/library/format.factor"
"/library/syntax/unparser.factor"
"/library/io/presentation.factor"
"/library/io/vocabulary-style.factor"
@ -94,7 +99,6 @@ USE: stdio
"/library/io/files.factor"
"/library/eval-catch.factor"
"/library/tools/listener.factor"
"/library/tools/inspector.factor"
"/library/tools/word-tools.factor"
"/library/test/test.factor"
"/library/io/ansi.factor"
@ -110,9 +114,10 @@ USE: stdio
"/library/inference/dataflow.factor"
"/library/inference/inference.factor"
"/library/inference/words.factor"
"/library/inference/branches.factor"
"/library/inference/words.factor"
"/library/inference/stack.factor"
"/library/inference/types.factor"
"/library/compiler/assembler.factor"
"/library/compiler/xt.factor"
@ -129,8 +134,10 @@ USE: stdio
"/library/sdl/sdl-event.factor"
"/library/sdl/sdl-gfx.factor"
"/library/sdl/sdl-keysym.factor"
"/library/sdl/sdl-keyboard.factor"
"/library/sdl/sdl-utils.factor"
"/library/sdl/hsv.factor"
"/library/sdl/console.factor"
"/library/bootstrap/image.factor"
@ -141,7 +148,6 @@ USE: stdio
"/library/httpd/responder.factor"
"/library/httpd/httpd.factor"
"/library/httpd/file-responder.factor"
"/library/httpd/inspect-responder.factor"
"/library/httpd/test-responder.factor"
"/library/httpd/quit-responder.factor"
"/library/httpd/resource-responder.factor"
@ -155,6 +161,22 @@ USE: stdio
run-resource
] each
os "win32" = [
[
"/library/io/buffer.factor"
"/library/win32/win32-io.factor"
"/library/win32/win32-errors.factor"
"/library/win32/winsock.factor"
"/library/io/win32-io-internals.factor"
"/library/io/win32-stream.factor"
"/library/io/win32-server.factor"
"/library/io/win32-console.factor"
] [
dup print
run-resource
] each
] when
cpu "x86" = [
[
"/library/compiler/assembly-x86.factor"

View File

@ -36,53 +36,63 @@ USE: words
USE: hashtables
"/library/bootstrap/primitives.factor" run-resource
"/version.factor" run-resource
"/library/stack.factor" run-resource
"/library/combinators.factor" run-resource
"/library/kernel.factor" run-resource
"/library/logic.factor" run-resource
"/library/cons.factor" run-resource
"/library/assoc.factor" run-resource
"/library/math/generic.factor" run-resource
"/library/words.factor" run-resource
"/library/math/arithmetic.factor" run-resource
"/library/math/math-combinators.factor" run-resource
"/library/math/math.factor" run-resource
"/library/lists.factor" run-resource
"/library/vectors.factor" run-resource
"/library/strings.factor" run-resource
"/library/hashtables.factor" run-resource
"/library/namespaces.factor" run-resource
"/library/list-namespaces.factor" run-resource
"/library/sbuf.factor" run-resource
"/library/errors.factor" run-resource
"/library/continuations.factor" run-resource
"/library/threads.factor" run-resource
"/library/io/stream.factor" run-resource
"/library/io/stdio.factor" run-resource
"/library/io/io-internals.factor" run-resource
"/library/io/stream-impl.factor" run-resource
"/library/vocabularies.factor" run-resource
"/library/syntax/parse-numbers.factor" run-resource
"/library/syntax/parser.factor" run-resource
"/library/syntax/parse-stream.factor" run-resource
! A bootstrapping trick. See doc/bootstrap.txt.
vocabularies get [
"generic" off
] bind
! The make-list form creates a boot quotation
[
"/version.factor" parse-resource append,
"/library/stack.factor" parse-resource append,
"/library/combinators.factor" parse-resource append,
"/library/kernel.factor" parse-resource append,
"/library/cons.factor" parse-resource append,
"/library/assoc.factor" parse-resource append,
"/library/math/math.factor" parse-resource append,
"/library/math/integer.factor" parse-resource append,
"/library/math/ratio.factor" parse-resource append,
"/library/math/float.factor" parse-resource append,
"/library/math/complex.factor" parse-resource append,
"/library/words.factor" parse-resource append,
"/library/math/math-combinators.factor" parse-resource append,
"/library/lists.factor" parse-resource append,
"/library/vectors.factor" parse-resource append,
"/library/strings.factor" parse-resource append,
"/library/hashtables.factor" parse-resource append,
"/library/namespaces.factor" parse-resource append,
"/library/list-namespaces.factor" parse-resource append,
"/library/sbuf.factor" parse-resource append,
"/library/errors.factor" parse-resource append,
"/library/continuations.factor" parse-resource append,
"/library/threads.factor" parse-resource append,
"/library/io/stream.factor" parse-resource append,
"/library/io/stdio.factor" parse-resource append,
"/library/io/io-internals.factor" parse-resource append,
"/library/io/stream-impl.factor" parse-resource append,
"/library/vocabularies.factor" parse-resource append,
"/library/syntax/parse-numbers.factor" parse-resource append,
"/library/syntax/parser.factor" parse-resource append,
"/library/syntax/parse-stream.factor" parse-resource append,
"/library/generic/generic.factor" run-resource
"/library/generic/object.factor" run-resource
"/library/generic/builtin.factor" run-resource
"/library/generic/predicate.factor" run-resource
"/library/generic/traits.factor" run-resource
"traits" [ "generic" ] search
"delegate" [ "generic" ] search
"object" [ "generic" ] search
! init.factor leaves a boot quotation on the stack
"/library/bootstrap/init.factor" run-resource
vocabularies get [ "generic" off ] bind
! A bootstrapping trick. See doc/bootstrap.txt.
"/library/syntax/parse-syntax.factor" run-resource
reveal
reveal
reveal
"/library/generic/generic.factor" parse-resource append,
"/library/generic/object.factor" parse-resource append,
"/library/generic/builtin.factor" parse-resource append,
"/library/generic/predicate.factor" parse-resource append,
"/library/generic/union.factor" parse-resource append,
"/library/generic/traits.factor" parse-resource append,
"/library/bootstrap/init.factor" parse-resource append,
"/library/syntax/parse-syntax.factor" parse-resource append,
] make-list
"boot" [ "kernel" ] search swons
vocabularies get [
"!syntax" get "syntax" set

View File

@ -137,7 +137,7 @@ GENERIC: ' ( obj -- ptr )
: here-as ( tag -- pointer )
here swap bitor ;
: pad ( -- )
: align-here ( -- )
here 8 mod 4 = [ 0 emit ] when ;
( Remember what objects we've compiled )
@ -162,7 +162,7 @@ M: bignum ' ( bignum -- tagged )
[ 0 | [ 1 0 ] ]
[ -1 | [ 2 1 1 ] ]
[ 1 | [ 2 0 1 ] ]
] assoc [ emit ] each pad r> ;
] assoc [ emit ] each align-here r> ;
( Special objects )
@ -190,21 +190,14 @@ M: f ' ( obj -- ptr )
( Words )
: make-plist ( word -- plist )
[
dup word-name "name" swons ,
dup word-vocabulary "vocabulary" swons ,
parsing? [ t "parsing" swons , ] when
] make-list ;
: word, ( word -- )
[
word-tag >header ,
dup hashcode ,
dup hashcode fixnum-tag immediate ,
0 ,
dup word-primitive ,
dup word-parameter ' ,
dup make-plist ' ,
dup word-plist ' ,
0 ,
0 ,
] make-list
@ -272,9 +265,9 @@ M: cons ' ( c -- tagged )
object-tag here-as swap
string-type >header emit
dup str-length emit
dup hashcode emit
dup hashcode fixnum-tag immediate emit
pack-string
pad ;
align-here ;
M: string ' ( string -- pointer )
#! We pool strings so that each string is only written once
@ -293,15 +286,37 @@ M: string ' ( string -- pointer )
array-type >header emit
dup length emit
( elements -- ) [ emit ] each
pad r> ;
align-here r> ;
M: vector ' ( vector -- pointer )
: emit-vector ( vector -- pointer )
dup vector>list emit-array swap vector-length
object-tag here-as >r
vector-type >header emit
emit ( length )
emit ( array ptr )
pad r> ;
align-here r> ;
M: vector ' ( vector -- pointer )
emit-vector ;
: rehash ( hashtable -- )
! Now make a rehashing boot quotation
dup hash>alist [
>r dup vector-length [
f swap pick set-vector-nth
] times* r>
[ unswons rot set-hash ] each-with
] cons cons
boot-quot [ append ] change ;
M: hashtable ' ( hashtable -- pointer )
#! Only hashtables are pooled, not vectors!
dup pooled-object dup [
nip
] [
drop [ dup emit-vector [ pool-object ] keep ] keep
rehash
] ifte ;
( End of the image )
@ -323,11 +338,11 @@ M: vector ' ( vector -- pointer )
global-offset fixup ;
: boot, ( quot -- )
boot-quot get ' boot-quot-offset fixup ;
boot-quot get swap append ' boot-quot-offset fixup ;
: end ( -- )
boot,
: end ( quot -- )
global,
boot,
fixup-words
here base - heap-size-offset fixup ;
@ -364,6 +379,7 @@ M: vector ' ( vector -- pointer )
] with-scope ;
: with-image ( quot -- image )
#! The quotation leaves a boot quotation on the stack.
[ begin call end ] with-minimal-image ;
: test-image ( quot -- ) with-image vector>list . ;
@ -371,8 +387,8 @@ M: vector ' ( vector -- pointer )
: make-image ( name -- )
#! Make an image for the C interpreter.
[
boot-quot off
"/library/bootstrap/boot.factor" run-resource
boot-quot set
] with-image
swap write-image ;

View File

@ -26,7 +26,7 @@
! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
IN: kernel
USE: ansi
USE: alien
USE: compiler
USE: errors
USE: inference
@ -42,46 +42,72 @@ USE: stdio
USE: presentation
USE: words
USE: unparser
USE: kernel-internals
USE: console
: cli-args ( -- args ) 10 getenv ;
: default-cli-args
#! Some flags are *on* by default, unless user specifies
#! -no-<flag> CLI switch
"user-init" on
"interactive" on
"smart-terminal" on
"verbose-compile" on
"compile" on
os "win32" = [
"sdl" "shell" set
] [
"ansi" "shell" set
] ifte ;
: warm-boot ( -- )
#! A fully bootstrapped image has this as the boot
#! quotation.
boot
init-error-handler
init-random
init-assembler
default-cli-args
parse-command-line ;
! Some flags are *on* by default, unless user specifies
! -no-<flag> CLI switch
t "user-init" set
t "interactive" set
! We don't want ANSI escape codes on Windows
os "unix" = "ansi" set
t "compile" set
: shell ( str -- )
#! This handles the -shell:<foo> cli argument.
[ "shells" ] search execute ;
! The first CLI arg is the image name.
cli-args uncons parse-command-line "image" set
"ansi" get [ stdio [ <ansi-stream> ] change ] when
"compile" get [ compile-all ] when
run-user-init ;
: auto-inline-count 5 ;
[
warm-boot
garbage-collection
"interactive" get [ print-banner listener ] when
run-user-init
"shell" get shell
0 exit*
] set-boot
init-error-handler
0 [ drop succ ] each-word unparse write " words" print
! An experiment gone wrong...
! : usage+ ( key -- )
! dup "usages" word-property
! [ succ ] [ 1 ] ifte*
! "usages" set-word-property ;
!
! GENERIC: count-usages ( quot -- )
! M: object count-usages drop ;
! M: word count-usages usage+ ;
! M: cons count-usages unswons count-usages count-usages ;
!
! : tally-usages ( -- )
! [ f "usages" set-word-property ] each-word
! [ word-parameter count-usages ] each-word ;
!
! : auto-inline ( count -- )
! #! Automatically inline all words called less than a count
! #! number of times.
! [
! 2dup "usages" word-property dup 0 ? >= [
! t "inline" set-word-property
! ] [
! drop
! ] ifte
! ] each-word drop ;
! "Counting word usages..." print
! tally-usages
@ -91,9 +117,36 @@ init-error-handler
! " or less times..." print
! auto-inline-count auto-inline
"Inferring stack effects..." print
0 [ unit try-infer [ succ ] when ] each-word
unparse write " words have a stack effect" print
default-cli-args
parse-command-line
os "win32" = "compile" get and [
"kernel32" "kernel32.dll" "stdcall" add-library
"user32" "user32.dll" "stdcall" add-library
"gdi32" "gdi32.dll" "stdcall" add-library
"winsock" "ws2_32.dll" "stdcall" add-library
"mswsock" "mswsock.dll" "stdcall" add-library
"libc" "msvcrt.dll" "cdecl" add-library
"sdl" "SDL.dll" "cdecl" add-library
"sdl-gfx" "SDL_gfx.dll" "cdecl" add-library
] when
! FIXME: KLUDGE to get FFI-based IO going in Windows.
os "win32" = [ "/library/bootstrap/win32-io.factor" run-resource ] when
"Compiling system..." print
"compile" get [ compile-all ] when
terpri
"Unless you're working on the compiler, ignore the errors above." print
"Not every word compiles, by design." print
terpri
0 [ compiled? [ 1 + ] when ] each-word
unparse write " words compiled" print
0 [ drop 1 + ] each-word
unparse write " words total" print
"Bootstrapping is complete." print
"Now, you can run ./f factor.image" print

View File

@ -41,9 +41,6 @@ USE: words
"HOME" os-env [ "." ] unless* "~" set
init-search-path ;
[
boot
"Good morning!" print
flush
"/library/bootstrap/boot-stage2.factor" run-resource
]
"Good morning!" print
flush
"/library/bootstrap/boot-stage2.factor" run-resource

View File

@ -34,6 +34,7 @@ USE: parser
USE: words
USE: vectors
USE: hashtables
USE: generic
! Bring up a bare cross-compiling vocabulary.
"syntax" vocab
@ -50,23 +51,19 @@ vocabularies get [
"syntax" set
] bind
<namespace> classes set
2 [
[ "words" | "execute" ]
[ "kernel" | "call" ]
[ "kernel" | "ifte" ]
[ "lists" | "cons" ]
[ "lists" | "car" ]
[ "lists" | "cdr" ]
[ "vectors" | "<vector>" ]
[ "vectors" | "vector-length" ]
[ "vectors" | "set-vector-length" ]
[ "vectors" | "vector-nth" ]
[ "vectors" | "set-vector-nth" ]
[ "strings" | "str-length" ]
[ "strings" | "str-nth" ]
[ "strings" | "str-compare" ]
[ "strings" | "str=" ]
[ "strings" | "str-hashcode" ]
[ "strings" | "index-of*" ]
[ "strings" | "substring" ]
[ "strings" | "str-reverse" ]
@ -82,19 +79,13 @@ vocabularies get [
[ "strings" | "sbuf=" ]
[ "strings" | "sbuf-hashcode" ]
[ "math-internals" | "arithmetic-type" ]
[ "math" | "number?" ]
[ "math" | ">fixnum" ]
[ "math" | ">bignum" ]
[ "math" | ">float" ]
[ "math" | "numerator" ]
[ "math" | "denominator" ]
[ "math" | "fraction>" ]
[ "math-internals" | "(fraction>)" ]
[ "parser" | "str>float" ]
[ "unparser" | "(unparse-float)" ]
[ "math" | "float>bits" ]
[ "math" | "real" ]
[ "math" | "imaginary" ]
[ "math" | "rect>" ]
[ "math-internals" | "(rect>)" ]
[ "math-internals" | "fixnum=" ]
[ "math-internals" | "fixnum+" ]
[ "math-internals" | "fixnum-" ]
@ -151,21 +142,9 @@ vocabularies get [
[ "math-internals" | "fsinh" ]
[ "math-internals" | "fsqrt" ]
[ "words" | "<word>" ]
[ "words" | "word-hashcode" ]
[ "words" | "word-xt" ]
[ "words" | "set-word-xt" ]
[ "words" | "word-primitive" ]
[ "words" | "set-word-primitive" ]
[ "words" | "word-parameter" ]
[ "words" | "set-word-parameter" ]
[ "words" | "word-plist" ]
[ "words" | "set-word-plist" ]
[ "words" | "update-xt" ]
[ "profiler" | "call-profiling" ]
[ "profiler" | "call-count" ]
[ "profiler" | "set-call-count" ]
[ "profiler" | "allot-profiling" ]
[ "profiler" | "allot-count" ]
[ "profiler" | "set-allot-count" ]
[ "words" | "compiled?" ]
[ "kernel" | "drop" ]
[ "kernel" | "dup" ]
@ -175,8 +154,8 @@ vocabularies get [
[ "kernel" | ">r" ]
[ "kernel" | "r>" ]
[ "kernel" | "eq?" ]
[ "kernel" | "getenv" ]
[ "kernel" | "setenv" ]
[ "kernel-internals" | "getenv" ]
[ "kernel-internals" | "setenv" ]
[ "io-internals" | "open-file" ]
[ "files" | "stat" ]
[ "files" | "(directory)" ]
@ -211,19 +190,15 @@ vocabularies get [
[ "random" | "init-random" ]
[ "random" | "(random-int)" ]
[ "kernel" | "type" ]
[ "kernel" | "size" ]
[ "files" | "cwd" ]
[ "files" | "cd" ]
[ "compiler" | "compiled-offset" ]
[ "compiler" | "set-compiled-offset" ]
[ "compiler" | "set-compiled-cell" ]
[ "compiler" | "set-compiled-byte" ]
[ "compiler" | "literal-top" ]
[ "compiler" | "set-literal-top" ]
[ "kernel" | "address" ]
[ "alien" | "dlopen" ]
[ "alien" | "dlsym" ]
[ "alien" | "dlsym-self" ]
[ "alien" | "dlclose" ]
[ "alien" | "<alien>" ]
[ "alien" | "<local-alien>" ]
@ -237,6 +212,19 @@ vocabularies get [
[ "alien" | "set-alien-1" ]
[ "kernel" | "heap-stats" ]
[ "errors" | "throw" ]
[ "kernel-internals" | "string>memory" ]
[ "kernel-internals" | "memory>string" ]
[ "alien" | "local-alien?" ]
[ "alien" | "alien-address" ]
[ "lists" | ">cons" ]
[ "vectors" | ">vector" ]
[ "strings" | ">string" ]
[ "words" | ">word" ]
[ "kernel-internals" | "slot" ]
[ "kernel-internals" | "set-slot" ]
[ "kernel-internals" | "integer-slot" ]
[ "kernel-internals" | "set-integer-slot" ]
[ "kernel-internals" | "grow-array" ]
] [
unswons create swap succ [ f define ] keep
unswons create swap 1 + [ f define ] keep
] each drop

View File

@ -1,8 +1,8 @@
! :folding=indent:collapseFolds=0:
! :folding=indent:collapseFolds=1:
! $Id$
!
! Copyright (C) 2003, 2004 Slava Pestov.
! Copyright (C) 2003, 2004 Mackenzie Straight.
!
! Redistribution and use in source and binary forms, with or without
! modification, are permitted provided that the following conditions are met:
@ -25,30 +25,37 @@
! OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
IN: kernel
IN: threads
USE: compiler
USE: io-internals
USE: kernel
USE: win32-io-internals
USE: win32-api
: ? ( cond t f -- t/f )
#! Push t if cond is true, otherwise push f.
rot [ drop ] [ nip ] ifte ; inline
: (yield) ( -- )
next-thread [
call
] [
next-io-task [
call
] [
win32-next-io-task
] ifte*
] ifte* ;
: and ( a b -- a&b )
#! Logical and.
f ? ; inline
IN: streams
USE: compiler
USE: namespaces
USE: stdio
USE: kernel
USE: win32-io-internals
USE: win32-stream
USE: win32-api
: not ( a -- a )
#! Pushes f is the object is not f, t if the object is f.
f t ? ; inline
: <filecr> <win32-filecr> ;
: <filecw> <win32-filecw> ;
: <server> <win32-server> ;
: or ( a b -- a|b)
#! Logical or.
t swap ? ; inline
: init-stdio ( -- )
win32-init-stdio ;
: xor ( a b -- a^b )
#! Logical exclusive or.
dup not swap ? ; inline
: >boolean t f ? ; inline
: replace ( obj old new -- obj/new )
#! If obj is equal to old, drop it and push new.
>r dupd = [ drop r> ] [ r> drop ] ifte ;

View File

@ -40,6 +40,7 @@ USE: stdio
USE: streams
USE: strings
USE: words
USE: kernel-internals
! This file is run as the last stage of boot.factor; it relies
! on all other words already being defined.
@ -54,8 +55,12 @@ USE: words
?run-file
] when ;
: cli-var-param ( name value -- )
swap ":" split set-object-path ;
: set-path ( value list -- )
unswons over [ nest [ set-path ] bind ] [ nip set ] ifte ;
: cli-var-param ( name value -- ) swap ":" split set-path ;
: cli-bool-param ( name -- ) "no-" ?str-head not put ;
: cli-param ( param -- )
#! Handle a command-line argument starting with '-' by
@ -64,26 +69,12 @@ USE: words
#!
#! Arguments containing = are handled differently; they
#! set the object path.
"=" split1 dup [
cli-var-param
] [
drop dup "no-" str-head? dup [
f put drop
] [
drop t put
] ifte
] ifte ;
"=" split1 [ cli-var-param ] [ cli-bool-param ] ifte* ;
: cli-arg ( argument -- argument )
#! Handle a command-line argument. If the argument was
#! consumed, returns f. Otherwise returns the argument.
dup f-or-"" [
dup "-" str-head? dup [
cli-param drop f
] [
drop
] ifte
] unless ;
dup f-or-"" [ "-" ?str-head [ cli-param f ] when ] unless ;
: parse-switches ( args -- args )
[ cli-arg ] map ;
@ -91,6 +82,9 @@ USE: words
: run-files ( args -- )
[ [ run-file ] when* ] each ;
: parse-command-line ( args -- )
: cli-args ( -- args ) 10 getenv ;
: parse-command-line ( -- )
#! Parse command line arguments.
parse-switches run-files ;
#! The first CLI arg is the image name.
cli-args unswons "image" set parse-switches run-files ;

View File

@ -26,7 +26,6 @@
! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
IN: kernel
USE: lists
: slip ( quot x -- x )
>r call r> ; inline
@ -51,36 +50,6 @@ USE: lists
#! Apply code to input.
swap dup >r call r> swap ; inline
IN: lists DEFER: uncons IN: kernel
: cond ( x list -- )
#! The list is of this form:
#!
#! [ [ condition 1 ] [ code 1 ]
#! [ condition 2 ] [ code 2 ]
#! ... ]
#!
#! Each condition is evaluated in turn. If it returns true,
#! the code is evaluated. If it returns false, the next
#! condition is checked.
#!
#! Before evaluating each condition, the top of the stack is
#! duplicated. After the last condition is evaluated, the
#! top of the stack is popped.
#!
#! So each condition and code block must have stack effect:
#! ( X -- )
#!
#! This combinator will not compile.
dup [
uncons >r over >r call r> r> rot [
car call
] [
cdr cond
] ifte
] [
2drop
] ifte ;
: ifte* ( cond true false -- )
#! If the condition is not f, execute the 'true' quotation,
#! with the condition on the stack. Otherwise, pop the

View File

@ -53,7 +53,7 @@ USE: words
scan str>number ; parsing
: ENUM:
dup CREATE swap unit define-compound succ ; parsing
dup CREATE swap unit define-compound 1 + ; parsing
: END-ENUM
drop ; parsing
@ -75,12 +75,15 @@ USE: words
dup "c-types" get hash dup [
nip
] [
drop "No such C type: " swap cat2 throw
drop "No such C type: " swap cat2 throw f
] ifte
] bind ;
: size ( name -- size )
c-type [ "width" get ] bind ;
: define-c-type ( quot name -- )
c-types [ >r <c-type> swap extend r> set ] bind ;
c-types [ >r <c-type> swap extend r> set ] bind ; inline
: define-getter ( offset type name -- )
#! Define a word with stack effect ( alien -- obj ) in the

View File

@ -38,19 +38,56 @@ USE: namespaces
USE: parser
USE: words
USE: hashtables
USE: strings
! Command line parameters specify libraries to load.
!
! -library:<foo>:name=<soname> -- define a library <foo>, to be
! loaded from the <soname> DLL.
!
! -library:<foo>:abi=stdcall -- define a library using the
! stdcall ABI. This ABI is usually used on Win32. Any other abi
! parameter, or a missing abi parameter indicates the cdecl ABI
! should be used, which is common on Unix.
BUILTIN: dll 15
BUILTIN: alien 16
: (library) ( name -- object )
"libraries" get hash ;
M: alien hashcode ( obj -- n )
alien-address >fixnum ;
: load-dll ( library -- dll )
"dll" get dup [
drop "name" get dlopen dup "dll" set
] unless ;
M: alien = ( obj obj -- ? )
over alien? [
over local-alien? over local-alien? or [
eq?
] [
alien-address swap alien-address =
] ifte
] [
2drop f
] ifte ;
SYMBOL: #c-invoke ( C ABI -- Unix and most Windows libs )
: library ( name -- object )
dup [ "libraries" get hash ] when ;
: load-dll ( name -- dll )
#! Higher level wrapper around dlopen primitive.
library dup [
[
"dll" get dup [
drop "name" get dlopen dup "dll" set
] unless
] bind
] when ;
: add-library ( library name abi -- )
"libraries" get [
<namespace> [
"abi" set
"name" set
] extend put
] bind ;
SYMBOL: #cleanup ( unwind stack by parameter )
SYMBOL: #c-call ( jump to raw address )
@ -58,76 +95,81 @@ SYMBOL: #c-call ( jump to raw address )
SYMBOL: #unbox ( move top of datastack to C stack )
SYMBOL: #box ( move EAX to datastack )
SYMBOL: #std-invoke ( stdcall ABI -- Win32 )
: library-abi ( library -- abi )
library [ [ "abi" get ] bind ] [ "cdecl" ] ifte* ;
: abi ( -- abi )
"abi" get "stdcall" = #std-invoke #c-invoke ? ;
SYMBOL: #alien-invoke
: alien-function ( function library -- address abi )
[
(library) [ load-dll dlsym abi ] bind
] [
dlsym-self #c-invoke
] ifte* ;
! These are set in the #c-invoke and #std-invoke dataflow IR
! nodes.
! These are set in the #alien-invoke dataflow IR node.
SYMBOL: alien-returns
SYMBOL: alien-parameters
: infer-alien ( -- )
4 ensure-d
dataflow-drop, pop-d car
dataflow-drop, pop-d car
dataflow-drop, pop-d car alien-function >r
dataflow-drop, pop-d car swap
r> dataflow, [
alien-returns set
alien-parameters set
] bind ;
: set-alien-returns ( returns node -- )
[ dup alien-returns set ] bind
"void" = [
[ object ] produce-d 1 0 node-outputs
] unless ;
: unbox-parameter ( function -- )
dlsym-self #unbox swons , ;
: set-alien-parameters ( parameters node -- )
[ dup alien-parameters set ] bind
[ drop object ] map dup dup ensure-d
length 0 node-inputs consume-d ;
: alien-node ( returns params function library -- )
cons #alien-invoke dataflow,
[ set-alien-parameters ] keep
set-alien-returns ;
: infer-alien ( -- )
[ object object object object ] ensure-d
dataflow-drop, pop-d literal-value
dataflow-drop, pop-d literal-value >r
dataflow-drop, pop-d literal-value
dataflow-drop, pop-d literal-value -rot
r> swap alien-node ;
: box-parameter
c-type [
"width" get cell align
"unboxer" get
] bind #unbox swons , ;
: linearize-parameters ( params -- count )
#! Generate code for boxing a list of C types.
#! Return amount stack must be unwound by.
[ alien-parameters get reverse ] bind 0 swap [
c-type [
"width" get cell align +
"unboxer" get
] bind unbox-parameter
box-parameter +
] each ;
: box-parameter ( function -- )
dlsym-self #box swons , ;
: linearize-returns ( returns -- )
[ alien-returns get ] bind dup "void" = [
drop
] [
c-type [ "boxer" get ] bind box-parameter
c-type [ "boxer" get ] bind #box swons ,
] ifte ;
: linearize-alien ( node -- )
dup linearize-parameters >r
dup [ node-param get ] bind #c-call swons ,
dup [ node-op get #c-invoke = ] bind
r> swap [ #cleanup swons , ] [ drop ] ifte
dup [ node-param get cdr library-abi "stdcall" = ] bind
r> swap [ drop ] [ #cleanup swons , ] ifte
linearize-returns ;
#c-invoke [ linearize-alien ] "linearizer" set-word-property
#std-invoke [ linearize-alien ] "linearizer" set-word-property
#alien-invoke [ linearize-alien ] "linearizer" set-word-property
: alien-invoke ( ... returns library function parameters -- ... )
#! Call a C library function.
#! 'returns' is a type spec, and 'parameters' is a list of
#! type specs. 'library' is an entry in the "libraries"
#! namespace.
"alien-invoke cannot be interpreted." throw ;
[
"alien-invoke cannot be interpreted. " ,
"Either the compiler is disabled, " ,
"or the ``" , rot , "'' library is missing. " ,
] make-string throw ;
\ alien-invoke [ 4 | 0 ] "infer-effect" set-word-property
\ alien-invoke [ [ object object object object ] [ ] ]
"infer-effect" set-word-property
\ alien-invoke [ infer-alien ] "infer" set-word-property

View File

@ -26,27 +26,49 @@
! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
IN: compiler
USE: alien
USE: math
USE: kernel
USE: hashtables
USE: namespaces
: cell 4 ;
: literal-table 1024 cell * ;
SYMBOL: interned-literals
: init-assembler ( -- )
compiled-offset literal-table + set-compiled-offset ;
: cell 4 ; inline
: compiled-header HEX: 01c3babe ; inline
: set-compiled-byte ( n addr -- )
<alien> 0 set-alien-1 ; inline
: set-compiled-cell ( n addr -- )
<alien> 0 set-alien-cell ; inline
: compile-aligned ( n -- )
compiled-offset swap align set-compiled-offset ;
compiled-offset cell 2 * align set-compiled-offset ; inline
: intern-literal ( obj -- lit# )
address
literal-top set-compiled-cell
literal-top dup cell + set-literal-top ;
dup interned-literals get hash dup [
nip
] [
drop [
address
literal-top set-compiled-cell
literal-top dup cell + set-literal-top
dup
] keep interned-literals get set-hash
] ifte ;
: compile-byte ( n -- )
compiled-offset set-compiled-byte
compiled-offset 1 + set-compiled-offset ;
compiled-offset 1 + set-compiled-offset ; inline
: compile-cell ( n -- )
compiled-offset set-compiled-cell
compiled-offset cell + set-compiled-offset ;
compiled-offset cell + set-compiled-offset ; inline
: begin-assembly ( -- code-len-fixup reloc-len-fixup )
compiled-header compile-cell
compiled-offset 0 compile-cell
compiled-offset 0 compile-cell ;
global [ <namespace> interned-literals set ] bind

View File

@ -121,6 +121,10 @@ USE: math
#! MOV INDIRECT <reg> TO <reg>.
HEX: 8b compile-byte 0 MOD-R/M ;
: D[R]>R ( disp reg reg -- )
#! MOV INDIRECT DISPLACED <reg> TO <reg>.
HEX: 8b compile-byte 1 MOD-R/M compile-byte ;
: R>[R] ( reg reg -- )
#! MOV <reg> TO INDIRECT <reg>.
HEX: 89 compile-byte swap 0 MOD-R/M ;

View File

@ -28,6 +28,7 @@
IN: compiler
USE: inference
USE: errors
USE: generic
USE: hashtables
USE: kernel
USE: lists
@ -40,6 +41,7 @@ USE: strings
USE: unparser
USE: vectors
USE: words
USE: test
: supported-cpu? ( -- ? )
cpu "unknown" = not ;
@ -49,14 +51,18 @@ USE: words
"Unsupported CPU; compiler disabled" throw
] unless ;
: compiling ( word -- definition )
: compiling ( word -- word parameter )
check-architecture
"verbose-compile" get [
"Compiling " write dup . flush
] when
cell compile-aligned dup save-xt word-parameter ;
dup word-parameter ;
: (compile) ( word -- )
GENERIC: (compile) ( word -- )
M: word (compile) drop ;
M: compound (compile) ( word -- )
#! Should be called inside the with-compiler scope.
compiling dataflow optimize linearize simplify generate ;
@ -78,16 +84,21 @@ USE: words
#! Compile the most recently defined word.
"compile" get [ word compile ] when ; parsing
: cannot-compile ( word -- )
: cannot-compile ( word error -- )
"verbose-compile" get [
"Cannot compile " write .
"Cannot compile " write swap .
print-error
] [
drop
2drop
] ifte ;
: try-compile ( word -- )
[ compile ] [ [ cannot-compile ] when ] catch ;
[ compile ] [ [ cannot-compile ] when* ] catch ;
: compile-all ( -- )
#! Compile all words.
[ try-compile ] each-word ;
supported-cpu? [
[ [ try-compile ] each-word ] time
] [
"Unsupported CPU" print
] ifte ;

View File

@ -31,39 +31,72 @@ USE: inference
USE: kernel
USE: namespaces
USE: words
USE: lists
USE: math
: DS ( -- address ) "ds" dlsym-self ;
: DS ( -- address ) "ds" f dlsym ;
: absolute-ds ( -- )
#! Add an entry to the relocation table for the 32-bit
#! immediate just compiled.
"ds" f f rel-dlsym ;
: PEEK-DS ( -- )
#! Peek datastack to EAX.
DS ECX [I]>R absolute-ds
ECX EAX [R]>R ;
: POP-DS ( -- )
#! Pop datastack to EAX.
DS ECX [I]>R
ECX EAX [R]>R
PEEK-DS
4 ECX R-I
ECX DS R>[I] ;
ECX DS R>[I] absolute-ds ;
#push-immediate [
DS ECX [I]>R
DS ECX [I]>R absolute-ds
4 ECX R+I
address ECX I>[R]
ECX DS R>[I]
ECX DS R>[I] absolute-ds
] "generator" set-word-property
#push-indirect [
DS ECX [I]>R
DS ECX [I]>R absolute-ds
4 ECX R+I
intern-literal EAX [I]>R
intern-literal EAX [I]>R rel-address
EAX ECX R>[R]
ECX DS R>[I] absolute-ds
] "generator" set-word-property
#replace-immediate [
DS ECX [I]>R absolute-ds
address ECX I>[R]
ECX DS R>[I] absolute-ds
] "generator" set-word-property
#replace-indirect [
DS ECX [I]>R absolute-ds
intern-literal EAX [I]>R rel-address
EAX ECX R>[R]
ECX DS R>[I] absolute-ds
] "generator" set-word-property
#slot [
PEEK-DS
2unlist type-tag >r cell * r> - EAX EAX D[R]>R
DS ECX [I]>R absolute-ds
EAX ECX R>[R]
ECX DS R>[I]
] "generator" set-word-property
#call [
dup postpone-word
dup dup postpone-word
CALL compiled-offset defer-xt
t rel-word
] "generator" set-word-property
#jump [
dup postpone-word
dup dup postpone-word
JUMP compiled-offset defer-xt
t rel-word
] "generator" set-word-property
#call-label [
@ -83,7 +116,7 @@ USE: words
] "generator" set-word-property
#return-to [
PUSH-I/PARTIAL 0 defer-xt
PUSH-I/PARTIAL 0 defer-xt rel-address
] "generator" set-word-property
#return [ drop RET ] "generator" set-word-property
@ -94,31 +127,49 @@ USE: words
#! The jump table must immediately follow this macro.
drop
POP-DS
1 EAX R>>I ( -- fixup )
EAX+/PARTIAL
1 EAX R>>I
EAX+/PARTIAL ( -- fixup ) rel-address
EAX JUMP-[R]
cell compile-aligned
compile-aligned
compiled-offset swap set-compiled-cell ( fixup -- )
] "generator" set-word-property
#target [
#! Jump table entries are absolute addresses.
compiled-offset 0 compile-cell 0 defer-xt
compiled-offset 0 compile-cell 0 defer-xt rel-address
] "generator" set-word-property
#c-call [ CALL JUMP-FIXUP ] "generator" set-word-property
#c-call [
uncons load-dll 2dup dlsym CALL JUMP-FIXUP t rel-dlsym
] "generator" set-word-property
#unbox [
CALL JUMP-FIXUP
dup f dlsym CALL JUMP-FIXUP f t rel-dlsym
EAX PUSH-R
] "generator" set-word-property
#box [
EAX PUSH-R
CALL JUMP-FIXUP
dup f dlsym CALL JUMP-FIXUP f t rel-dlsym
4 ESP R+I
] "generator" set-word-property
#cleanup [
dup 0 = [ drop ] [ ESP R+I ] ifte
] "generator" set-word-property
[
[ #drop drop ]
[ #dup dup ]
[ #swap swap ]
[ #over over ]
[ #pick pick ]
[ #>r >r ]
[ #r> r> ]
] [
uncons
[
car dup CALL compiled-offset defer-xt t rel-word drop
] cons
"generator" set-word-property
] each

View File

@ -34,6 +34,31 @@ USE: math
USE: namespaces
USE: strings
USE: words
USE: vectors
! To support saving compiled code to disk, generator words
! append relocation instructions to this vector.
SYMBOL: relocation-table
: rel, ( n -- ) relocation-table get vector-push ;
: relocating compiled-offset cell - rel, ;
: rel-primitive ( word rel/abs -- )
#! If flag is true; relative.
0 1 ? rel, relocating word-primitive rel, ;
: rel-word ( word rel/abs -- )
#! If flag is true; relative.
over primitive? [ rel-primitive ] [ 2drop ] ifte ;
: rel-dlsym ( name dll rel/abs -- )
#! If flag is true; relative.
2 3 ? rel, relocating cons intern-literal rel, ;
: rel-address ( -- )
#! Relocate address just compiled.
4 rel, relocating 0 rel, ;
: generate-node ( [ op | params ] -- )
#! Generate machine code for a node.
@ -43,8 +68,44 @@ USE: words
"No generator" throw
] ifte ;
: generate ( linear -- )
: generate-code ( word linear -- length )
compiled-offset >r
compile-aligned
swap save-xt
[ generate-node ] each
compile-aligned
compiled-offset r> - ;
: generate-reloc ( -- length )
relocation-table get
dup [ compile-cell ] vector-each
vector-length cell * ;
: (generate) ( word linear -- )
#! Compile a word definition from linear IR.
[ generate-node ] each ;
100 <vector> relocation-table set
begin-assembly swap >r >r
generate-code
generate-reloc
r> set-compiled-cell
r> set-compiled-cell ;
SYMBOL: previous-offset
: generate ( word linear -- )
#! If generation fails, reset compiled offset.
[
compiled-offset previous-offset set
(generate)
] [
[
previous-offset get set-compiled-offset
rethrow
] when*
] catch ;
#label [ save-xt ] "generator" set-word-property
: type-tag ( type -- tag )
#! Given a type number, return the tag number.
dup 6 > [ drop 3 ] when ;

View File

@ -44,6 +44,8 @@ USE: errors
SYMBOL: #push-immediate
SYMBOL: #push-indirect
SYMBOL: #replace-immediate
SYMBOL: #replace-indirect
SYMBOL: #jump-t ( branch if top of stack is true )
SYMBOL: #jump ( tail-call )
SYMBOL: #jump-label ( tail-call )
@ -148,8 +150,8 @@ SYMBOL: #target ( part of jump table )
: dispatch-body ( end label/param -- )
#! Output each branch, with a jump to the end label.
[
uncons label, (linearize) dup #jump-label swons ,
] each drop ;
uncons label, (linearize) #jump-label swons ,
] each-with ;
: check-dispatch ( vtable -- )
length num-types = [
@ -166,17 +168,3 @@ SYMBOL: #target ( part of jump table )
] "linearizer" set-word-property
#values [ drop ] "linearizer" set-word-property
[
[ #drop drop ]
[ #dup dup ]
[ #swap swap ]
[ #over over ]
[ #pick pick ]
[ #>r >r ]
[ #r> r> ]
] [
uncons
[ car #call swons , drop ] cons
"linearizer" set-word-property
] each

View File

@ -55,23 +55,23 @@ USE: prettyprint
#! Collect all literals from all branches.
[ node-param get ] bind [ [ scan-literal ] each ] each ;
: mentions-literal? ( literal list -- )
: mentions-literal? ( literal list -- ? )
#! Does the given list of result objects refer to this
#! literal?
[ dup cons? [ car over = ] [ drop f ] ifte ] some? ;
[ dupd value= ] some? nip ;
: consumes-literal? ( literal node -- ? )
#! Does the dataflow node consume the literal?
[
node-consume-d get mentions-literal? swap
node-consume-r get mentions-literal? nip or
dup node-consume-d get mentions-literal? swap
dup node-consume-r get mentions-literal? nip or
] bind ;
: produces-literal? ( literal node -- ? )
#! Does the dataflow node produce the literal?
[
node-produce-d get mentions-literal? swap
node-produce-r get mentions-literal? nip or
dup node-produce-d get mentions-literal? swap
dup node-produce-r get mentions-literal? nip or
] bind ;
: (can-kill?) ( literal node -- ? )
@ -101,7 +101,7 @@ USE: prettyprint
: (kill-nodes) ( literals dataflow -- )
#! Append live nodes to currently constructing list.
[ dupd "kill-node" [ nip , ] apply-dataflow ] each drop ;
[ "kill-node" [ nip , ] apply-dataflow ] each-with ;
: kill-nodes ( literals dataflow -- dataflow )
#! Remove literals and construct a list.
@ -187,16 +187,16 @@ USE: prettyprint
#swap [ 2drop t ] "can-kill" set-word-property
#swap [ kill-node ] "kill-node" set-word-property
: kill-mask ( literals node -- mask )
[ node-consume-d get ] bind [
dup cons? [ car over contains? ] [ drop f ] ifte
] map nip ;
: kill-mask ( killing inputs -- mask )
[ over [ over value= ] some? >boolean nip ] map nip ;
: reduce-stack-op ( literals node map -- )
#! If certain values passing through a stack op are being
#! killed, the stack op can be reduced, in extreme cases
#! to a no-op.
-rot [ kill-mask swap assoc ] keep
-rot [
[ node-consume-d get ] bind kill-mask swap assoc
] keep
over [ [ node-op set ] extend , ] [ 2drop ] ifte ;
#over [ 2drop t ] "can-kill" set-word-property

View File

@ -71,11 +71,7 @@ USE: words
] ifte ;
: simplify-node ( node rest -- rest ? )
over car "simplify" word-property [
call
] [
swap , f
] ifte* ;
over car "simplify" [ swap , f ] singleton ;
: find-label ( label linear -- rest )
[ cdr over = ] some? cdr nip ;
@ -87,11 +83,7 @@ USE: words
purge-labels [ (simplify) ] make-list ;
: follow ( linear -- linear )
dup car car "follow" word-property dup [
call
] [
drop
] ifte ;
dup car car "follow" [ ] singleton ;
#label [
cdr follow
@ -104,17 +96,34 @@ USE: words
: follows? ( op linear -- ? )
follow dup [ car car = ] [ 2drop f ] ifte ;
GENERIC: call-simplifier ( node rest -- rest ? )
M: cons call-simplifier ( node rest -- ? )
GENERIC: simplify-call ( node rest -- rest ? )
M: cons simplify-call ( node rest -- rest ? )
swap , f ;
PREDICATE: cons return-follows #return swap follows? ;
M: return-follows call-simplifier ( node rest -- rest ? )
M: return-follows simplify-call ( node rest -- rest ? )
>r
unswons [
[ #call | #jump ]
[ #call-label | #jump-label ]
] assoc swons , r> t ;
#call [ call-simplifier ] "simplify" set-word-property
#call-label [ call-simplifier ] "simplify" set-word-property
#call [ simplify-call ] "simplify" set-word-property
#call-label [ simplify-call ] "simplify" set-word-property
GENERIC: simplify-drop ( node rest -- rest ? )
M: cons simplify-drop ( node rest -- rest ? )
swap , f ;
PREDICATE: cons push-next ( list -- ? )
dup [
car car [ #push-immediate #push-indirect ] contains?
] when ;
M: push-next simplify-drop ( node rest -- rest ? )
nip uncons >r unswons [
[ #push-immediate | #replace-immediate ]
[ #push-indirect | #replace-indirect ]
] assoc swons , r> t ;
#drop [ simplify-drop ] "simplify" set-word-property

View File

@ -28,6 +28,7 @@
IN: lists
USE: generic
USE: kernel
USE: kernel-internals
! This file contains vital list-related words that everything
! else depends on, and is loaded early in bootstrap.
@ -35,6 +36,9 @@ USE: kernel
BUILTIN: cons 2
: car ( [ car | cdr ] -- car ) >cons 0 slot ; inline
: cdr ( [ car | cdr ] -- cdr ) >cons 1 slot ; inline
: swons ( cdr car -- [ car | cdr ] )
#! Push a new cons cell. If the cdr is f or a proper list,
#! has the effect of prepending the car to the cdr.
@ -58,6 +62,9 @@ BUILTIN: cons 2
: 2cdr ( cons cons -- car car )
swap cdr swap cdr ;
: 2uncons ( cons1 cons2 -- car1 car2 cdr1 cdr2 )
[ 2car ] 2keep 2cdr ;
: last* ( list -- last )
#! Last cons of a list.
dup cdr cons? [ cdr last* ] when ;
@ -66,14 +73,12 @@ BUILTIN: cons 2
#! Last element of a list.
last* car ;
: tail ( list -- tail )
#! Return the cdr of the last cons cell, or f.
dup [ last* cdr ] when ;
UNION: general-list f cons ;
: list? ( list -- ? )
PREDICATE: general-list list ( list -- ? )
#! Proper list test. A proper list is either f, or a cons
#! cell whose cdr is a proper list.
dup cons? [ tail ] when not ;
dup [ last* cdr ] when not ;
: all? ( list pred -- ? )
#! Push if the predicate returns true for each element of
@ -93,9 +98,18 @@ BUILTIN: cons 2
: each ( list quot -- )
#! Push each element of a proper list in turn, and apply a
#! quotation with effect ( X -- ) to each element.
#! quotation with effect ( elt -- ) to each element.
over [ (each) each ] [ 2drop ] ifte ; inline
: with ( obj quot elt -- obj quot )
#! Utility word for each-with, map-with.
pick pick >r >r swap call r> r> ;
: each-with ( obj list quot -- )
#! Push each element of a proper list in turn, and apply a
#! quotation with effect ( obj elt -- ) to each element.
swap [ with ] each 2drop ; inline
: subset ( list quot -- list )
#! Applies a quotation with effect ( X -- ? ) to each
#! element of a list; all elements for which the quotation

View File

@ -30,6 +30,7 @@ DEFER: callcc1
IN: errors
USE: kernel
USE: kernel-internals
USE: lists
USE: math
USE: namespaces

View File

@ -31,7 +31,7 @@ USE: errors
USE: stdio
: eval-catch ( str -- )
[ eval ] [ [ default-error-handler drop ] when* ] catch ;
[ eval ] [ [ print-error debug-help drop ] when* ] catch ;
: eval>string ( in -- out )
[ eval-catch ] with-string ;

View File

@ -39,31 +39,48 @@ USE: vectors
! Builtin metaclass for builtin types: fixnum, word, cons, etc.
SYMBOL: builtin
: builtin-method ( type generic definition -- )
-rot "vtable" word-property add-method ;
builtin [ builtin-method ] "define-method" set-word-property
builtin [
"builtin-type" word-property unit
] "builtin-supertypes" set-word-property
: builtin-predicate ( type# symbol -- word )
predicate-word [
swap [ swap type eq? ] cons define-compound
] keep ;
builtin [
( generic vtable definition class -- )
rot set-vtable drop
] "add-method" set-word-property
: builtin-class ( number type -- )
dup undefined? [ dup define-symbol ] when
builtin 50 "priority" set-word-property
! All builtin types are equivalent in ordering
builtin [ 2drop t ] "class<" set-word-property
: builtin-predicate ( type# symbol -- )
over f type = [
nip [ not ] "predicate" set-word-property
] [
over t type = [
nip [ ] "predicate" set-word-property
] [
dup predicate-word
[ rot [ swap type eq? ] cons define-compound ] keep
unit "predicate" set-word-property
] ifte
] ifte ;
: builtin-class ( type# symbol -- )
dup intern-symbol
2dup builtin-predicate
dupd "predicate" set-word-property
dup builtin "metaclass" set-word-property
swap "builtin-type" set-word-property ;
[ swap "builtin-type" set-word-property ] keep
builtin define-class ;
: BUILTIN:
#! Followed by type name and type number. Define a built-in
#! type predicate with this number.
CREATE scan-word swap builtin-class ; parsing
: builtin-type ( symbol -- n )
"builtin-type" word-property ;
: builtin-type ( n -- symbol )
unit classes get hash ;
: class ( obj -- class )
#! Analogous to the type primitive. Pushes the builtin
#! class of an object.
type builtin-type ;

Some files were not shown because too many files have changed in this diff Show More