]> gitweb.factorcode.org Git - factor.git/blob - library/platform/jvm/kernel.factor
6573e2778f63b9f9766a541c76d6f90bfdfb0340
[factor.git] / library / platform / jvm / kernel.factor
1 !:folding=indent:collapseFolds=1:
2
3 ! $Id$
4 !
5 ! Copyright (C) 2003, 2004 Slava Pestov.
6
7 ! Redistribution and use in source and binary forms, with or without
8 ! modification, are permitted provided that the following conditions are met:
9
10 ! 1. Redistributions of source code must retain the above copyright notice,
11 !    this list of conditions and the following disclaimer.
12
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.
16
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.
27
28 IN: kernel
29
30 : word ( -- word )
31     ! Pushes most recently defined word.
32     interpreter "factor.FactorInterpreter" "last" jvar-get ;
33
34 : inline ( -- )
35     #! Marks the most recently defined word to be inlined.
36     t word "factor.FactorWord" "inline" jvar-set ;
37
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 ;
42
43 : hashcode ( obj -- hashcode )
44     #! If two objects are =, they must have equal hashcodes.
45     [ ] "java.lang.Object" "hashCode" jinvoke ;
46
47 : eq? ( a b -- ? )
48     #! Returns true if a and b are the same object.
49     [ "java.lang.Object" "java.lang.Object" ]
50     "factor.FactorLib" "eq" jinvoke-static ;
51
52 : = ( a b -- ? )
53     #! Push t if a is isomorphic to b.
54     [ "java.lang.Object" "java.lang.Object" ]
55     "factor.FactorLib" "equal" jinvoke-static ;
56
57 : class-of ( obj -- class )
58     [ ] "java.lang.Object" "getClass" jinvoke
59     [ ] "java.lang.Class" "getName" jinvoke ;
60
61 : clone ( obj -- obj )
62     [ ] "factor.PublicCloneable" "clone" jinvoke ;
63
64 : clone-array ( obj -- obj )
65     [ [ "java.lang.Object" ] ]
66     "factor.FactorLib" "cloneArray"
67     jinvoke-static ;
68
69 : deep-clone-array ( obj -- obj )
70     [ [ "java.lang.Object" ] ]
71     "factor.FactorLib" "deepCloneArray"
72     jinvoke-static ;
73
74 : is ( obj class -- boolean )
75     ! Like "instanceof" in Java.
76     [ "java.lang.Object" ] "java.lang.Class" "isInstance"
77     jinvoke ;
78
79 : toplevel ( -- )
80     interpreter
81     [ ] "factor.FactorInterpreter" "topLevel" jinvoke ;
82
83 : exec ( args -- exitCode )
84     [ [ "java.lang.String" ] ] "factor.FactorLib" "exec"
85     jinvoke-static ;
86
87 : exit* ( code -- )
88     [ "int" ] "java.lang.System" "exit" jinvoke-static ;
89
90 : garbage-collection ( -- )
91     [ ] "java.lang.System" "gc" jinvoke-static ;
92
93 : millis ( -- millis )
94     ! Pushes the current time, in milliseconds.
95     [ ] "java.lang.System" "currentTimeMillis" jinvoke-static ;
96
97 : system-property ( name -- value )
98     [ "java.lang.String" ] "java.lang.System" "getProperty"
99     jinvoke-static ;
100
101 : java? t ;
102 : native? f ;
103 : version "factor.FactorInterpreter" "VERSION" jvar-static-get ;