Ticket #32: tracePrintSuppress.patch
File tracePrintSuppress.patch, 7.9 KB (added by hopscc, 16 years ago) |
---|
-
Source/CommandLine.cobra
147 147 'description': 'Includes unit tests for classes and members in the output assembly.', 148 148 }, 149 149 { 150 'name': 'include-traces', 151 'type': 'bool', 152 'default': 'yes', 153 'description': 'Includes tracing code in the output assembly.', 154 }, 155 { 150 156 'name': 'keep-intermediate-files', 151 157 'synonyms': ['kif'], 152 158 'type': 'bool', … … 595 601 options['include-asserts'] = false 596 602 options['include-nil-checks'] = false 597 603 options['include-tests'] = false 604 options['include-traces'] = false 598 605 options['optimize'] = true 599 606 600 607 def interpretValue(valueStr as String, spec as Dictionary<of String, Object>) as dynamic? -
Source/CobraLang.cobra
92 92 _dest.writeLine(source.oneLiner(.separator, .willOutputDirectoryNames)) 93 93 if .willAutoFlush 94 94 _dest.flush 95 95 96 def tracePrint(source as SourceSite, nameValues as vari Object) 97 require nameValues.length % 2 == 0 98 if .isActive 99 _dest.write(.prefix) 100 sep = ' ' # .separator 101 i = 0 102 while i < nameValues.length-1 103 name = nameValues[i] to String 104 if nameValues[i+1] inherits String # emit strings as is 105 value = nameValues[i+1] 106 _dest.write('[value][sep]') 107 else 108 value = CobraImp._techStringMaker.makeString(nameValues[i+1]) 109 _dest.write('[name]=[value][sep]') 110 i += 2 111 _dest.writeLine 112 if .willAutoFlush 113 _dest.flush 114 96 115 class Visitor 97 116 is abstract 98 117 """ -
Source/CobraParser.cobra
1990 1990 on 'EOL' 1991 1991 .expect('EOL') 1992 1992 return if(_isTraceOn, TraceLocationStmt(token, _curCodePart), nil) 1993 on 'PRINT' 1994 .expect('PRINT', 'EOL') 1995 if _isTraceOn 1996 return TracePrintExprsStmt(token, _curCodePart, .commaSepExprs('EOL')) 1997 else 1998 .commaSepExprs('EOL') 1999 return nil 1993 2000 else 1994 2001 if _isTraceOn 1995 2002 return TraceExprsStmt(token, _curCodePart, .commaSepExprs('EOL')) -
Source/Statements.cobra
1220 1220 def init(token as IToken, codePart as AbstractMethod) 1221 1221 base.init(token) 1222 1222 _codePart = codePart 1223 1224 def includeTraces as bool 1225 return .compiler.options.boolValue('include-traces') 1223 1226 1224 1225 1227 class TraceLocationStmt 1226 1228 inherits TraceStmt 1227 1229 … … 1230 1232 1231 1233 def writeSharpDef(sw as SharpWriter) 1232 1234 base.writeSharpDef(sw) 1233 sw.write('CobraCore.Tracer.Trace([.sharpSourceSite]);\n') 1235 if .includeTraces 1236 sw.write('CobraCore.Tracer.Trace([.sharpSourceSite]);\n') 1234 1237 1235 1238 1236 1239 class TraceAllStmt … … 1241 1244 1242 1245 def writeSharpDef(sw as SharpWriter) 1243 1246 base.writeSharpDef(sw) 1247 if not .includeTraces 1248 return 1244 1249 sw.write('CobraCore.Tracer.Trace([.sharpSourceSite], "this", [_codePart.sharpThis]') 1245 1250 for param in _codePart.params 1246 1251 sw.write(', "[param.name]", [param.sharpName]') … … 1268 1273 1269 1274 def writeSharpDef(sw as SharpWriter) 1270 1275 base.writeSharpDef(sw) 1276 if not .includeTraces 1277 return 1271 1278 sw.write('CobraCore.Tracer.Trace([.sharpSourceSite]') 1272 1279 sep = ', ' 1273 1280 for expr in _exprs 1274 1281 sw.write('[sep][Utils.sharpStringLiteralFor(expr.toCobraSource)][sep]') 1275 1282 expr.writeSharpDef(sw, false) 1276 1283 sw.write(');\n') 1284 1277 1285 1286 class TracePrintExprsStmt 1287 inherits TraceExprsStmt 1278 1288 1289 def init(token as IToken, codePart as AbstractMethod, exprs as List<of Expr>) 1290 base.init(token, codePart, exprs) 1291 1292 def writeSharpDef(sw as SharpWriter) is override 1293 if not .includeTraces 1294 return 1295 sw.write('CobraCore.Tracer.TracePrint([.sharpSourceSite]') 1296 sep = ', ' 1297 for expr in _exprs 1298 sw.write('[sep][Utils.sharpStringLiteralFor(expr.toCobraSource)][sep]') 1299 expr.writeSharpDef(sw, false) 1300 sw.write(');\n') 1301 1302 1279 1303 class TryStmt 1280 1304 inherits Stmt 1281 1305 -
Tests/700-command-line/602-turbo.cobra
4 4 5 5 def main is shared 6 6 assert false 7 trace 8 x=1 9 trace all 10 trace x -
Tests/700-command-line/601-include-traces.cobra
1 # .args. -include-traces:no 2 3 class Program 4 5 def main is shared 6 x=1 7 trace 8 trace all 9 trace x 10 trace off 11 trace 'hello' 12 trace on 13 trace print 'hello2' -
Tests/110-basics-two/900-trace.cobra
27 27 trace 28 28 trace on 29 29 trace 30 30 trace print x 31 trace print x,y 32 trace print 'x is [x]', y 33 31 34 output = tracer.destination.toString.replace('\r', '') 32 35 lines = output.split(c'\n') 33 36 .check(lines[0], 'prefix: at FILE:15 | in Test.testTrace') … … 39 42 .check(lines[6], 'prefix: i=3 | at FILE:23 | in Test.testTrace') 40 43 .check(lines[7], 'prefix: this=Test | x=2 | y=2 | tracer=Cobra.Lang.Tracer | i=3 | output=nil | lines=nil | at FILE:24 | in Test.testTrace') 41 44 .check(lines[8], 'prefix: at FILE:29 | in Test.testTrace') 45 .check(lines[9], 'prefix: x=2 ') 46 .check(lines[10],'prefix: x=2 y=2 ') 47 .check(lines[11],'prefix: x is 2 y=2 ') 42 48 43 49 def check(actual as String, expected as String) is shared 44 50 if CobraCore.isRunningOnMono 45 51 expected = expected.replace('RuntimeType', 'MonoType') 46 52 # fix filename in actual 47 53 i = actual.indexOf(' at ') 48 i += 4 49 j = actual.indexOf(':', i) 50 actual = actual[:i] + 'FILE' + actual[j:] 54 if i >= 0 55 i += 4 56 j = actual.indexOf(':', i) 57 actual = actual[:i] + 'FILE' + actual[j:] 51 58 52 59 assert actual == expected 53 60 … … 56 63 CobraCore.tracer.destination = StringWriter() 57 64 trace 58 65 output = CobraCore.tracer.destination.toString.trim 59 .check(output, 'prefix: at FILE: 57| in Test.testStaticTrace')66 .check(output, 'prefix: at FILE:64 | in Test.testStaticTrace') 60 67 61 68 # trace all in a shared method 62 69 CobraCore.tracer.destination = StringWriter() 63 70 output = 'o' 64 71 trace all 65 72 output = CobraCore.tracer.destination.toString.trim 66 .check(output, "prefix: this=Test (RuntimeType) | output='o' | at FILE: 64| in Test.testStaticTrace")73 .check(output, "prefix: this=Test (RuntimeType) | output='o' | at FILE:71 | in Test.testStaticTrace") -
Developer/IntermediateReleaseNotes.text
1 1 Post 0.8 2 2 3 * Add trace form trace print, emits trace lines without position info and 4 strings are emitted as is ( no name=value form). 5 Add compile option -include-traces default value yes to allow compile time 6 suppression of any trace code. 7 3 8 * Added a new built-in doc tool accessible via "cobra -doc ...". The documentation is generated to local HTML files using your declarations, doc strings, contracts, etc. 4 9 5 10 * Add support for specifying unsigned integers as Hex literals