~manxi-david/pyeffect/pyeffect

« back to all changes in this revision

Viewing changes to src/s4/sma/ofo.py

  • Committer: dvspeed
  • Date: 2011-12-26 13:18:36 UTC
  • Revision ID: manxi.david@gmail.com-20111226131836-mvoy9y32z0ujxvm1
-Change of folder

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2011 David Manzanares <manxi.david@gmail.com>
 
2
#This file is part of PyEffect.
 
3
#
 
4
# PyEffect is free software: you can redistribute it and/or modify
 
5
# it under the terms of the GNU General Public License as published by
 
6
# the Free Software Foundation, either version 3 of the License, or
 
7
# (at your option) any later version.
 
8
#
 
9
# PyEffect is distributed in the hope that it will be useful,
 
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 
12
# GNU General Public License for more details.
 
13
#
 
14
# You should have received a copy of the GNU General Public License
 
15
# along with PyEffect. If not, see <http://www.gnu.org/licenses/>.
 
16
 
 
17
from s2 import lns
 
18
from aux import isNN
 
19
from s2 import data
 
20
from s2 import tStr
 
21
 
 
22
used = 0
 
23
 
 
24
def prerun():
 
25
        pass
 
26
 
 
27
def alloc():
 
28
        """This is the One For One algorithm,
 
29
        it allocates one block of memory for one var,
 
30
        it is designed to be used for debugging PyEffect"""
 
31
        global used
 
32
        sizeOf = {1: ".byte", 4:".long", 8:".quad"}
 
33
        dated = []
 
34
        for s in tStr.strs:
 
35
                for c in s.char:
 
36
                        dated.append(c.name)
 
37
                        used = used + c.size
 
38
                        data.string = data.string + c.name + ":\n\t" + sizeOf[c.size] + "\t0\n"
 
39
        for l in lns.lines:
 
40
                for a in l.acts:
 
41
                        if isNN(a) and a.up.mem == "static" and a.loc.asm == None:
 
42
                                if a.pointer == True:
 
43
                                        a.loc.asm = "$" + a.up.name
 
44
                                else:
 
45
                                        a.loc.asm = a.up.name
 
46
                                a.loc.Type = "smem"
 
47
                                if dated.count(a.up.name) == 0:
 
48
                                        dated.append(a.up.name)
 
49
                                        used = used + a.up.size
 
50
                                        data.string = data.string + a.up.name + ":\n\t" + sizeOf[a.up.size] + "\t0\n"