diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2016-02-26 14:48:56 +0100 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2016-02-26 14:48:56 +0100 |
commit | 696ddbd93b4c16f27d78f608bfd5eaf157d2fcf4 (patch) | |
tree | 06bcac9c4dff8e49bdb3f11f0fec680a4347d2f7 /compiler | |
parent | 8a3fd4b12988bad0547f6311c330bf61cc453fd3 (diff) | |
download | Nim-696ddbd93b4c16f27d78f608bfd5eaf157d2fcf4.tar.gz |
PHP codegen generates reliable filenames
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/jsgen.nim | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/compiler/jsgen.nim b/compiler/jsgen.nim index 33a8dc12d..3bbb22745 100644 --- a/compiler/jsgen.nim +++ b/compiler/jsgen.nim @@ -2089,7 +2089,8 @@ proc getClassName(t: PType): Rope = s = skipTypes(t, abstractPtrs).sym if s.isNil or sfAnon in s.flags: internalError("cannot retrieve class name") - result = mangleName(s, targetPHP) + if s.loc.r != nil: result = s.loc.r + else: result = rope(s.name.s) proc genClass(obj: PType; content: Rope; ext: string) = let cls = getClassName(obj) @@ -2100,6 +2101,7 @@ proc genClass(obj: PType; content: Rope; ext: string) = let result = ("<?php$n" & "/* Generated by the Nim Compiler v$# */$n" & "/* (c) 2016 Andreas Rumpf */$n$n" & + "require_once \"nimsystem.php\";$n" & "class $#$# {$n$#$n}$n") % [rope(VersionAsString), cls, extends, content] @@ -2112,13 +2114,15 @@ proc myClose(b: PPassContext, n: PNode): PNode = var m = BModule(b) if sfMainModule in m.module.flags: let ext = if m.target == targetJS: "js" else: "php" + let f = if globals.classes.len == 0: m.module.filename + else: "nimsystem" let code = wholeCode(m) let outfile = if options.outFile.len > 0: if options.outFile.isAbsolute: options.outFile else: getCurrentDir() / options.outFile else: - changeFileExt(completeCFilePath(m.module.filename), ext) + changeFileExt(completeCFilePath(f), ext) discard writeRopeIfNotEqual(genHeader(m.target) & code, outfile) for obj, content in items(globals.classes): genClass(obj, content, ext) |