OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
generate_loop_ref Namespace Reference

Functions

def generate
 

Variables

list upper_bounds = [5, 3, 9]
 
tuple mask_bitcount = bin(mask)
 
tuple loops = generate(mask, cond_mask, upper_bounds)
 

Function Documentation

def generate_loop_ref.generate (   mask,
  cond_mask,
  upper_bounds 
)

Definition at line 1 of file generate_loop_ref.py.

References join().

Referenced by ExtractExpr.generate(), and DateTruncExpr.generate().

1 def generate(mask, cond_mask, upper_bounds):
2  indent_level = 0
3  start_iterator_ch = 'i'
4  cond_idx = 0
5  iterators = []
6  loops = ''
7  for i in xrange(0, len(upper_bounds)):
8  if mask & (1 << i):
9  cond_is_true = (cond_mask & (1 << cond_idx)) != 0
10  slot_lookup_result = 99 if cond_is_true else -1
11  if_cond = indent_level * ' ' + 'if %d >= 0:' % slot_lookup_result
12  cond_idx += 1
13  iterators.append(slot_lookup_result)
14  loops += if_cond + '\n'
15  else:
16  iterator_ch = chr(ord(start_iterator_ch) + i)
17  for_loop = (indent_level * ' ' + 'for %s in xrange(0, %d):' %
18  (iterator_ch, upper_bounds[i]))
19  iterators.append(iterator_ch)
20  loops += for_loop + '\n'
21  indent_level += 1
22  loops += (indent_level * ' ' + "print('" + ', '.join(['%s' for iterator in iterators])
23  + "' % (" + ', '.join([str(iterator) for iterator in iterators]) + '))')
24  return loops
25 
std::string join(T const &container, std::string const &delim)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

tuple generate_loop_ref.loops = generate(mask, cond_mask, upper_bounds)

Definition at line 31 of file generate_loop_ref.py.

tuple generate_loop_ref.mask_bitcount = bin(mask)

Definition at line 29 of file generate_loop_ref.py.

Referenced by main().

list generate_loop_ref.upper_bounds = [5, 3, 9]

Definition at line 27 of file generate_loop_ref.py.

Referenced by main().