nga-python: begin work to cache dictionary, provide faster versions of some words (working on #20)
FossilOrigin-Name: cdfb621e669956d3ea1ca2c0a5ae74a78f7d90d0c728b2bd4768f53ec904f007
This commit is contained in:
parent
a824c5b3aa
commit
858d81b49b
1 changed files with 8 additions and 4 deletions
|
@ -42,8 +42,12 @@ class Retro:
|
||||||
self.files = FileSystem()
|
self.files = FileSystem()
|
||||||
self.floats = FloatStack()
|
self.floats = FloatStack()
|
||||||
self.afloats = FloatStack()
|
self.afloats = FloatStack()
|
||||||
self.interpreter = self.memory.fetch(self.find_entry("interpret") + 1)
|
self.Dictionary = dict()
|
||||||
self.not_found = self.memory.fetch(self.find_entry("err:notfound") + 1)
|
self.Cached = dict()
|
||||||
|
self.Cached['interpreter'] = self.memory.fetch(self.find_entry("interpret") + 1)
|
||||||
|
self.Cached['not_found'] = self.memory.fetch(self.find_entry("err:notfound") + 1)
|
||||||
|
self.Cached['s:eq?'] = self.memory.fetch(self.find_entry("s:eq?") + 1)
|
||||||
|
|
||||||
self.instructions = [
|
self.instructions = [
|
||||||
self.i_nop,
|
self.i_nop,
|
||||||
self.i_lit,
|
self.i_lit,
|
||||||
|
@ -440,7 +444,7 @@ class Retro:
|
||||||
for token in line.split():
|
for token in line.split():
|
||||||
self.inject_string(token, 1024)
|
self.inject_string(token, 1024)
|
||||||
self.stack.push(1024)
|
self.stack.push(1024)
|
||||||
self.execute(self.interpreter, self.not_found)
|
self.execute(self.Cached['interpreter'], self.Cached['not_found'])
|
||||||
|
|
||||||
def run_file(self, file):
|
def run_file(self, file):
|
||||||
if not os.path.exists(file):
|
if not os.path.exists(file):
|
||||||
|
@ -456,7 +460,7 @@ class Retro:
|
||||||
for token in line.strip().split():
|
for token in line.strip().split():
|
||||||
self.inject_string(token, 1024)
|
self.inject_string(token, 1024)
|
||||||
self.stack.push(1024)
|
self.stack.push(1024)
|
||||||
self.execute(self.interpreter, self.not_found)
|
self.execute(self.Cached['interpreter'], self.Cached['not_found'])
|
||||||
|
|
||||||
def update_image(self):
|
def update_image(self):
|
||||||
import requests
|
import requests
|
||||||
|
|
Loading…
Reference in a new issue