mirror of
https://github.com/esphome/esphome.git
synced 2025-09-02 19:32:19 +01:00
Refactor font creation to save stack (#1707)
This commit is contained in:
@@ -411,6 +411,16 @@ class ProgmemAssignmentExpression(AssignmentExpression):
|
||||
return f"static const {self.type} {self.name}[] PROGMEM = {self.rhs}"
|
||||
|
||||
|
||||
class StaticConstAssignmentExpression(AssignmentExpression):
|
||||
__slots__ = ()
|
||||
|
||||
def __init__(self, type_, name, rhs, obj):
|
||||
super().__init__(type_, "", name, rhs, obj)
|
||||
|
||||
def __str__(self):
|
||||
return f"static const {self.type} {self.name}[] = {self.rhs}"
|
||||
|
||||
|
||||
def progmem_array(id_, rhs) -> "MockObj":
|
||||
rhs = safe_exp(rhs)
|
||||
obj = MockObj(id_, ".")
|
||||
@@ -420,6 +430,15 @@ def progmem_array(id_, rhs) -> "MockObj":
|
||||
return obj
|
||||
|
||||
|
||||
def static_const_array(id_, rhs) -> "MockObj":
|
||||
rhs = safe_exp(rhs)
|
||||
obj = MockObj(id_, ".")
|
||||
assignment = StaticConstAssignmentExpression(id_.type, id_, rhs, obj)
|
||||
CORE.add(assignment)
|
||||
CORE.register_variable(id_, obj)
|
||||
return obj
|
||||
|
||||
|
||||
def statement(expression: Union[Expression, Statement]) -> Statement:
|
||||
"""Convert expression into a statement unless is already a statement."""
|
||||
if isinstance(expression, Statement):
|
||||
|
Reference in New Issue
Block a user