From d0edb1826b2c49413b6b7b1b9b351a632bd323f9 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Sun, 2 Dec 2012 20:36:29 +0200 Subject: adds an option to interleave the generated code with snippets from the original source Lines from the original source are outputted as comments next to line directives. Hopefully, this will make debugging codegen problems easier. Other changes: The frame setup code now uses a single-line C macro. My motivation was to reduce the noise in the generated output and make it easier to step over the boiler-plate code, but counter-intuitively this also improved the overall compilation speed a little bit so I applied the same treatment to line tracking too (this reduces the size of the generated files and the explanation is that probably the I/O overhead dominates the macro expansion costs). --- compiler/ccgutils.nim | 25 ------------------------- 1 file changed, 25 deletions(-) (limited to 'compiler/ccgutils.nim') diff --git a/compiler/ccgutils.nim b/compiler/ccgutils.nim index 90a1c5d81..90696825b 100755 --- a/compiler/ccgutils.nim +++ b/compiler/ccgutils.nim @@ -154,36 +154,11 @@ proc TableGetType*(tab: TIdTable, key: PType): PObject = if sameType(t, key): return tab.data[h].val -proc toCChar*(c: Char): string = - case c - of '\0'..'\x1F', '\x80'..'\xFF': result = '\\' & toOctal(c) - of '\'', '\"', '\\': result = '\\' & c - else: result = $(c) - proc makeSingleLineCString*(s: string): string = result = "\"" for c in items(s): result.add(c.toCChar) result.add('\"') - -proc makeCString*(s: string): PRope = - # BUGFIX: We have to split long strings into many ropes. Otherwise - # this could trigger an InternalError(). See the ropes module for - # further information. - const - MaxLineLength = 64 - result = nil - var res = "\"" - for i in countup(0, len(s) - 1): - if (i + 1) mod MaxLineLength == 0: - add(res, '\"') - add(res, tnl) - app(result, toRope(res)) # reset: - setlen(res, 1) - res[0] = '\"' - add(res, toCChar(s[i])) - add(res, '\"') - app(result, toRope(res)) proc makeLLVMString*(s: string): PRope = const MaxLineLength = 64 -- cgit 1.4.1-2-gfad0