def eval(self, context): # for for(var exp1, cond, exp2) if self.declarations is not None: for declaration in self.declarations: declaration.eval(context) # for for(exp1, cond, exp2) if self.start_expression is not None: ref = self.start_expression.eval(context) js.get_value(ref) result_value = js.EMPTY while True: if self.condition is not None: condition_value = js.get_value(self.condition.eval(context)) if not condition_value: return js.Completion(js.NORMAL, result_value, js.EMPTY) stmt = self.statement.eval(context) if stmt.value is not js.EMPTY: result_value = stmt.value if stmt.type is js.BREAK: return js.Completion(js.NORMAL, result_value, js.EMPTY) if js.is_abrupt(stmt) and stmt.type is not js.CONTINUE: return stmt if self.count_expression is not None: count_expression_ref = self.count_expression.eval(context) js.get_value(count_expression_ref)
def eval(self, context): result = js.EMPTY_COMPLETION for statement in self.statements: partial_result = statement.eval(context) if js.is_abrupt(partial_result): return partial_result # Ignore empty statement values, as specified in [ECMA-262 12.1] if partial_result.value is not js.EMPTY: result = partial_result return result
def eval(self, context): result_value = js.EMPTY while True: condition_value = js.get_value(self.condition.eval(context)) if not condition_value: return js.Completion(js.NORMAL, result_value, js.EMPTY) stmt = self.statement.eval(context) if stmt.value is not js.EMPTY: result_value = stmt.value if stmt.type is js.BREAK: return js.Completion(js.NORMAL, result_value, js.EMPTY) elif js.is_abrupt(stmt) and stmt.type is not js.CONTINUE: return stmt
def eval(self, context): cntx = js.ExecutionContext(dict(), parent=context) result_value = js.EMPTY firstst = self.first.eval(cntx) while True: condition_value = js.get_value(self.condition.eval(cntx)) #print("COND",condition_value) if not condition_value: return js.Completion(js.NORMAL, result_value, js.EMPTY) stmt = self.statement.eval(cntx) if stmt.value is not js.EMPTY: result_value = stmt.value if stmt.type is js.BREAK: return js.Completion(js.NORMAL, result_value, js.EMPTY) elif js.is_abrupt(stmt) and stmt.type is not js.CONTINUE: return stmt nextst = self.then.eval(cntx)