USE: unparser
USE: kernel-internals
USE: console
+USE: assembler
: default-cli-args
#! Some flags are *on* by default, unless user specifies
: warm-boot ( -- )
#! A fully bootstrapped image has this as the boot
#! quotation.
- boot
+ init-assembler
init-error-handler
init-random
default-cli-args
[ "shells" ] search execute ;
[
+ boot
warm-boot
garbage-collection
run-user-init
0 exit*
] set-boot
-init-error-handler
-
-! 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
-!
-! "Automatically inlining words called " write
-! auto-inline-count unparse write
-! " or less times..." print
-! auto-inline-count auto-inline
-
-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
+warm-boot
+
+os "win32" = [
+ "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
+ ! FIXME: KLUDGE to get FFI-based IO going in Windows.
+ "/library/bootstrap/win32-io.factor" run-resource
] 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
[[ "math-internals" "(fraction>)" ]]
[[ "parser" "str>float" ]]
[[ "unparser" "(unparse-float)" ]]
- [[ "math-internals" "(rect>)" ]]
+ [[ "math-internals" "<complex>" ]]
[[ "math-internals" "fixnum=" ]]
[[ "math-internals" "fixnum+" ]]
[[ "math-internals" "fixnum-" ]]
! $Id$
!
-! Copyright (C) 2004 Slava Pestov.
+! Copyright (C) 2004, 2005 Slava Pestov.
!
! Redistribution and use in source and binary forms, with or without
! modification, are permitted provided that the following conditions are met:
compiled-offset 0 compile-cell
compiled-offset 0 compile-cell ;
-global [ <namespace> interned-literals set ] bind
+: init-assembler ( -- )
+ global [ <namespace> interned-literals set ] bind ;
IN: errors
DEFER: throw
-IN: math
+IN: math-internals
USE: generic
USE: kernel
USE: kernel-internals
USE: math
-USE: math-internals
+
+: (rect>) ( xr xi -- x )
+ #! Does not perform a check that the arguments are reals.
+ #! Do not use in your own code.
+ dup 0 number= [ drop ] [ <complex> ] ifte ; inline
+
+IN: math
GENERIC: real ( #{ re im }# -- re )
M: real real ;
: rect> ( xr xi -- x )
over real? over real? and [
- dup 0 number= [ drop ] [ (rect>) ] ifte
+ (rect>)
] [
"Complex number must have real components" throw drop
] ifte ; inline
: *re ( x y -- xr*yr xi*ri ) 2>rect * >r * r> ; inline
: *im ( x y -- xi*yr xr*yi ) 2>rect >r * swap r> * ; inline
-M: complex + 2>rect + >r + r> rect> ;
-M: complex - 2>rect - >r - r> rect> ;
-M: complex * ( x y -- x*y ) 2dup *re - -rot *im + rect> ;
+M: complex + 2>rect + >r + r> (rect>) ;
+M: complex - 2>rect - >r - r> (rect>) ;
+M: complex * ( x y -- x*y ) 2dup *re - -rot *im + (rect>) ;
: abs^2 ( x -- y ) >rect sq swap sq + ; inline
: complex/ ( x y -- r i m )
#! r = xr*yr+xi*yi, i = xi*yr-xr*yi, m = yr*yr+yi*yi
dup abs^2 >r 2dup *re + -rot *im - r> ; inline
-M: complex / ( x y -- x/y ) complex/ tuck / >r / r> rect> ;
-M: complex /f ( x y -- x/y ) complex/ tuck /f >r /f r> rect> ;
+M: complex / ( x y -- x/y ) complex/ tuck / >r / r> (rect>) ;
+M: complex /f ( x y -- x/y ) complex/ tuck /f >r /f r> (rect>) ;
M: complex abs ( z -- |z| ) >rect mag2 ;
[ (fraction>) [ [ integer integer ] [ rational ] ] ]
[ str>float [ [ string ] [ float ] ] ]
[ (unparse-float) [ [ float ] [ string ] ] ]
- [ (rect>) [ [ real real ] [ number ] ] ]
+ [ <complex> [ [ real real ] [ number ] ] ]
[ fixnum= [ [ fixnum fixnum ] [ boolean ] ] ]
[ fixnum+ [ [ fixnum fixnum ] [ integer ] ] ]
[ fixnum- [ [ fixnum fixnum ] [ integer ] ] ]
#include "factor.h"
-/*
- * It is up to the caller to fill in the object's fields in a meaningful
- * fashion!
- */
-void* allot_object(CELL type, CELL length)
-{
- CELL* object = allot(length);
- *object = tag_header(type);
- return object;
-}
-
CELL object_size(CELL pointer)
{
CELL size;
type_error(type,tagged);
}
+/*
+ * It is up to the caller to fill in the object's fields in a meaningful
+ * fashion!
+ */
+INLINE void* allot_object(CELL type, CELL length)
+{
+ CELL* object = allot(length);
+ *object = tag_header(type);
+ return object;
+}
-void* allot_object(CELL type, CELL length);
CELL untagged_object_size(CELL pointer);
CELL object_size(CELL pointer);
void primitive_type(void);