mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-25 11:46:31 +00:00
Berry coc parser keeps order of variables (#21542)
This commit is contained in:
parent
8c4388bf47
commit
e13c0a7114
@ -11,6 +11,7 @@ All notable changes to this project will be documented in this file.
|
|||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- TCP bridge increased baudrate selection (#21528)
|
- TCP bridge increased baudrate selection (#21528)
|
||||||
|
- Berry coc parser keeps order of variables
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- uDisplay Parallel display on Core3 (#21529)
|
- uDisplay Parallel display on Core3 (#21529)
|
||||||
|
@ -27,6 +27,13 @@ class hash_map:
|
|||||||
self.bucket = []
|
self.bucket = []
|
||||||
|
|
||||||
self.resize(2)
|
self.resize(2)
|
||||||
|
var_count = 0
|
||||||
|
# replace any 'var' by its slot number
|
||||||
|
for (key, value) in map.items():
|
||||||
|
if value == "var":
|
||||||
|
map[key] = var_count
|
||||||
|
var_count += 1
|
||||||
|
|
||||||
for key in sorted(map.keys()):
|
for key in sorted(map.keys()):
|
||||||
self.insert(key, map[key])
|
self.insert(key, map[key])
|
||||||
|
|
||||||
@ -115,27 +122,21 @@ class hash_map:
|
|||||||
# Compute entries in the hash for modules or classes
|
# Compute entries in the hash for modules or classes
|
||||||
#################################################################################
|
#################################################################################
|
||||||
# return a list (entiry, var_count)
|
# return a list (entiry, var_count)
|
||||||
def entry_modify(self, ent, var_count):
|
def entry_modify(self, ent):
|
||||||
ent.key = escape_operator(ent.key)
|
ent.key = escape_operator(ent.key)
|
||||||
if ent.value == "var":
|
if isinstance(ent.value, int):
|
||||||
ent.value = "be_const_var(" + str(var_count) + ")"
|
ent.value = "be_const_var(" + str(ent.value) + ")"
|
||||||
var_count += 1
|
|
||||||
else:
|
else:
|
||||||
ent.value = "be_const_" + ent.value
|
ent.value = "be_const_" + ent.value
|
||||||
return (ent, var_count)
|
return ent
|
||||||
|
|
||||||
# generate the final map
|
# generate the final map
|
||||||
def entry_list(self):
|
def entry_list(self):
|
||||||
l = []
|
l = []
|
||||||
var_count = 0
|
|
||||||
|
|
||||||
self.resize(self.count)
|
self.resize(self.count)
|
||||||
for it in self.bucket:
|
for it in self.bucket:
|
||||||
(ent, var_count) = self.entry_modify(it, var_count)
|
l.append(self.entry_modify(it))
|
||||||
# print(f"ent={ent} var_count={var_count}")
|
|
||||||
# # ex: ent=<entry object; key='arg', value='be_const_func(w_webserver_arg)', next=-1> var_count=0
|
|
||||||
# # ex: ent=<entry object; key='check_privileged_access2', value='be_const_func(w_webserver_check_privileged_access_ntv, "b", "")', next=-1> var_count=0
|
|
||||||
l.append(ent)
|
|
||||||
return l
|
return l
|
||||||
|
|
||||||
def var_count(self):
|
def var_count(self):
|
||||||
@ -143,7 +144,7 @@ class hash_map:
|
|||||||
|
|
||||||
self.resize(self.count)
|
self.resize(self.count)
|
||||||
for it in self.bucket:
|
for it in self.bucket:
|
||||||
if it.value == "var": count += 1
|
if isinstance(it.value, int): count += 1
|
||||||
return count
|
return count
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
x
Reference in New Issue
Block a user