diff options
author | Zahary Karadjov <zahary@gmail.com> | 2012-12-02 20:36:29 +0200 |
---|---|---|
committer | Zahary Karadjov <zahary@gmail.com> | 2012-12-02 20:36:29 +0200 |
commit | d0edb1826b2c49413b6b7b1b9b351a632bd323f9 (patch) | |
tree | 279c27a24b89e093338910515d5f9b8223432e61 /compiler/ccgutils.nim | |
parent | e9e22ccb2adfe1a44e998405b2dfed9b46ddcb95 (diff) | |
download | Nim-d0edb1826b2c49413b6b7b1b9b351a632bd323f9.tar.gz |
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).
Diffstat (limited to 'compiler/ccgutils.nim')
-rwxr-xr-x | compiler/ccgutils.nim | 25 |
1 files changed, 0 insertions, 25 deletions
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 |