mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -08:00
Remove $rt_global and indirect references to runtime function
This commit is contained in:
parent
149775dd95
commit
63b2440e48
|
@ -19,15 +19,18 @@ import org.teavm.classlib.java.io.TIOException;
|
||||||
import org.teavm.classlib.java.io.TOutputStream;
|
import org.teavm.classlib.java.io.TOutputStream;
|
||||||
import org.teavm.interop.DelegateTo;
|
import org.teavm.interop.DelegateTo;
|
||||||
import org.teavm.interop.Import;
|
import org.teavm.interop.Import;
|
||||||
import org.teavm.platform.Platform;
|
import org.teavm.jso.JSBody;
|
||||||
|
|
||||||
class TConsoleOutputStreamStderr extends TOutputStream {
|
class TConsoleOutputStreamStderr extends TOutputStream {
|
||||||
@Override
|
@Override
|
||||||
@DelegateTo("writeLowLevel")
|
@DelegateTo("writeLowLevel")
|
||||||
public void write(int b) throws TIOException {
|
public void write(int b) throws TIOException {
|
||||||
Platform.getConsole().error(b);
|
writeJs(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JSBody(params = "b", script = "$rt_putStderr(b);")
|
||||||
|
private static native void writeJs(int b);
|
||||||
|
|
||||||
private void writeLowLevel(int b) {
|
private void writeLowLevel(int b) {
|
||||||
writeImpl(b);
|
writeImpl(b);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,15 +18,18 @@ package org.teavm.classlib.java.lang;
|
||||||
import org.teavm.classlib.java.io.TIOException;
|
import org.teavm.classlib.java.io.TIOException;
|
||||||
import org.teavm.classlib.java.io.TOutputStream;
|
import org.teavm.classlib.java.io.TOutputStream;
|
||||||
import org.teavm.interop.DelegateTo;
|
import org.teavm.interop.DelegateTo;
|
||||||
import org.teavm.platform.Platform;
|
import org.teavm.jso.JSBody;
|
||||||
|
|
||||||
class TConsoleOutputStreamStdout extends TOutputStream {
|
class TConsoleOutputStreamStdout extends TOutputStream {
|
||||||
@Override
|
@Override
|
||||||
@DelegateTo("writeLowLevel")
|
@DelegateTo("writeLowLevel")
|
||||||
public void write(int b) throws TIOException {
|
public void write(int b) throws TIOException {
|
||||||
Platform.getConsole().output(b);
|
writeJs(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JSBody(params = "b", script = "$rt_putStdout(b);")
|
||||||
|
private static native void writeJs(int b);
|
||||||
|
|
||||||
private void writeLowLevel(int b) {
|
private void writeLowLevel(int b) {
|
||||||
TConsoleOutputStreamStderr.writeImpl(b);
|
TConsoleOutputStreamStderr.writeImpl(b);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
"use strict";
|
"use strict";
|
||||||
var $rt_global = this;
|
|
||||||
var $rt_seed = 2463534242;
|
var $rt_seed = 2463534242;
|
||||||
function $rt_nextId() {
|
function $rt_nextId() {
|
||||||
var x = $rt_seed;
|
var x = $rt_seed;
|
||||||
|
|
|
@ -24,6 +24,8 @@ import org.teavm.interop.DelegateTo;
|
||||||
import org.teavm.interop.Unmanaged;
|
import org.teavm.interop.Unmanaged;
|
||||||
import org.teavm.jso.JSBody;
|
import org.teavm.jso.JSBody;
|
||||||
import org.teavm.jso.JSObject;
|
import org.teavm.jso.JSObject;
|
||||||
|
import org.teavm.jso.browser.Window;
|
||||||
|
import org.teavm.jso.core.JSString;
|
||||||
import org.teavm.platform.metadata.ClassResource;
|
import org.teavm.platform.metadata.ClassResource;
|
||||||
import org.teavm.platform.metadata.StaticFieldResource;
|
import org.teavm.platform.metadata.StaticFieldResource;
|
||||||
import org.teavm.platform.plugin.PlatformGenerator;
|
import org.teavm.platform.plugin.PlatformGenerator;
|
||||||
|
@ -84,10 +86,6 @@ public final class Platform {
|
||||||
@Unmanaged
|
@Unmanaged
|
||||||
public static native Class<?> asJavaClass(PlatformObject obj);
|
public static native Class<?> asJavaClass(PlatformObject obj);
|
||||||
|
|
||||||
public static PlatformConsole getConsole() {
|
|
||||||
return (PlatformConsole) getGlobal();
|
|
||||||
}
|
|
||||||
|
|
||||||
@JSBody(script = "return $rt_nextId();")
|
@JSBody(script = "return $rt_nextId();")
|
||||||
public static native int nextObjectId();
|
public static native int nextObjectId();
|
||||||
|
|
||||||
|
@ -191,14 +189,14 @@ public final class Platform {
|
||||||
public static native int schedule(PlatformRunnable runnable, int timeout);
|
public static native int schedule(PlatformRunnable runnable, int timeout);
|
||||||
|
|
||||||
public static void killSchedule(int id) {
|
public static void killSchedule(int id) {
|
||||||
((PlatformHelper) getGlobal()).killSchedule(id);
|
Window.clearTimeout(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@JSBody(script = "return [];")
|
@JSBody(script = "return [];")
|
||||||
public static native <T> PlatformQueue<T> createQueue();
|
public static native <T> PlatformQueue<T> createQueue();
|
||||||
|
|
||||||
public static PlatformString stringFromCharCode(int charCode) {
|
public static PlatformString stringFromCharCode(int charCode) {
|
||||||
return ((PlatformHelper) getGlobal()).getStringClass().fromCharCode(charCode);
|
return JSString.fromCharCode(charCode).cast();
|
||||||
}
|
}
|
||||||
|
|
||||||
@DelegateTo("isPrimitiveLowLevel")
|
@DelegateTo("isPrimitiveLowLevel")
|
||||||
|
@ -231,7 +229,4 @@ public final class Platform {
|
||||||
public static String getName(PlatformClass cls) {
|
public static String getName(PlatformClass cls) {
|
||||||
return cls.getMetadata().getName();
|
return cls.getMetadata().getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@JSBody(script = "return $rt_global;")
|
|
||||||
private static native JSObject getGlobal();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2015 Alexey Andreev.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.teavm.platform;
|
|
||||||
|
|
||||||
import org.teavm.jso.JSMethod;
|
|
||||||
import org.teavm.jso.JSObject;
|
|
||||||
|
|
||||||
public interface PlatformConsole extends JSObject {
|
|
||||||
@JSMethod("$rt_putStdout")
|
|
||||||
void output(int b);
|
|
||||||
|
|
||||||
@JSMethod("$rt_putStderr")
|
|
||||||
void error(int b);
|
|
||||||
}
|
|
|
@ -1,31 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2015 Alexey Andreev.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.teavm.platform;
|
|
||||||
|
|
||||||
import org.teavm.jso.JSMethod;
|
|
||||||
import org.teavm.jso.JSObject;
|
|
||||||
import org.teavm.jso.JSProperty;
|
|
||||||
|
|
||||||
interface PlatformHelper extends JSObject {
|
|
||||||
@JSMethod("$rt_nextId")
|
|
||||||
int nextId();
|
|
||||||
|
|
||||||
@JSProperty("String")
|
|
||||||
PlatformStringClass getStringClass();
|
|
||||||
|
|
||||||
@JSMethod("clearTimeout")
|
|
||||||
void killSchedule(int scheduleId);
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user