Browse Source

Finish exploding symbols.

tags/v1.0^2
Ben Kurtovic 10 years ago
parent
commit
d3f6f226f1
2 changed files with 9 additions and 9 deletions
  1. +6
    -6
      bitshift/database/__init__.py
  2. +3
    -3
      bitshift/query/nodes.py

+ 6
- 6
bitshift/database/__init__.py View File

@@ -74,12 +74,12 @@ class Database(object):
return "(" + column + " " + op + " ?)", [node.date]
elif isinstance(node, Symbol):
tables |= {"symbols"}
if node.type == node.ALL:
# OR all of the types of symbol_types
pass
else:
cond = "(symbol_type = ? AND symbol_name = ?)"
return cond, [node.type, node.name]
cond_base = "(symbol_type = ? AND symbol_name = ?)"
if node.type != node.ALL:
return cond_base, [node.type, node.name]
cond = "(" + " OR ".join([cond_base] * len(node.TYPES)) + ")"
args = zip(node.TYPES.keys(), [node.name] * len(node.TYPES))
return cond, [arg for tup in args for arg in tup]
elif isinstance(node, BinaryOp):
left_cond, left_args = _parse_node(node.left)
right_cond, right_args = _parse_node(node.right)


+ 3
- 3
bitshift/query/nodes.py View File

@@ -154,6 +154,8 @@ class Symbol(_Node):
FUNCTION = 1
CLASS = 2
VARIABLE = 3
TYPES = {ALL: "ALL", FUNCTION: "FUNCTION", CLASS: "CLASS",
VARIABLE: "VARIABLE"}

def __init__(self, type_, name):
"""
@@ -164,9 +166,7 @@ class Symbol(_Node):
self.name = name

def __repr__(self):
types = {self.ALL: "ALL", self.FUNCTION: "FUNCTION",
self.CLASS: "CLASS", self.VARIABLE: "VARIABLE"}
return "Symbol({0}, {1})".format(types[self.type], self.name)
return "Symbol({0}, {1})".format(self.TYPES[self.type], self.name)

def sortkey(self):
return self.name.sortkey()


Loading…
Cancel
Save