1 !:folding=indent:collapseFolds=1:
5 ! Copyright (C) 2003, 2004 Slava Pestov.
7 ! Redistribution and use in source and binary forms, with or without
8 ! modification, are permitted provided that the following conditions are met:
10 ! 1. Redistributions of source code must retain the above copyright notice,
11 ! this list of conditions and the following disclaimer.
13 ! 2. Redistributions in binary form must reproduce the above copyright notice,
14 ! this list of conditions and the following disclaimer in the documentation
15 ! and/or other materials provided with the distribution.
17 ! THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
18 ! INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
19 ! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
20 ! DEVELOPERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 ! SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 ! PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
23 ! OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 ! WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25 ! OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
26 ! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 ! Pushes most recently defined word.
32 interpreter "factor.FactorInterpreter" "last" jvar-get ;
35 #! Marks the most recently defined word to be inlined.
36 t word "factor.FactorWord" "inline" jvar-set ;
38 : interpret-only ( -- )
39 #! Marks the most recently defined word as an interpret-only word;
40 #! attempting to compile it will raise an error.
41 t word "factor.FactorWord" "interpretOnly" jvar-set ;
43 : hashcode ( obj -- hashcode )
44 #! If two objects are =, they must have equal hashcodes.
45 [ ] "java.lang.Object" "hashCode" jinvoke ;
48 #! Returns true if a and b are the same object.
49 [ "java.lang.Object" "java.lang.Object" ]
50 "factor.FactorLib" "eq" jinvoke-static ;
53 #! Push t if a is isomorphic to b.
54 [ "java.lang.Object" "java.lang.Object" ]
55 "factor.FactorLib" "equal" jinvoke-static ;
57 : class-of ( obj -- class )
58 [ ] "java.lang.Object" "getClass" jinvoke
59 [ ] "java.lang.Class" "getName" jinvoke ;
61 : clone ( obj -- obj )
62 [ ] "factor.PublicCloneable" "clone" jinvoke ;
64 : clone-array ( obj -- obj )
65 [ [ "java.lang.Object" ] ]
66 "factor.FactorLib" "cloneArray"
69 : deep-clone-array ( obj -- obj )
70 [ [ "java.lang.Object" ] ]
71 "factor.FactorLib" "deepCloneArray"
74 : is ( obj class -- boolean )
75 ! Like "instanceof" in Java.
76 [ "java.lang.Object" ] "java.lang.Class" "isInstance"
81 [ ] "factor.FactorInterpreter" "topLevel" jinvoke ;
83 : exec ( args -- exitCode )
84 [ [ "java.lang.String" ] ] "factor.FactorLib" "exec"
88 [ "int" ] "java.lang.System" "exit" jinvoke-static ;
90 : garbage-collection ( -- )
91 [ ] "java.lang.System" "gc" jinvoke-static ;
93 : millis ( -- millis )
94 ! Pushes the current time, in milliseconds.
95 [ ] "java.lang.System" "currentTimeMillis" jinvoke-static ;
97 : system-property ( name -- value )
98 [ "java.lang.String" ] "java.lang.System" "getProperty"
103 : version "factor.FactorInterpreter" "VERSION" jvar-static-get ;