Commit 2f49173c authored by pazsan's avatar pazsan

Several fixes and typos I forgot to check in until recently

Documentation additions (not completed)
parent 2db21e82
......@@ -7,15 +7,6 @@ Conditional compilation continues after the file ends. This is allowed
by the standard (through an ambiguous condition), but the compiler
should at least produce a warning. anton 27jan95
DOS and OS/2 don't like . at begin of a file (.gforth-history). bernd 6sep95py
see does not leave a space after two-digit literals:
: xxx 50 ;
see xxx
gives
: xxx
50;
QUERY and TIB may behave differently than some may expect. TIB always
points to the current SOURCE, and QUERY puts its result there. anton
28nov96
......
......@@ -147,7 +147,6 @@ EC_SRC = \
asm/generic.fs \
asm/target.fs \
ec/00-readme \
ec/crossdoc.fd \
ec/mirror.fs \
ec/mirrors.fs \
ec/shex.fs \
......@@ -296,7 +295,7 @@ DOCDIST = doc/gforth.info doc/gforth.info-* doc/gforth.ps
#stuff in a binonly distribution
BINONLYDIST = config.status Makefile gforth gforth-ditc \
$(OBJECTS0) $(OBJECTS) $(OBJECTS_DITC)\
arch/$(machine)/machine.h engine/config.h engione/Makefile \
arch/$(machine)/machine.h engine/config.h engine/Makefile \
stamp-h kernel/version.fs version-stamp \
INSTALL.BINDIST
......@@ -619,8 +618,8 @@ prim.TAGS: prim.b prims2x.fs
$(CP) $@- $@
$(RM) $@-
doc/doc.fd: doc/makedoc.fs $(GFORTH_FI_SRC) code.fs objects.fs oof.fs
$(FORTHK) -e "s\" doc/doc.fd\"" doc/makedoc.fs startup.fs code.fs objects.fs oof.fs -e bye
doc/doc.fd: doc/makedoc.fs $(GFORTH_FI_SRC) code.fs objects.fs oof.fs mini-oof.fs
$(FORTHK) -e "s\" doc/doc.fd\"" doc/makedoc.fs startup.fs code.fs objects.fs oof.fs mini-oof.fs -e bye
doc/crossdoc.fd: $(KERN_SRC) kernel/version.fs $(FORTH_GEN0)
$(FORTHK) -e 's" mach32l.fs"' kernel/main.fs -e bye
......
......@@ -20,6 +20,12 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifdef HAVE_LIBKERNEL32
#ifdef i386
#define SYSCALL __attribute__ ((stdcall))
#endif
#endif
#include "../generic/machine.h"
/* indirect threading is faster on the 486, on the 386 direct
......
......@@ -33,4 +33,4 @@ game, type "q".
More informations about the 4stack processor, including a description
of the architecture, a user manual, a simulator, and a description of
a sample implementation in Verilog can be found in
http://www.informatik.tu-muenchen.de/~paysan/4stack.html
http://www.jwdt.com/~paysan/4stack.html
......@@ -30,6 +30,12 @@ typedef double DFloat;
/* the IEEE single precision type */
typedef float SFloat;
/* define SYSCALL */
#ifndef SYSCALL
#define SYSCALL
#endif
#ifndef USE_FTOS
#ifndef USE_NO_FTOS
/* keep top of FP stack in register. Since most processors have FP
......
......@@ -99,9 +99,9 @@ extern int cacheflush(void *, int, int, size_t);
#ifdef FORCE_REG /* highly recommended */
#if defined(amigaos)
# define IPREG asm("a6")
# define IPREG asm("%a6")
#else
# define IPREG asm("a5")
# define IPREG asm("%a5")
#endif
#define SPREG asm("%a4")
#define RPREG asm("%a3")
......
......@@ -260,7 +260,7 @@ create brick-val 1 c, 2 c, 3 c, 3 c, 4 c, 5 c, 5 c,
else false then ;
: drop-brick \ --- ; move brick down fast
begin 1 0 move-brick 0= until ;
begin 1 0 move-brick key? drop 0= until ;
: move-line \ from to ---
over 0 pit over 0 pit wide 2* cmove draw-line
......
......@@ -16,6 +16,13 @@ You can add a word to the list with "' my-init foo8 chained". You can
execute all the code with "foo8 chainperform".
[THEN]
has? cross
[IF] e? compiler
[ELSE] true
[THEN]
[IF] \ only needed with compiler
[IFUNDEF] linked
: linked here over @ a, swap ! ;
[THEN]
......@@ -25,6 +32,8 @@ execute all the code with "foo8 chainperform".
: chained ( xt list -- ) \ gforth
linked , ;
[THEN]
: chainperform ( list -- ) \ gforth
BEGIN @ dup WHILE dup cell+ perform REPEAT drop ;
......@@ -68,14 +68,14 @@ Warnings off
\G SetValue searches in the current vocabulary
save-input bl word >r restore-input throw r> count
get-current search-wordlist
IF bl word drop >body ! ELSE Value THEN ;
IF ['] to execute ELSE Value THEN ;
: DefaultValue ( n -- <name> )
\G Same behaviour as "Value" if the <name> is not defined
\G DefaultValue searches in the current vocabulary
save-input bl word >r restore-input throw r> count
get-current search-wordlist
IF bl word drop drop drop ELSE Value THEN ;
IF bl word drop 2drop ELSE Value THEN ;
hex
......
......@@ -18,7 +18,7 @@ Programming style note:
@ifinfo
This file documents Gforth @value{VERSION}
Copyright @copyright{} 1995-1997 Free Software Foundation, Inc.
Copyright @copyright{} 1995-1998 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
......@@ -61,7 +61,7 @@ Copyright @copyright{} 1995-1997 Free Software Foundation, Inc.
@comment The following two commands start the copyright page.
@page
@vskip 0pt plus 1filll
Copyright @copyright{} 1995--1997 Free Software Foundation, Inc.
Copyright @copyright{} 1995--1998 Free Software Foundation, Inc.
@comment !! Published by ... or You can get a copy of this manual ...
......@@ -103,6 +103,7 @@ personal machines. This manual corresponds to version @value{VERSION}.
* Emacs and Gforth:: The Gforth Mode
* Image Files:: @code{.fi} files contain compiled code
* Engine:: The inner interpreter and the primitives
* Cross Compiler:: The Cross Compiler
* Bugs:: How to report them
* Origin:: Authors and ancestors of Gforth
* Word Index:: An item for each Forth word
......@@ -339,6 +340,16 @@ Primitives
* Automatic Generation::
* TOS Optimization::
* Produced code::
System Libraries
* Binding to System Library::
Cross Compiler
* Using the Cross Compiler::
* How the Cross Compiler Works::
@end menu
@node License, Goals, Top, Top
......@@ -4098,7 +4109,7 @@ operation @code{draw}. We can perform the operation
@end example
where @code{t-rex} is an object or object pointer, created with e.g.
@code{graphical : trex}.
@code{graphical : t-rex}.
@cindex abstract class
How do we create a graphical object? With the present definitions,
......@@ -4265,31 +4276,130 @@ doc---oof-class;
@end itemize
@c -------------------------------------------------------------
@node Class Implementation, , Class Declaration, OOF
@subsubsection Class Implementation
@cindex class implementation
@node Mini-OOF, , OOF, Object-oriented Forth
@c -------------------------------------------------------------
@node Mini-OOF, , OOF, Object-oriented Forth
@subsection Mini-OOF
@cindex mini-oof
Gforth's third object oriented Forth package is a 12-liner. It uses a
bit of a mixture of the @file{object.fs} and the @file{oof.fs} syntax,
and reduces to the bare minimum of features.
and reduces to the bare minimum of features. This is based on a posting
of Bernd Paysan in comp.arch.
@menu
* Mini-OOF Usage::
* Mini-OOF Example::
@end menu
@c -------------------------------------------------------------
@node Mini-OOF Usage, Mini-OOF Example, , Mini-OOF
@subsubsection Usage
@cindex mini-oof usage
Basically, there are seven words, to define a method, a variable, a
class; to end a class, to define a method, to allocate an object, to
resolve binding, and the base class (which allocates one cell for the
object pointer).
doc-method
Defines a method
doc-var
Defines a variable with size bytes
doc-class
Starts the definition of a sub-class
doc-end-class
Ends the definition of a class
doc-defines
Binds the xt to the method name in the class
doc-new
Creates a new incarnation of the class
doc-::
Compiles the method name of the class (not immediate!)
doc-object
Is the base class of all objects
@c -------------------------------------------------------------
@node Mini-OOF Example, , Mini-OOF Usage, Mini-OOF
@subsubsection Mini-OOF Example
@cindex mini-oof example
A short example shows how to use this package.
@example
: method ( m v -- m' v ) Create over , swap cell+ swap
DOES> ( ... o -- ... ) @ over @ + @ execute ;
: var ( m v size -- m v' ) Create over , +
DOES> ( o -- addr ) @ + ;
: class ( class -- class methods vars ) dup 2@ ;
: end-class ( class methods vars -- )
Create here >r , dup , 2 cells ?DO ['] noop , cell +LOOP
cell+ dup cell+ swap @ 2 - cells r> 2 cells + swap move ;
: defines ( xt class -- ) ' >body @ + ! ;
: new ( class -- o ) here over @ allot swap over ! ;
: :: ( class "name" -- ) ' >body @ + @ compile, ;
Create object 1 cells , 2 cells ,
object class
method init
method draw
end-class graphical
@end example
This code defines a class @code{graphical} with an
operation @code{draw}. We can perform the operation
@code{draw} on any @code{graphical} object, e.g.:
@example
100 100 t-rex draw
@end example
where @code{t-rex} is an object or object pointer, created with e.g.
@code{graphical new Constant t-rex}.
For concrete graphical objects, we define child classes of the
class @code{graphical}, e.g.:
@example
graphical class
cell var circle-radius
end-class circle \ "graphical" is the parent class
:noname ( x y -- )
circle-radius @@ draw-circle ; circle defines draw
:noname ( r -- )
circle-radius ! ; circle defines init
@end example
There is no implicit init method, so we have to define one. The creation
code of the object now has to call init explicitely.
@example
circle new Constant my-circle
50 my-circle init
@end example
It is also possible to add a function to create named objects with
automatic call of @code{init}, given that all objects have @code{init}
on the same place
@example
: new: ( .. o "name" -- )
new dup Constant init ;
80 circle new: large-circle
@end example
We can draw this new circle at (100,100)
with
@example
100 100 my-circle draw
@end example
@c -------------------------------------------------------------
......@@ -6613,7 +6723,7 @@ arguments as files to be loaded and strings to be evaluated. Therefore,
@code{'cold} should remove the arguments it has used in this case.
@c ******************************************************************
@node Engine, Bugs, Image Files, Top
@node Engine, Binding to System Library, Image Files, Top
@chapter Engine
@cindex engine
@cindex virtual machine
......@@ -7113,7 +7223,26 @@ newer version of these measurements at
@url{http://www.complang.tuwien.ac.at/forth/performance.html}. You can
find numbers for Gforth on various machines in @file{Benchres}.
@node Bugs, Origin, Engine, Top
@node Binding to System Library, Cross Compiler, Engine, Top
@section Binding to System Library
@node Cross Compiler, Bugs, Binding to System Library, Top
@section Cross Compiler
Cross Compiler
@menu
* Using the Cross Compiler::
* How the Cross Compiler Works::
@end menu
@node Using the Cross Compiler, , How the Cross Compiler Works, Cross Compiler
@subsection Using the Cross Compiler
@node How the Cross Compiler Works, Using the Cross Compiler, , Cross Compiler
@subsection How the Cross Compiler Works
@node Bugs, Origin, Cross Compiler, Top
@chapter Bugs
@cindex bug reporting
......
1 cells Constant cell
: method ( m v -- m' v ) Create over , swap cell+ swap
DOES> ( ... o -- ... ) @ over @ + @ execute ;
: var ( m v size -- m v' ) Create over , +
DOES> ( o -- addr ) @ + ;
: class ( class -- class methods vars ) dup 2@ ;
: end-class ( class methods vars -- )
Create here >r , dup , 2 cells ?DO ['] noop , cell +LOOP
Create here >r , dup , 2 cells ?DO ['] noop , 1 cells +LOOP
cell+ dup cell+ swap @ 2 - cells r> 2 cells + swap move ;
: defines ( xt class -- ) ' >body @ + ! ;
: defines ( xt class "name" -- ) ' >body @ + ! ;
: new ( class -- o ) here over @ allot swap over ! ;
: :: ( class "name" -- ) ' >body @ + @ compile, ;
Create object 1 cells , 2 cells ,
......@@ -3,7 +3,6 @@ s%SHELL%# SHELL%g
# s% rm% del%g
# s% cp% copy%g
s% ln -s% cp%g
s%@mach_h@%386%g
s%-pipe %%g
s% ./gforth% gforth%g
......@@ -49,3 +48,4 @@ s%gforth-ditc%gforth-d%g
s%engine-ditc%engine-d%g
s%main-ditc%main-d%g
s%@OSCLASS@%dos%g
s%$(MAKE) -C%bash makein.bsh%g
......@@ -2004,12 +2004,12 @@ define(argclist,
\ icall(argnum)
define(icall,
`icall$1 argflist($1)u -- uret gforth
uret = ((Cell(*)(argdlist($1)))u)(argclist($1));
uret = (SYSCALL(Cell(*)(argdlist($1)))u)(argclist($1));
')
define(fcall,
`fcall$1 argflist($1)u -- rret gforth
rret = ((Float(*)(argdlist($1)))u)(argclist($1));
rret = (SYSCALL(Float(*)(argdlist($1)))u)(argclist($1));
')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment