def __init__(self, base_expr: Expression = None, true_base_expr: Expression = None): self.display_value = base_expr self.base_expr = (base_expr if (true_base_expr is None) else true_base_expr) self.value = None self.children = [] self.id = get_id() if (logger.op_count >= OP_LIMIT): self.children = fake_obj return if (base_expr is None): return if (isinstance(base_expr, ValueHolder) or isinstance(base_expr, evaluate_apply.Callable) or isinstance(base_expr, Promise) or (base_expr == Nil) or (base_expr == Undefined)): self.value = base_expr elif isinstance(base_expr, Pair): try: self.set_entries(pair_to_list(base_expr)) except OperandDeduceError: self.set_entries([base_expr.first, base_expr.rest]) else: raise NotImplementedError(base_expr, type(base_expr))
def __init__(self, expr: Expression, frame: 'Frame'): super().__init__() self.forced = False self.force_i = None self.expr = expr self.frame = frame self.targets = [] self.id = get_id()
def new_node(self, expr: Union[(Expression, VisualExpression)], transition_type: HolderState): if isinstance(expr, Expression): key = get_id() self.node_cache[key] = StaticNode(expr, transition_type) return key if (expr.id in self.node_cache): return self.node_cache[expr.id].modify(expr, transition_type, force=True) node = FatNode(expr, transition_type) self.node_cache[node.id] = node return node.id
def record(self, expr: Expression) -> 'Heap.HeapKey': if isinstance(expr, evaluate_apply.Thunk): return (False, 'thunk') if (expr.id is None): expr.id = get_id() if ((expr.id not in self.prev) and (expr.id not in self.curr)): if isinstance(expr, ValueHolder): return (False, repr(expr)) elif isinstance(expr, Pair): val = [self.record(expr.first), self.record(expr.rest)] elif isinstance(expr, Promise): val = expr.bind() elif isinstance(expr, NilType): return (False, 'nil') elif isinstance(expr, UndefinedType): return (False, 'undefined') else: val = [(False, repr(expr))] self.curr[expr.id] = val return (True, expr.id)
def record(self, expr: Expression) -> 'Heap.HeapKey': if isinstance(expr, evaluate_apply.Thunk): return False, "thunk" if expr.id is None: expr.id = get_id() if expr.id not in self.prev and expr.id not in self.curr: if isinstance(expr, ValueHolder): return False, repr(expr) elif isinstance(expr, Pair): val = [self.record(expr.first), self.record(expr.rest)] elif isinstance(expr, Promise): val = expr.bind() elif isinstance(expr, NilType): return False, "nil" elif isinstance(expr, UndefinedType): return False, "undefined" else: # assume the repr method is good enough val = [(False, repr(expr))] self.curr[expr.id] = val return True, expr.id
def __init__(self): self.id = get_id()