1
0
mirror of https://github.com/catseye/SixtyPical.git synced 2024-06-14 23:29:29 +00:00

Refactor to replace some sketchy code with code actually in use.

--HG--
rename : src/sixtypical/objects.py => src/sixtypical/model.py
This commit is contained in:
Chris Pressey 2015-10-16 10:40:38 +01:00
parent 15e6a732f5
commit dd4c50fc50
8 changed files with 34 additions and 59 deletions

2
.gitignore vendored
View File

@ -1,3 +1 @@
*.o
*.hi
*.pyc

View File

@ -1,5 +1,3 @@
syntax: glob
*.o
*.hi
*.pyc

View File

@ -40,6 +40,7 @@ For 0.3:
* explicitly-addressed memory locations.
* generate 6502 code (either Ophis assembler or machine code `PRG` files.)
* `while` loops.
* `repeat` loops.
* a little demo that actually compiles and runs on a C64 emulator.
For 0.4 and/or beyond:

View File

@ -3,7 +3,7 @@
import sys
from sixtypical.ast import Program, Defn, Routine, Block, Instr
from sixtypical.parser import ConstantRef, LocationRef
from sixtypical.model import ConstantRef, LocationRef
UNINITIALIZED = 'UNINITIALIZED'

View File

@ -1,7 +1,7 @@
# encoding: UTF-8
from sixtypical.ast import Program, Defn, Routine, Block, Instr
from sixtypical.parser import ConstantRef, LocationRef
from sixtypical.model import ConstantRef, LocationRef
# TODO: should not inherit from dict

30
src/sixtypical/model.py Normal file
View File

@ -0,0 +1,30 @@
"""Data/storage model for SixtyPical."""
class LocationRef(object):
def __init__(self, name):
self.name = name
def __repr__(self):
return 'LocationRef(%r)' % self.name
class ConstantRef(object):
def __init__(self, value):
self.value = value
def __repr__(self):
return 'ConstantRef(%r)' % self.value
# TODO type=byte
REG_A = LocationRef('a')
REG_X = LocationRef('x')
REG_Y = LocationRef('y')
# TODO type=bit
FLAG_Z = LocationRef('z')
FLAG_C = LocationRef('c')
FLAG_N = LocationRef('n')
FLAG_V = LocationRef('v')

View File

@ -1,31 +0,0 @@
class Type(object):
pass
class BitType(Type):
pass
class ByteType(Type):
pass
class MemoryLocation(object):
def __init__(self, name, type_=ByteType, readonly=False):
self.name = name
self.type_ = type_
self.readonly = readonly
regA = MemoryLocation('a')
regX = MemoryLocation('x')
regY = MemoryLocation('y')
regC = MemoryLocation('c', type=BitType)
regZ = MemoryLocation('z', type=BitType)
regN = MemoryLocation('n', type=BitType)
regV = MemoryLocation('v', type=BitType)
class Context(dict):
# maps MemoryLoction -> properties: uninitialized, initialized, written
pass

View File

@ -3,6 +3,7 @@
import re
from sixtypical.ast import Program, Defn, Routine, Block, Instr
from sixtypical.model import LocationRef, ConstantRef
class Scanner(object):
@ -69,28 +70,6 @@ class Scanner(object):
return False
# - - - -
class LocationRef(object):
def __init__(self, name):
self.name = name
def __repr__(self):
return 'LocationRef(%r)' % self.name
class ConstantRef(object):
def __init__(self, value):
self.value = value
def __repr__(self):
return 'ConstantRef(%r)' % self.value
# - - - -
class Parser(object):
def __init__(self, text):
self.scanner = Scanner(text)