Make it possible to defer start, boost web memory.
This commit is contained in:
5
Makefile
5
Makefile
@ -346,7 +346,7 @@ $(RES)/ueforth_res64.res: windows/ueforth.rc $(RES)/eforth.ico
|
|||||||
# ---- WEB ----
|
# ---- WEB ----
|
||||||
|
|
||||||
web: web_target web_tests
|
web: web_target web_tests
|
||||||
web_target: $(WEB)/terminal.html $(WEB)/ueforth.js
|
web_target: $(WEB)/terminal.html $(WEB)/lazy_terminal.html $(WEB)/ueforth.js
|
||||||
|
|
||||||
$(WEB):
|
$(WEB):
|
||||||
mkdir -p $(WEB)
|
mkdir -p $(WEB)
|
||||||
@ -354,6 +354,9 @@ $(WEB):
|
|||||||
$(WEB)/terminal.html: web/terminal.html | $(WEB)
|
$(WEB)/terminal.html: web/terminal.html | $(WEB)
|
||||||
cp $< $@
|
cp $< $@
|
||||||
|
|
||||||
|
$(WEB)/lazy_terminal.html: web/lazy_terminal.html | $(WEB)
|
||||||
|
cp $< $@
|
||||||
|
|
||||||
$(WEB)/ueforth.js: \
|
$(WEB)/ueforth.js: \
|
||||||
web/fuse_web.js \
|
web/fuse_web.js \
|
||||||
web/web.template.js \
|
web/web.template.js \
|
||||||
|
|||||||
27
web/lazy_terminal.html
Normal file
27
web/lazy_terminal.html
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<!--
|
||||||
|
Copyright 2022 Bradley D. Nelson
|
||||||
|
|
||||||
|
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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<script>
|
||||||
|
var ueforth = null;
|
||||||
|
window.onload = function() {
|
||||||
|
window.onclick = function() {
|
||||||
|
window.onclick = null;
|
||||||
|
ueforth.Start();
|
||||||
|
};
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<script src="ueforth.js"></script>
|
||||||
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
const HEAP_SIZE = (1024 * 1024);
|
const HEAP_SIZE = (4 * 1024 * 1024);
|
||||||
const STACK_CELLS = 4096;
|
const STACK_CELLS = 4096;
|
||||||
const VOCABULARY_DEPTH = 16;
|
const VOCABULARY_DEPTH = 16;
|
||||||
|
|
||||||
@ -601,18 +601,29 @@ function getGlobalObj() {
|
|||||||
var globalObj = getGlobalObj();
|
var globalObj = getGlobalObj();
|
||||||
|
|
||||||
var module = VM(globalObj, ffi, heap);
|
var module = VM(globalObj, ffi, heap);
|
||||||
|
|
||||||
function run() {
|
function run() {
|
||||||
module.run();
|
module.run();
|
||||||
setTimeout(run, 0);
|
setTimeout(run, 0);
|
||||||
}
|
}
|
||||||
if (globalObj.write) {
|
|
||||||
|
function Start() {
|
||||||
Init();
|
Init();
|
||||||
setTimeout(run, 0);
|
setTimeout(run, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (globalObj.write) {
|
||||||
|
Start();
|
||||||
} else {
|
} else {
|
||||||
|
if (globalObj.ueforth === null) {
|
||||||
|
globalObj.ueforth = context;
|
||||||
|
context.Start = Start;
|
||||||
|
} else {
|
||||||
window.addEventListener('load', function() {
|
window.addEventListener('load', function() {
|
||||||
Init();
|
Init();
|
||||||
setTimeout(run, 0);
|
setTimeout(run, 0);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|||||||
Reference in New Issue
Block a user