2021-01-09 16:28:59 +01:00
|
|
|
_lanes = {}
|
|
|
|
_stacks = {}
|
2021-01-11 20:50:07 +01:00
|
|
|
_aliases = {}
|
2021-01-09 16:28:59 +01:00
|
|
|
_last_name = {}
|
|
|
|
|
2021-01-11 20:50:07 +01:00
|
|
|
|
2021-01-11 01:37:08 +01:00
|
|
|
_block_type(block_type)
|
|
|
|
|
2021-01-09 16:28:59 +01:00
|
|
|
if block_type == null
|
|
|
|
block_type = called-from[1]
|
2021-01-11 01:37:08 +01:00
|
|
|
return block_type
|
|
|
|
|
|
|
|
_reset_last_name(block_type=null)
|
|
|
|
block_type = _block_type(block_type)
|
2021-01-09 16:28:59 +01:00
|
|
|
|
|
|
|
if block_type in _last_name
|
|
|
|
remove(_last_name, block_type)
|
|
|
|
|
|
|
|
|
|
|
|
_set_last_name(name, block_type=null)
|
2021-01-11 01:37:08 +01:00
|
|
|
block_type = _block_type(block_type)
|
2021-01-09 16:28:59 +01:00
|
|
|
|
|
|
|
_last_name[block_type] = name
|
|
|
|
|
|
|
|
_get_last_name(block_type)
|
2021-01-11 01:37:08 +01:00
|
|
|
block_type = _block_type(block_type)
|
2021-01-09 16:28:59 +01:00
|
|
|
|
|
|
|
if block_type in _last_name
|
|
|
|
return _last_name[block_type]
|
|
|
|
else
|
|
|
|
return null
|
|
|
|
|
|
|
|
|
|
|
|
_push_onto_stack(block, block_type=null)
|
2021-01-11 01:37:08 +01:00
|
|
|
block_type = _block_type(block_type)
|
2021-01-09 16:28:59 +01:00
|
|
|
|
|
|
|
if block_type in _stacks
|
|
|
|
stack = _stacks[block_type]
|
|
|
|
else
|
|
|
|
stack = ()
|
|
|
|
|
|
|
|
push(stack, block)
|
|
|
|
_stacks[block_type] = stack
|
|
|
|
|
|
|
|
_pop_from_stack(block_type=null)
|
2021-01-11 01:37:08 +01:00
|
|
|
block_type = _block_type(block_type)
|
2021-01-09 16:28:59 +01:00
|
|
|
|
|
|
|
if block_type in _stacks
|
|
|
|
stack = _stacks[block_type]
|
|
|
|
b = pop(stack)
|
|
|
|
if length(stack) > 0
|
|
|
|
_stacks[block_type]
|
|
|
|
else
|
|
|
|
remove(_stacks, block_type)
|
|
|
|
return b
|
|
|
|
return null
|
|
|
|
|
|
|
|
_pop_stack(block_type=null)
|
2021-01-11 01:37:08 +01:00
|
|
|
block_type = _block_type(block_type)
|
2021-01-09 16:28:59 +01:00
|
|
|
|
|
|
|
if block_type in _stacks
|
|
|
|
stack = _stacks[block_type]
|
|
|
|
remove(_stacks, block_type)
|
|
|
|
return stack
|
|
|
|
else
|
|
|
|
return ()
|
2021-01-11 01:37:08 +01:00
|
|
|
|
|
|
|
_last_element_of_stack(block_type=null)
|
|
|
|
block_type = _block_type(block_type)
|
|
|
|
|
|
|
|
if block_type in _stacks
|
|
|
|
stack = _stacks[block_type]
|
|
|
|
return stack[-1]
|
|
|
|
else
|
|
|
|
return null
|
2021-01-09 16:28:59 +01:00
|
|
|
|
2021-01-11 01:37:08 +01:00
|
|
|
_set_lane(lane_name, value, block_type=null)
|
|
|
|
block_type = _block_type(block_type)
|
2021-01-10 15:27:00 +01:00
|
|
|
|
|
|
|
if block_type in _lanes
|
|
|
|
lane = _lanes[block_type]
|
|
|
|
else
|
|
|
|
lane = {}
|
|
|
|
|
2021-01-11 01:37:08 +01:00
|
|
|
if lane_name in lane
|
|
|
|
stack = lane[lane_name]
|
2021-01-10 15:27:00 +01:00
|
|
|
else
|
|
|
|
stack = ()
|
|
|
|
|
|
|
|
push(stack, value)
|
2021-01-11 01:37:08 +01:00
|
|
|
lane[lane_name] = stack
|
2021-01-10 15:27:00 +01:00
|
|
|
_lanes[block_type] = lane
|
2021-01-11 01:37:08 +01:00
|
|
|
|
|
|
|
_get_lane(block_type)
|
|
|
|
block_type = _block_type(block_type)
|
|
|
|
|
|
|
|
if block_type in _lanes
|
|
|
|
return _lanes[block_type]
|
|
|
|
else
|
|
|
|
return {}
|
|
|
|
|
2021-01-09 16:28:59 +01:00
|
|
|
|
|
|
|
_put_into_lane(key, value, block_type=null)
|
2021-01-11 01:37:08 +01:00
|
|
|
block_type = _block_type(block_type)
|
2021-01-09 16:28:59 +01:00
|
|
|
|
|
|
|
if block_type in _lanes
|
|
|
|
lane = _lanes[block_type]
|
|
|
|
else
|
|
|
|
lane = {}
|
|
|
|
|
|
|
|
lane[key] = value
|
|
|
|
_lanes[block_type] = lane
|
|
|
|
|
|
|
|
_pop_lane(block_type=null)
|
2021-01-11 01:37:08 +01:00
|
|
|
block_type = _block_type(block_type)
|
2021-01-09 16:28:59 +01:00
|
|
|
|
|
|
|
if block_type in _lanes
|
|
|
|
lane = _lanes[block_type]
|
|
|
|
remove(_lanes, block_type)
|
|
|
|
return lane
|
|
|
|
else
|
|
|
|
return {}
|
2021-01-11 20:50:07 +01:00
|
|
|
|
|
|
|
_set_alias(name, alias, block_type=null)
|
|
|
|
block_type = _block_type(block_type)
|
|
|
|
|
|
|
|
if block_type in _aliases
|
|
|
|
alias_map = _aliases[block_type]
|
|
|
|
else
|
|
|
|
alias_map = {}
|
|
|
|
|
|
|
|
alias_map[name] = alias
|
|
|
|
_aliases[block_type] = alias_map
|
|
|
|
|
|
|
|
_get_alias(name, block_type=null)
|
|
|
|
block_type = _block_type(block_type)
|
|
|
|
|
|
|
|
if block_type in _aliases
|
|
|
|
alias_map = _aliases[block_type]
|
|
|
|
if name in alias_map
|
|
|
|
return alias_map[name]
|
|
|
|
else
|
|
|
|
return name
|
|
|
|
else
|
|
|
|
return name
|
|
|
|
|
|
|
|
_reset_aliases()
|
|
|
|
for key in keys(_aliases)
|
|
|
|
remove(_aliases, key)
|