- don't hardcode so many colors\r
- ffi unicode strings: null char security hole\r
- utf16 string boxing\r
-- slot compile problem\r
- sdl console crash\r
- UI: don't roll over if mouse button is down\r
+- more accurate types for various words\r
+- optimize out >array, >tuple, >hashtable etc\r
\r
+ compiler/ffi:\r
\r
String text = buffer.getLineText(i);
int index = text.indexOf("USING:");
if(index != -1)
- return index + "USING:".length();
+ return buffer.getLineStartOffset(i) + index;
}
return -1;
if(end == -1)
end = buffer.getLength();
- String decl = text.substring(offset,end);
+ String decl = text.substring(offset + "USING:".length(),end);
List declList = new ArrayList();
StringTokenizer st = new StringTokenizer(decl);
declList.add(vocab);
Collections.sort(declList);
- StringBuffer buf = new StringBuffer(" ");
+ StringBuffer buf = new StringBuffer("USING: ");
Iterator iter = declList.iterator();
while(iter.hasNext())
{
BUILTIN: array 8
-: array-capacity ( array -- n ) 1 slot ; inline
-: vector-array ( vec -- array ) >vector 2 slot ; inline
+DEFER: %fixnum
+
+: array-capacity ( array -- n ) 1 slot %fixnum ; inline
+: vector-array ( vec -- array ) >vector 2 slot %array ; inline
: set-vector-array ( array vec -- ) >vector 2 set-slot ; inline
: array-nth ( n array -- obj )
clone-tuple dup clone-delegate ;
: tuple>list ( tuple -- list )
- dup array-capacity swap array>list ;
+ >tuple dup array-capacity swap array>list ;
M: tuple = ( obj tuple -- ? )
over tuple? [
IN: kernel-internals
-: hash-array 2 slot ; inline
-: set-hash-array 2 set-slot ; inline
+: hash-array >hashtable 2 slot ( promise ) %array ; inline
+: set-hash-array swap >array swap >hashtable 2 set-slot ; inline
: hash-bucket ( n hash -- alist )
swap >fixnum swap >hashtable hash-array array-nth ; inline
\ >string \ string infer-check
] "infer" set-word-property
-! : literal-slot ( -- )
-! dataflow-drop, pop-d literal-value
-! peek-d value-class builtin-supertypes dup length 1 = [
-! cons \ slot [ [ object ] [ object ] ] (consume/produce)
-! ] [
-! "slot called without static type knowledge" throw
-! ] ifte ;
-!
-! : computed-slot ( -- )
-! \ slot dup "infer-effect" word-property consume/produce ;
-!
-! \ slot [
-! [ object fixnum ] ensure-d
-! peek-d literal? [ literal-slot ] [ computed-slot ] ifte
-! ] "infer" set-word-property
+: fast-slot? ( -- ? )
+ #! If the slot number is literal and the object's type is
+ #! known, we can compile a slot access into a single
+ #! instruction (x86).
+ peek-d literal?
+ peek-next-d value-class builtin-supertypes length 1 = and ;
+
+: fast-slot ( -- )
+ dataflow-drop, pop-d literal-value
+ peek-d value-class builtin-supertypes cons
+ \ slot [ [ object ] [ object ] ] (consume/produce) ;
+
+: computed-slot ( -- )
+ \ slot dup "infer-effect" word-property consume/produce ;
+
+\ slot [
+ [ object fixnum ] ensure-d
+ fast-slot? [ fast-slot ] [ computed-slot ] ifte
+] "infer" set-word-property
: type-value-map ( value -- )
num-types [ dup builtin-type pick swons cons ] project
IN: scratchpad
-USE: errors
-USE: kernel
-USE: math
-USE: namespaces
-USE: parser
-USE: strings
-USE: test
-USE: vectors
-USE: lists
-USE: words
-USE: prettyprint
! Various things that broke CFactor at various times.
! This should run without issue (and tests nothing useful)
! in Java Factor
+USING: errors kernel lists math memory namespaces parser
+prettyprint strings test vectors words ;
"20 <sbuf> \"foo\" set" eval
"garbage-collection" eval
[ [ "2 car" ] parse ] [ print-error ] catch
-[ [ "\"\" { } vector-nth" ] parse ] [ type-check-error ] catch
+! [ [ "\"\" { } vector-nth" ] parse ] [ type-check-error ] catch
"error-line-number" get [ 1 ] unless* unparse ,
] make-string print
- "error-line" get print
+ "error-line" get dup string? [ print ] [ drop ] ifte
[ "error-col" get " " fill , "^" , ] make-string print ;
-! :folding=indent: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.
-
+! Copyright (C) 2004, 2005 Slava Pestov.
+! See http://factor.sf.net/license.txt for BSD license.
IN: interpreter
-USE: vectors
-USE: namespaces
-USE: kernel
-USE: lists
-USE: words
-USE: errors
-USE: strings
-USE: prettyprint
-USE: stdio
+USING: errors kernel lists math namespaces prettyprint stdio
+strings vectors words ;
! A Factor interpreter written in Factor. Used by compiler for
! partial evaluation, also for trace and step.
: push-d meta-d get vector-push ;
: pop-d meta-d get vector-pop ;
: peek-d meta-d get vector-peek ;
+: peek-next-d meta-d get [ vector-length 2 - ] keep vector-nth ;
SYMBOL: meta-n
SYMBOL: meta-c
CELL ds_bot;
/* raw pointer to datastack top */
-register DLLEXPORT CELL ds asm("esi");
+#ifdef FACTOR_X86
+ register DLLEXPORT CELL ds asm("esi");
+#else
+ CELL ds;
+#endif
/* raw pointer to callstack bottom */
CELL cs_bot;