Пример #1
0
 def eval(self, env: Env.Values) -> V.Array:
     ""
     assert isinstance(self.type, T.Array)
     return V.Array(self.type, [
         item.eval(env).coerce(self.type.item_type) for item in self.items
     ])
Пример #2
0
 def _call_eager(self, expr: E.Apply, arguments: List[V.Base]) -> V.Base:
     arg0 = arguments[0]
     assert isinstance(arg0, V.Int)
     if arg0.value < 0:
         raise Error.EvalError(expr, "range() got negative argument")
     return V.Array(T.Array(T.Int()), [V.Int(x) for x in range(arg0.value)])
Пример #3
0
 def _call_eager(self, expr: E.Apply, arguments: List[V.Base]) -> V.Base:
     pfx = arguments[0].coerce(T.String()).value
     return V.Array(
         T.Array(T.String()),
         [V.String(pfx + s.coerce(T.String()).value) for s in arguments[1].value],
     )
Пример #4
0
 def _call_eager(self, expr: E.Apply, arguments: List[V.Base]) -> V.Base:
     arr = arguments[0]
     assert isinstance(arr, V.Array)
     arrty = arr.type
     assert isinstance(arrty, T.Array)
     return V.Array(arrty, [arg for arg in arr.value if not isinstance(arg, V.Null)])