Пример #1
0
 def f(i):
     interp = InterpreterState(codes[i])
     interp.run(space)
     if not len(interp.results):
         raise Exception("need results")
     w_res = interp.results[-1]
     if isinstance(w_res, W_NDimArray):
         i, s = w_res.create_iter()
         w_res = i.getitem(s)
     if isinstance(w_res, boxes.W_Float64Box):
         return w_res.value
     if isinstance(w_res, boxes.W_Float32Box):
         return float(w_res.value)
     elif isinstance(w_res, boxes.W_Int64Box):
         return float(w_res.value)
     elif isinstance(w_res, boxes.W_Int32Box):
         return float(int(w_res.value))
     elif isinstance(w_res, boxes.W_Int16Box):
         return float(int(w_res.value))
     elif isinstance(w_res, boxes.W_Int8Box):
         return float(int(w_res.value))
     elif isinstance(w_res, boxes.W_UInt64Box):
         return float(intmask(w_res.value))
     elif isinstance(w_res, boxes.W_UInt32Box):
         return float(intmask(w_res.value))
     elif isinstance(w_res, boxes.W_UInt16Box):
         return float(intmask(w_res.value))
     elif isinstance(w_res, boxes.W_UInt8Box):
         return float(intmask(w_res.value))
     elif isinstance(w_res, boxes.W_LongBox):
         return float(w_res.value)
     elif isinstance(w_res, boxes.W_BoolBox):
         return float(w_res.value)
     print "ERROR: did not implement return type for interpreter"
     raise TypeError(w_res)
Пример #2
0
 def f(i):
     interp = InterpreterState(codes[i])
     interp.run(space)
     if not len(interp.results):
         raise Exception("need results")
     w_res = interp.results[-1]
     if isinstance(w_res, W_NDimArray):
         i, s = w_res.create_iter()
         w_res = i.getitem(s)
     if isinstance(w_res, boxes.W_Float64Box):
         return w_res.value
     if isinstance(w_res, boxes.W_Float32Box):
         return float(w_res.value)
     elif isinstance(w_res, boxes.W_Int64Box):
         return float(w_res.value)
     elif isinstance(w_res, boxes.W_Int32Box):
         return float(int(w_res.value))
     elif isinstance(w_res, boxes.W_Int16Box):
         return float(int(w_res.value))
     elif isinstance(w_res, boxes.W_Int8Box):
         return float(int(w_res.value))
     elif isinstance(w_res, boxes.W_UInt64Box):
         return float(intmask(w_res.value))
     elif isinstance(w_res, boxes.W_UInt32Box):
         return float(intmask(w_res.value))
     elif isinstance(w_res, boxes.W_UInt16Box):
         return float(intmask(w_res.value))
     elif isinstance(w_res, boxes.W_UInt8Box):
         return float(intmask(w_res.value))
     elif isinstance(w_res, boxes.W_LongBox):
         return float(w_res.value)
     elif isinstance(w_res, boxes.W_BoolBox):
         return float(w_res.value)
     print "ERROR: did not implement return type for interpreter"
     raise TypeError(w_res)
Пример #3
0
 def f(i):
     interp = InterpreterState(codes[i])
     interp.run(space)
     res = interp.results[-1]
     w_res = res.eval(res.start_iter()).wrap(interp.space)
     if isinstance(w_res, BoolObject):
         return float(w_res.boolval)
     elif isinstance(w_res, FloatObject):
         return w_res.floatval
     elif isinstance(w_res, IntObject):
         return w_res.intval
     else:
         return -42.
Пример #4
0
 def f(i):
     interp = InterpreterState(codes[i])
     interp.run(space)
     if not len(interp.results):
         raise Exception("need results")
     w_res = interp.results[-1]
     if isinstance(w_res, W_NDimArray):
         w_res = w_res.create_iter().getitem()
     if isinstance(w_res, interp_boxes.W_Float64Box):
         return w_res.value
     if isinstance(w_res, interp_boxes.W_Int64Box):
         return float(w_res.value)
     elif isinstance(w_res, interp_boxes.W_BoolBox):
         return float(w_res.value)
     raise TypeError(w_res)
Пример #5
0
 def f(i):
     interp = InterpreterState(codes[i])
     interp.run(space)
     if not len(interp.results):
         raise Exception("need results")
     w_res = interp.results[-1]
     if isinstance(w_res, W_NDimArray):
         i, s = w_res.create_iter()
         w_res = i.getitem(s)
     if isinstance(w_res, boxes.W_Float64Box):
         return w_res.value
     elif isinstance(w_res, boxes.W_Int64Box):
         return float(w_res.value)
     elif isinstance(w_res, boxes.W_LongBox):
         return float(w_res.value)
     elif isinstance(w_res, boxes.W_BoolBox):
         return float(w_res.value)
     raise TypeError(w_res)
Пример #6
0
 def f(i):
     interp = InterpreterState(codes[i])
     interp.run(space)
     if not len(interp.results):
         raise Exception("need results")
     w_res = interp.results[-1]
     if isinstance(w_res, BaseArray):
         concr = w_res.get_concrete_or_scalar()
         sig = concr.find_sig()
         frame = sig.create_frame(concr)
         w_res = sig.eval(frame, concr)
     if isinstance(w_res, interp_boxes.W_Float64Box):
         return w_res.value
     if isinstance(w_res, interp_boxes.W_Int64Box):
         return float(w_res.value)
     elif isinstance(w_res, interp_boxes.W_BoolBox):
         return float(w_res.value)
     raise TypeError(w_res)