return repr(self.refValue)
+class StringMatcher(Matcher):
+
+ def __init__(self, refValue):
+ self.refValue = refValue
+
+ def isShaderDisassembly(self, value):
+ return value.find('// Generated by Microsoft (R) D3D Shader Disassembler\n') != -1
+
+ def normalizeShaderDisassembly(self, value):
+ # Unfortunately slightly different disassemblers produce different output
+ return '\n'.join([line.strip() for line in value.split('\n') if line.strip() and not line.startswith('//')])
+
+ def match(self, value, mo):
+ if self.isShaderDisassembly(self.refValue) and self.isShaderDisassembly(value):
+ return self.normalizeShaderDisassembly(self.refValue) == self.normalizeShaderDisassembly(value)
+ return self.refValue == value
+
+ def __str__(self):
+ return repr(self.refValue)
+
+
class BitmaskMatcher(Matcher):
def __init__(self, refElements):
self.col = ((self.col - 1)//self.tabsize + 1)*self.tabsize + 1
pos = tabpos + 1
self.col += len(text) - pos
+
+ def filter(self, type, text):
+ return type, text
class Parser:
if type == STRING:
text = text[1:-1]
- # line continuations
- text = text.replace('\\\r\n', '')
- text = text.replace('\\\r', '')
- text = text.replace('\\\n', '')
-
# quotes
text = text.replace('\\"', '"')
- type = ID
-
return type, text
return ApproxMatcher(value)
def handleString(self, value):
- return LiteralMatcher(value)
+ return StringMatcher(value)
def handleBitmask(self, value):
return BitmaskMatcher(value)