Skip to content

Commit ad13c63

Browse files
authored
Merge pull request #202 from boriel/feature/new_opt_peephole
Feature/new opt peephole
2 parents 266275d + 2bc288b commit ad13c63

163 files changed

Lines changed: 8198 additions & 3294 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[bumpversion]
2-
current_version = 1.8.10
2+
current_version = 1.9.0
33
files = version.py
44

Changelog.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
1+
[v1.9.0](https://bitbucket.org/zxbasic/zxbasic/commits/tag/v1.8.10)
2+
===
3+
+ New and completely refactored optimizer which now allow patterns.<br />
4+
This new optimizer (after a year of hard work) not only optimizes better,<br />
5+
it also allows to specify new optimization patterns without touching the compiler code.
6+
+ New optimizer level -O4 (peephole)
7+
+ zxbasm (assembler) now allows several instructions per line using `:`
8+
+ zxbasm allows labels to be declared without using colon.
9+
+ Some other little optimizationn
10+
111
[v1.8.10](https://bitbucket.org/zxbasic/zxbasic/commits/tag/v1.8.10)
212
===
313
+ ! Bugfix: `FLASH 8` and `BRIGHT 8` were not working correctly. Fixed.
4-
+ Changelog file renamed to `Changelog.md` and renoved. Now uses Markdown.
14+
+ Changelog file renamed to `Changelog.md` and renovated. Now uses Markdown.
515
+ `PLOT`, `DRAW` and `CIRCLE` now do not use the ROM for ATTR (no ROM dependency)
616
+ ! Bugfix: Setting multiple `ORG` within ASM blocks crashed the compiler. Fixed.
717
+ Change code style to pass more flake8 tests

api/errmsg.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,22 @@ def msg_output(msg):
2525
global_.error_msg_cache.add(msg)
2626

2727

28-
def syntax_error(lineno, msg):
28+
def info(msg):
29+
if OPTIONS.Debug.value < 1:
30+
return
31+
OPTIONS.stderr.value.write("info: %s\n" % msg)
32+
33+
34+
def syntax_error(lineno, msg, fname=None):
2935
""" Generic syntax error routine
3036
"""
37+
if fname is None:
38+
fname = global_.FILENAME
39+
3140
if global_.has_errors > OPTIONS.max_syntax_errors.value:
3241
msg = 'Too many errors. Giving up!'
3342

34-
msg = "%s:%i: %s" % (global_.FILENAME, lineno, msg)
43+
msg = "%s:%i: %s" % (fname, lineno, msg)
3544
msg_output(msg)
3645

3746
if global_.has_errors > OPTIONS.max_syntax_errors.value:
@@ -40,10 +49,13 @@ def syntax_error(lineno, msg):
4049
global_.has_errors += 1
4150

4251

43-
def warning(lineno, msg):
52+
def warning(lineno, msg, fname=None):
4453
""" Generic warning error routine
4554
"""
46-
msg = "%s:%i: warning: %s" % (global_.FILENAME, lineno, msg)
55+
if fname is None:
56+
fname = global_.FILENAME
57+
58+
msg = "%s:%i: warning: %s" % (fname, lineno, msg)
4759
msg_output(msg)
4860
global_.has_warnings += 1
4961

identityset.py renamed to api/identityset.py

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,31 @@
22
# -*- coding: utf-8 -*-
33
# vim:ts=4:et:
44

5-
import collections
6-
75

86
class IdentitySet(object):
97
""" This set implementation only adds items
108
if they are not exactly the same (same reference)
119
preserving its order (OrderedDict). Allows deleting by ith-index.
1210
"""
13-
def __init__(self, l=None):
11+
def __init__(self, elems=None):
1412
self.elems = []
1513
self._elems = set()
16-
if l is not None:
17-
self.add(l)
14+
self.update(elems or [])
1815

19-
def add(self, l):
20-
if not isinstance(l, collections.Iterable):
21-
l = [l]
22-
self.elems.extend(x for x in l if x not in self._elems)
23-
self._elems.update(x for x in l)
16+
def add(self, elem):
17+
self.elems.append(elem)
18+
self._elems.add(elem)
2419

25-
def remove(self, l):
26-
if not isinstance(l, collections.Iterable):
27-
l = [l]
20+
def remove(self, elem):
21+
""" Removes an element if it exits. Otherwise does nothing.
22+
Returns if the element was removed.
23+
"""
24+
if elem in self._elems:
25+
self._elems.remove(elem)
26+
self.elems = [x for x in self.elems if x in self._elems]
27+
return True
2828

29-
self._elems.difference_update(l)
30-
self.elems = [x for x in self.elems if x not in self._elems]
29+
return False
3130

3231
def __len__(self):
3332
return len(self.elems)
@@ -45,11 +44,16 @@ def __delitem__(self, key):
4544
self.pop(self.elems.index(key))
4645

4746
def intersection(self, other):
48-
return IdentitySet([x for x in self.elems if x in self._elems.intersection(other)])
47+
return IdentitySet(self._elems.intersection(other))
4948

5049
def union(self, other):
5150
return IdentitySet(self.elems + [x for x in other])
5251

5352
def pop(self, i):
54-
tmp = self.elems.pop(i)
55-
self._elems.remove(tmp)
53+
result = self.elems.pop(i)
54+
self._elems.remove(result)
55+
return result
56+
57+
def update(self, elems):
58+
self.elems.extend(x for x in elems if x not in self._elems)
59+
self._elems.update(x for x in elems)

0 commit comments

Comments
 (0)