added rint native;
authorcg
Tue, 13 Jul 1999 22:23:15 +0000
changeset 576 0214e973001d
parent 575 b126d405b936
child 577 18407fb4087b
added rint native; ask for Stdin replacement; fixed INSTANCEOF:
JavaVM.st
--- a/JavaVM.st	Tue Jul 13 21:22:11 1999 +0000
+++ b/JavaVM.st	Tue Jul 13 22:23:15 1999 +0000
@@ -34,7 +34,7 @@
 		EnteredMonitorObject EnteredMonitorObjectCount
 		EnteredMonitorProcess LeftMonitorObject JavaEventThread
 		JavaScreenUpdaterThread SystemProperties
-		NullPointerExceptionDebug'
+		NullPointerExceptionDebug StdinReplacementFileQuerySignal'
 	poolDictionaries:''
 	category:'Java-Support'
 !
@@ -1342,6 +1342,10 @@
     CallHandlerSignal nameClass:self message:#callHandlerSignal.
     CallHandlerSignal notifierString:'internal signal'.
 
+    StdinReplacementFileQuerySignal := QuerySignal new.
+    StdinReplacementFileQuerySignal nameClass:self message:#stdinReplacementFileQuerySignal.
+    StdinReplacementFileQuerySignal notifierString:'asking for stdin stream'.
+
     "
      JavaVM initialize
     "
@@ -1907,6 +1911,12 @@
     "Created: / 2.1.1998 / 18:05:58 / cg"
 !
 
+stdinReplacementFileQuerySignal
+    ^ StdinReplacementFileQuerySignal
+
+    "Created: / 2.1.1998 / 18:06:52 / cg"
+!
+
 unhandledJavaExceptionSignal
     ^ UnhandledJavaExceptionSignal
 
@@ -2759,6 +2769,13 @@
         ^ self
     ].
 
+    file == Stdin ifTrue:[
+        file := StdinReplacementFileQuerySignal raiseRequest.
+        file isNil ifTrue:[
+            file := Stdin
+        ]
+    ].
+
     "/ should always be bytes
 
     (file ~~ Stdin
@@ -2796,8 +2813,10 @@
         self halt.
     ].
     stream == Stdin ifTrue:[
-        self halt:'reading from standardInput ...'.
-        ^ -1 "/ 0
+        stream := StdinReplacementFileQuerySignal raiseRequest.
+        stream isNil ifTrue:[
+            ^ -1 "/ 0  EOF
+        ]
     ].
 
     FileIOTrace ifTrue:[
@@ -3151,14 +3170,20 @@
 
     file := self validateFile:(nativeContext receiver).
     file isNil ifTrue:[
-	self throwIOExceptionWithMessage:'invalid fileNo in available'.
-	^ self
+        self throwIOExceptionWithMessage:'invalid fileNo in available'.
+        ^ self
+    ].
+    file == Stdin ifTrue:[
+        file := StdinReplacementFileQuerySignal raiseRequest.
+        file isNil ifTrue:[
+            ^ 1
+        ]
     ].
     file isFileStream ifTrue:[
-	^ file size - file position + 1
+        ^ file size - file position + 1
     ].
     file atEnd ifTrue:[
-	^ 0.
+        ^ 0.
     ].
     self halt.
     ^ 1
@@ -3232,13 +3257,20 @@
 
     file := self validateFile:(nativeContext receiver).
 
+    file == Stdin ifTrue:[
+        file := StdinReplacementFileQuerySignal raiseRequest.
+        file isNil ifTrue:[
+            ^ -1
+        ]
+    ].
+
     FileIOTrace ifTrue:[
-	('JAVA: read 1 byte from ' , file pathName) infoPrintCR.
+        ('JAVA: read 1 byte from ' , file pathName) infoPrintCR.
     ].
 
     byte := file nextByte.
     byte isNil ifTrue:[
-	^ -1
+        ^ -1
     ].
     ^ byte
 
@@ -3259,6 +3291,13 @@
     file := self validateFile:(nativeContext receiver).
     nSkip := nativeContext argAt:1.
 
+    file == Stdin ifTrue:[
+        file := StdinReplacementFileQuerySignal raiseRequest.
+        file isNil ifTrue:[
+            ^ -1
+        ]
+    ].
+
     FileIOTrace ifTrue:[
         (('JAVA: skip %1 byte(s) from ' bindWith:nSkip printString) , file pathName) infoPrintCR.
     ].
@@ -4946,9 +4985,10 @@
 !
 
 _Math_rint:nativeContext
-    UnimplementedNativeMethodSignal raise
-
-    "Created: / 12.11.1998 / 18:52:47 / cg"
+    |dVal|
+
+    dVal := nativeContext argAt:1.
+    ^ dVal rounded asFloat.
 !
 
 _Math_sin:nativeContext
@@ -5329,7 +5369,7 @@
 
 _Runtime_runFinalization:nativeContext
     "/ void runFinalization ()
-    UnimplementedNativeMethodSignal raise
+"/    UnimplementedNativeMethodSignal raise
 
     "Modified: / 12.11.1998 / 18:52:07 / cg"
     "Created: / 12.11.1998 / 18:59:01 / cg"
@@ -10872,12 +10912,12 @@
 _INSTANCEOF:anObject _:aClassOrInterface
     "trampouline for unhandled cases ..."
 
-"/    aClassOrInterface isInterface ifTrue:[
-"/        (anObject class hasInterface:aClassOrInterface) ifTrue:[
+    aClassOrInterface isInterface ifTrue:[
+        (anObject class hasInterface:aClassOrInterface) ifTrue:[
 "/(aClassOrInterface name includesString:'LightweightPeer') ifTrue:[self halt].
-"/            ^ 1
-"/        ].
-"/    ].
+            ^ 1
+        ].
+    ].
 "/ (aClassOrInterface name includesString:'LightweightPeer') ifTrue:[self halt].
 
     anObject isArray ifTrue:[
@@ -11747,6 +11787,6 @@
 !JavaVM class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaVM.st,v 1.147 1999/07/13 21:22:11 cg Exp $'
+    ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaVM.st,v 1.148 1999/07/13 22:23:15 cg Exp $'
 ! !
 JavaVM initialize!