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