def assign(self, varname: Symbol, varval: Expression):
     if log.logger.fragile and not self.temp:
         raise IrreversibleOperationError()
     if isinstance(varval, Thunk):
         assert varname == log.return_symbol
         varval.bind(self)
         return
     self.vars[varname.value] = varval
     log.logger.frame_store(self, varname.value, varval)
def apply(operator: Expression, operands: List[Expression], frame: Frame, gui_holder: log.Holder):
    if isinstance(operator, Callable):
        return operator.execute(operands, frame, gui_holder)
    elif isinstance(operator, Symbol):
        raise CallableResolutionError(f"Unable to pass parameters into the Symbol '{operator}'")
    else:
        raise CallableResolutionError(f"Unable to pass parameters into: '{operator}'")
Пример #3
0
 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)
Пример #4
0
 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
Пример #5
0
def apply(operator: Expression, operands: List[Expression], frame: Frame,
          gui_holder: log.Holder):
    if isinstance(operator, Callable):
        return operator.execute(operands, frame, gui_holder)
    elif isinstance(operator, Symbol):
        raise CallableResolutionError(''.join([
            "Unable to pass parameters into the Symbol '",
            '{}'.format(operator), "'"
        ]))
    else:
        raise CallableResolutionError(''.join(
            ["Unable to pass parameters into: '", '{}'.format(operator), "'"]))