Remove PHP backend. (#7606)
* remove php * fix * keep nimphpext * remove targetJS enum
This commit is contained in:
parent
a708fda733
commit
35b0cc67e8
9 changed files with 330 additions and 778 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -121,26 +121,7 @@ proc genEnumInfo(p: PProc, typ: PType, name: Rope) =
|
|||
addf(p.g.typeInfo, "$1.base = $2;$n",
|
||||
[name, genTypeInfo(p, typ.sons[0])])
|
||||
|
||||
proc genEnumInfoPHP(p: PProc; t: PType): Rope =
|
||||
let t = t.skipTypes({tyGenericInst, tyDistinct, tyAlias, tySink})
|
||||
result = "$$NTI$1" % [rope(t.id)]
|
||||
p.declareGlobal(t.id, result)
|
||||
if containsOrIncl(p.g.typeInfoGenerated, t.id): return
|
||||
|
||||
let length = sonsLen(t.n)
|
||||
var s: Rope = nil
|
||||
for i in countup(0, length - 1):
|
||||
if (t.n.sons[i].kind != nkSym): internalError(t.n.info, "genEnumInfo")
|
||||
let field = t.n.sons[i].sym
|
||||
if i > 0: add(s, ", " & tnl)
|
||||
let extName = if field.ast == nil: field.name.s else: field.ast.strVal
|
||||
addf(s, "$# => $#$n",
|
||||
[rope(field.position), makeJSString(extName)])
|
||||
prepend(p.g.typeInfo, "$$$# = $#;$n" % [result, s])
|
||||
|
||||
proc genTypeInfo(p: PProc, typ: PType): Rope =
|
||||
if p.target == targetPHP:
|
||||
return makeJSString(typeToString(typ, preferModuleInfo))
|
||||
let t = typ.skipTypes({tyGenericInst, tyDistinct, tyAlias, tySink})
|
||||
result = "NTI$1" % [rope(t.id)]
|
||||
if containsOrIncl(p.g.typeInfoGenerated, t.id): return
|
||||
|
|
|
|||
|
|
@ -230,7 +230,7 @@ template isIterator*(owner: PSym): bool =
|
|||
proc liftingHarmful(owner: PSym): bool {.inline.} =
|
||||
## lambda lifting can be harmful for JS-like code generators.
|
||||
let isCompileTime = sfCompileTime in owner.flags or owner.kind == skMacro
|
||||
result = gCmd in {cmdCompileToPHP, cmdCompileToJS} and not isCompileTime
|
||||
result = gCmd == cmdCompileToJS and not isCompileTime
|
||||
|
||||
proc liftIterSym*(n: PNode; owner: PSym): PNode =
|
||||
# transforms (iter) to (let env = newClosure[iter](); (iter, env))
|
||||
|
|
@ -813,7 +813,7 @@ proc liftLambdas*(fn: PSym, body: PNode; tooEarly: var bool): PNode =
|
|||
let isCompileTime = sfCompileTime in fn.flags or fn.kind == skMacro
|
||||
|
||||
if body.kind == nkEmpty or (
|
||||
gCmd in {cmdCompileToPHP, cmdCompileToJS} and not isCompileTime) or
|
||||
gCmd == cmdCompileToJS and not isCompileTime) or
|
||||
fn.skipGenericOwner.kind != skModule:
|
||||
# ignore forward declaration:
|
||||
result = body
|
||||
|
|
|
|||
|
|
@ -94,7 +94,6 @@ proc commandCompileToJS(graph: ModuleGraph; cache: IdentCache) =
|
|||
defineSymbol("nimrod") # 'nimrod' is always defined
|
||||
defineSymbol("ecmascript") # For backward compatibility
|
||||
defineSymbol("js")
|
||||
if gCmd == cmdCompileToPHP: defineSymbol("nimphp")
|
||||
semanticPasses()
|
||||
registerPass(JSgenPass)
|
||||
compileProject(graph, cache)
|
||||
|
|
@ -189,9 +188,6 @@ proc mainCommand*(graph: ModuleGraph; cache: IdentCache) =
|
|||
of "js", "compiletojs":
|
||||
gCmd = cmdCompileToJS
|
||||
commandCompileToJS(graph, cache)
|
||||
of "php":
|
||||
gCmd = cmdCompileToPHP
|
||||
commandCompileToJS(graph, cache)
|
||||
of "doc0":
|
||||
wantMainModule()
|
||||
gCmd = cmdDoc
|
||||
|
|
|
|||
|
|
@ -90,14 +90,6 @@ proc handleCmdLine(cache: IdentCache; config: ConfigRef) =
|
|||
ex = quoteShell(
|
||||
completeCFilePath(changeFileExt(gProjectFull, "js").prependCurDir))
|
||||
execExternalProgram(findNodeJs() & " " & ex & ' ' & commands.arguments)
|
||||
elif gCmd == cmdCompileToPHP:
|
||||
var ex: string
|
||||
if options.outFile.len > 0:
|
||||
ex = options.outFile.prependCurDir.quoteShell
|
||||
else:
|
||||
ex = quoteShell(
|
||||
completeCFilePath(changeFileExt(gProjectFull, "php").prependCurDir))
|
||||
execExternalProgram("php " & ex & ' ' & commands.arguments)
|
||||
else:
|
||||
var binPath: string
|
||||
if options.outFile.len > 0:
|
||||
|
|
|
|||
|
|
@ -81,7 +81,6 @@ type
|
|||
# **keep binary compatible**
|
||||
cmdNone, cmdCompileToC, cmdCompileToCpp, cmdCompileToOC,
|
||||
cmdCompileToJS,
|
||||
cmdCompileToPHP,
|
||||
cmdCompileToLLVM, cmdInterpret, cmdPretty, cmdDoc,
|
||||
cmdGenDepend, cmdDump,
|
||||
cmdCheck, # semantic checking for whole project
|
||||
|
|
|
|||
|
|
@ -586,7 +586,7 @@ proc cmdChangeTriggersRecompilation(old, new: TCommands): bool =
|
|||
# new command forces us to consider it here :-)
|
||||
case old
|
||||
of cmdCompileToC, cmdCompileToCpp, cmdCompileToOC,
|
||||
cmdCompileToJS, cmdCompileToPHP, cmdCompileToLLVM:
|
||||
cmdCompileToJS, cmdCompileToLLVM:
|
||||
if new in {cmdDoc, cmdCheck, cmdIdeTools, cmdPretty, cmdDef,
|
||||
cmdInteractive}:
|
||||
return false
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue