瀏覽代碼

Finish exploding symbols.

tags/v1.0^2
Ben Kurtovic 10 年之前
父節點
當前提交
d3f6f226f1
共有 2 個文件被更改,包括 9 次插入9 次删除
  1. +6
    -6
      bitshift/database/__init__.py
  2. +3
    -3
      bitshift/query/nodes.py

+ 6
- 6
bitshift/database/__init__.py 查看文件

@@ -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 查看文件

@@ -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…
取消
儲存