mirror of
https://github.com/esphome/esphome.git
synced 2025-09-02 19:32:19 +01:00
Remove unused obj attribute from AssignmentExpression (#3145)
This commit is contained in:
@@ -62,14 +62,13 @@ class RawExpression(Expression):
|
||||
|
||||
|
||||
class AssignmentExpression(Expression):
|
||||
__slots__ = ("type", "modifier", "name", "rhs", "obj")
|
||||
__slots__ = ("type", "modifier", "name", "rhs")
|
||||
|
||||
def __init__(self, type_, modifier, name, rhs, obj):
|
||||
def __init__(self, type_, modifier, name, rhs):
|
||||
self.type = type_
|
||||
self.modifier = modifier
|
||||
self.name = name
|
||||
self.rhs = safe_exp(rhs)
|
||||
self.obj = obj
|
||||
|
||||
def __str__(self):
|
||||
if self.type is None:
|
||||
@@ -427,8 +426,8 @@ class LineComment(Statement):
|
||||
class ProgmemAssignmentExpression(AssignmentExpression):
|
||||
__slots__ = ()
|
||||
|
||||
def __init__(self, type_, name, rhs, obj):
|
||||
super().__init__(type_, "", name, rhs, obj)
|
||||
def __init__(self, type_, name, rhs):
|
||||
super().__init__(type_, "", name, rhs)
|
||||
|
||||
def __str__(self):
|
||||
return f"static const {self.type} {self.name}[] PROGMEM = {self.rhs}"
|
||||
@@ -437,8 +436,8 @@ class ProgmemAssignmentExpression(AssignmentExpression):
|
||||
class StaticConstAssignmentExpression(AssignmentExpression):
|
||||
__slots__ = ()
|
||||
|
||||
def __init__(self, type_, name, rhs, obj):
|
||||
super().__init__(type_, "", name, rhs, obj)
|
||||
def __init__(self, type_, name, rhs):
|
||||
super().__init__(type_, "", name, rhs)
|
||||
|
||||
def __str__(self):
|
||||
return f"static const {self.type} {self.name}[] = {self.rhs}"
|
||||
@@ -447,7 +446,7 @@ class StaticConstAssignmentExpression(AssignmentExpression):
|
||||
def progmem_array(id_, rhs) -> "MockObj":
|
||||
rhs = safe_exp(rhs)
|
||||
obj = MockObj(id_, ".")
|
||||
assignment = ProgmemAssignmentExpression(id_.type, id_, rhs, obj)
|
||||
assignment = ProgmemAssignmentExpression(id_.type, id_, rhs)
|
||||
CORE.add(assignment)
|
||||
CORE.register_variable(id_, obj)
|
||||
return obj
|
||||
@@ -456,7 +455,7 @@ def progmem_array(id_, rhs) -> "MockObj":
|
||||
def static_const_array(id_, rhs) -> "MockObj":
|
||||
rhs = safe_exp(rhs)
|
||||
obj = MockObj(id_, ".")
|
||||
assignment = StaticConstAssignmentExpression(id_.type, id_, rhs, obj)
|
||||
assignment = StaticConstAssignmentExpression(id_.type, id_, rhs)
|
||||
CORE.add(assignment)
|
||||
CORE.register_variable(id_, obj)
|
||||
return obj
|
||||
@@ -484,7 +483,7 @@ def variable(id_: ID, rhs: SafeExpType, type_: "MockObj" = None) -> "MockObj":
|
||||
obj = MockObj(id_, ".")
|
||||
if type_ is not None:
|
||||
id_.type = type_
|
||||
assignment = AssignmentExpression(id_.type, "", id_, rhs, obj)
|
||||
assignment = AssignmentExpression(id_.type, "", id_, rhs)
|
||||
CORE.add(assignment)
|
||||
CORE.register_variable(id_, obj)
|
||||
return obj
|
||||
@@ -507,7 +506,7 @@ def new_variable(id_: ID, rhs: SafeExpType, type_: "MockObj" = None) -> "MockObj
|
||||
id_.type = type_
|
||||
decl = VariableDeclarationExpression(id_.type, "", id_)
|
||||
CORE.add_global(decl)
|
||||
assignment = AssignmentExpression(None, "", id_, rhs, obj)
|
||||
assignment = AssignmentExpression(None, "", id_, rhs)
|
||||
CORE.add(assignment)
|
||||
CORE.register_variable(id_, obj)
|
||||
return obj
|
||||
@@ -529,7 +528,7 @@ def Pvariable(id_: ID, rhs: SafeExpType, type_: "MockObj" = None) -> "MockObj":
|
||||
id_.type = type_
|
||||
decl = VariableDeclarationExpression(id_.type, "*", id_)
|
||||
CORE.add_global(decl)
|
||||
assignment = AssignmentExpression(None, None, id_, rhs, obj)
|
||||
assignment = AssignmentExpression(None, None, id_, rhs)
|
||||
CORE.add(assignment)
|
||||
CORE.register_variable(id_, obj)
|
||||
return obj
|
||||
|
Reference in New Issue
Block a user