mirror of
https://github.com/irmen/prog8.git
synced 2025-08-16 05:27:31 +00:00
fix some errors
This commit is contained in:
@@ -42,7 +42,7 @@ class ConstantFold:
|
|||||||
self._constant_folding()
|
self._constant_folding()
|
||||||
|
|
||||||
def _constant_folding(self) -> None:
|
def _constant_folding(self) -> None:
|
||||||
for expression in list(self.module.all_nodes(Expression)):
|
for expression in self.module.all_nodes(Expression):
|
||||||
if expression.parent is None or expression.parent.parent is None:
|
if expression.parent is None or expression.parent.parent is None:
|
||||||
# stale expression node (was part of an expression that was constant-folded away)
|
# stale expression node (was part of an expression that was constant-folded away)
|
||||||
continue
|
continue
|
||||||
|
@@ -8,7 +8,7 @@ Written by Irmen de Jong (irmen@razorvine.net) - license: GNU GPL 3.0
|
|||||||
import contextlib
|
import contextlib
|
||||||
import math
|
import math
|
||||||
import attr
|
import attr
|
||||||
from typing import Set, Callable
|
from typing import Set, Callable, no_type_check
|
||||||
from ..datatypes import FLOAT_MAX_POSITIVE, FLOAT_MAX_NEGATIVE
|
from ..datatypes import FLOAT_MAX_POSITIVE, FLOAT_MAX_NEGATIVE
|
||||||
from ..plyparse import Scope, AstNode
|
from ..plyparse import Scope, AstNode
|
||||||
from ..compile import Zeropage
|
from ..compile import Zeropage
|
||||||
@@ -129,6 +129,7 @@ def preserving_registers(registers: Set[str], scope: Scope, out: Callable, loads
|
|||||||
yield
|
yield
|
||||||
|
|
||||||
|
|
||||||
|
@no_type_check
|
||||||
def scoped_name(node_with_name: AstNode, current_scope: Scope) -> str:
|
def scoped_name(node_with_name: AstNode, current_scope: Scope) -> str:
|
||||||
node_scope = node_with_name.my_scope()
|
node_scope = node_with_name.my_scope()
|
||||||
return node_with_name.name if node_scope is current_scope else node_scope.name + "." + node_with_name.name
|
return node_with_name.name if node_scope is current_scope else node_scope.name + "." + node_with_name.name
|
||||||
|
@@ -132,7 +132,7 @@
|
|||||||
|
|
||||||
; (constant) expressions
|
; (constant) expressions
|
||||||
var .word expr_byte1b = -1-2-3-4-$22+$80+ZP.zpconst
|
var .word expr_byte1b = -1-2-3-4-$22+$80+ZP.zpconst
|
||||||
var .byte expr_fault2 = 1 + (8/3)+sin(33) + max(1,2,3)
|
var .byte expr_fault2 = 1 + (8/3)+sin(33) + len("abc")
|
||||||
|
|
||||||
|
|
||||||
sin:
|
sin:
|
||||||
|
Reference in New Issue
Block a user