summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'compiler')
-rwxr-xr-xcompiler/jsgen.nim (renamed from compiler/ecmasgen.nim)42
-rw-r--r--compiler/lambdalifting.nim6
-rwxr-xr-xcompiler/main.nim17
-rwxr-xr-xcompiler/nimrod.dot54
-rwxr-xr-xcompiler/nimrod.ini2
-rwxr-xr-xcompiler/nimrod.nim2
-rwxr-xr-xcompiler/options.nim2
-rwxr-xr-xcompiler/platform.nim8
-rwxr-xr-xcompiler/rodread.nim2
9 files changed, 68 insertions, 67 deletions
diff --git a/compiler/ecmasgen.nim b/compiler/jsgen.nim
index a8c62ae09..94b662b48 100755
--- a/compiler/ecmasgen.nim
+++ b/compiler/jsgen.nim
@@ -20,22 +20,22 @@ import
 # implementation
 
 type 
-  TEcmasGen = object of TPassContext
+  TJSGen = object of TPassContext
     module: PSym
 
-  BModule = ref TEcmasGen
-  TEcmasTypeKind = enum       # necessary JS "types"
+  BModule = ref TJSGen
+  TJSTypeKind = enum       # necessary JS "types"
     etyNone,                  # no type
     etyNull,                  # null type
     etyProc,                  # proc type
     etyBool,                  # bool type
-    etyInt,                   # Ecmascript's int
-    etyFloat,                 # Ecmascript's float
-    etyString,                # Ecmascript's string
-    etyObject,                # Ecmascript's reference to an object
+    etyInt,                   # JavaScript's int
+    etyFloat,                 # JavaScript's float
+    etyString,                # JavaScript's string
+    etyObject,                # JavaScript's reference to an object
     etyBaseIndex              # base + index needed
   TCompRes{.final.} = object 
-    kind: TEcmasTypeKind
+    kind: TJSTypeKind
     com: PRope               # computation part
                              # address if this is a (address, index)-tuple
     res: PRope               # result part; index if this is an
@@ -91,7 +91,7 @@ const
   MappedToObject = {tyObject, tyArray, tyArrayConstr, tyTuple, tyOpenArray, 
     tySet, tyVar, tyRef, tyPtr, tyBigNum, tyVarargs}
 
-proc mapType(typ: PType): TEcmasTypeKind = 
+proc mapType(typ: PType): TJSTypeKind = 
   var t = skipTypes(typ, abstractInst)
   case t.kind
   of tyVar, tyRef, tyPtr: 
@@ -605,8 +605,8 @@ proc genCaseStmt(p: var TProc, n: PNode, r: var TCompRes) =
   if cond.com != nil: appf(r.com, "$1;$n", [cond.com])
   stringSwitch = skipTypes(n.sons[0].typ, abstractVar).kind == tyString
   if stringSwitch: 
-    useMagic(p, "toEcmaStr")
-    appf(r.com, "switch (toEcmaStr($1)) {$n", [cond.res])
+    useMagic(p, "toJSStr")
+    appf(r.com, "switch (toJSStr($1)) {$n", [cond.res])
   else: 
     appf(r.com, "switch ($1) {$n", [cond.res])
   for i in countup(1, sonsLen(n) - 1): 
@@ -619,17 +619,17 @@ proc genCaseStmt(p: var TProc, n: PNode, r: var TCompRes) =
           v = copyNode(e.sons[0])
           while (v.intVal <= e.sons[1].intVal): 
             gen(p, v, cond)
-            if cond.com != nil: internalError(v.info, "ecmasgen.genCaseStmt")
+            if cond.com != nil: internalError(v.info, "jsgen.genCaseStmt")
             appf(r.com, "case $1: ", [cond.res])
             Inc(v.intVal)
         else: 
           gen(p, e, cond)
-          if cond.com != nil: internalError(e.info, "ecmasgen.genCaseStmt")
+          if cond.com != nil: internalError(e.info, "jsgen.genCaseStmt")
           if stringSwitch: 
             case e.kind
             of nkStrLit..nkTripleStrLit: appf(r.com, "case $1: ", 
                 [makeJSString(e.strVal)])
-            else: InternalError(e.info, "ecmasgen.genCaseStmt: 2")
+            else: InternalError(e.info, "jsgen.genCaseStmt: 2")
           else: 
             appf(r.com, "case $1: ", [cond.res])
       genStmt(p, lastSon(it), stmt)
@@ -637,7 +637,7 @@ proc genCaseStmt(p: var TProc, n: PNode, r: var TCompRes) =
     of nkElse: 
       genStmt(p, it.sons[0], stmt)
       appf(r.com, "default: $n$1break;$n", [mergeStmt(stmt)])
-    else: internalError(it.info, "ecmasgen.genCaseStmt")
+    else: internalError(it.info, "jsgen.genCaseStmt")
   appf(r.com, "}$n", [])
 
 proc genStmtListExpr(p: var TProc, n: PNode, r: var TCompRes)
@@ -692,7 +692,7 @@ proc genAsmStmt(p: var TProc, n: PNode, r: var TCompRes) =
     case n.sons[i].Kind
     of nkStrLit..nkTripleStrLit: app(r.com, n.sons[i].strVal)
     of nkSym: app(r.com, mangleName(n.sons[i].sym))
-    else: InternalError(n.sons[i].info, "ecmasgen: genAsmStmt()")
+    else: InternalError(n.sons[i].info, "jsgen: genAsmStmt()")
   
 proc genIfStmt(p: var TProc, n: PNode, r: var TCompRes) = 
   var 
@@ -1276,7 +1276,7 @@ proc genMagic(p: var TProc, n: PNode, r: var TCompRes) =
         binaryStmt(p, n, r, "", "$1 += $2")
     else:
       binaryStmt(p, n, r, "", "$1 = ($1.slice(0,-1)).concat($2)")
-    # XXX: make a copy of $2, because of ECMAScript's sucking semantics
+    # XXX: make a copy of $2, because of Javascript's sucking semantics
   of mAppendSeqElem: binaryStmt(p, n, r, "", "$1.push($2)")
   of mConStrStr: genConStrStr(p, n, r)
   of mEqStr: binaryExpr(p, n, r, "eqStrings", "eqStrings($1, $2)")
@@ -1395,8 +1395,8 @@ proc convStrToCStr(p: var TProc, n: PNode, r: var TCompRes) =
   else: 
     gen(p, n.sons[0], r)
     if r.res == nil: InternalError(n.info, "convStrToCStr")
-    useMagic(p, "toEcmaStr")
-    r.res = ropef("toEcmaStr($1)", [r.res])
+    useMagic(p, "toJSStr")
+    r.res = ropef("toJSStr($1)", [r.res])
 
 proc convCStrToStr(p: var TProc, n: PNode, r: var TCompRes) = 
   # we do an optimization here as this is likely to slow down
@@ -1660,10 +1660,10 @@ proc myClose(b: PPassContext, n: PNode): PNode =
     discard writeRopeIfNotEqual(con(genHeader(), code), outfile)
 
 proc myOpenCached(s: PSym, rd: PRodReader): PPassContext = 
-  InternalError("symbol files are not possible with the Ecmas code generator")
+  InternalError("symbol files are not possible with the JS code generator")
   result = nil
 
 proc myOpen(s: PSym): PPassContext = 
   result = newModule(s)
 
-const ecmasgenPass* = makePass(myOpen, myOpenCached, myProcess, myClose)
+const JSgenPass* = makePass(myOpen, myOpenCached, myProcess, myClose)
diff --git a/compiler/lambdalifting.nim b/compiler/lambdalifting.nim
index 0c3eea3be..d85e4afc8 100644
--- a/compiler/lambdalifting.nim
+++ b/compiler/lambdalifting.nim
@@ -322,7 +322,7 @@ proc generateThunk(prc: PNode, dest: PType): PNode =
   
   # we cannot generate a proper thunk here for GC-safety reasons (see internal
   # documentation):
-  if gCmd == cmdCompileToEcmaScript: return prc
+  if gCmd == cmdCompileToJS: return prc
   result = newNodeIT(nkClosure, prc.info, dest)
   var conv = newNodeIT(nkHiddenStdConv, prc.info, dest)
   conv.add(emptyNode)
@@ -543,7 +543,7 @@ proc transformOuterProc(o: POuterContext, n: PNode): PNode =
       if x != nil: n.sons[i] = x
 
 proc liftLambdas*(fn: PSym, body: PNode): PNode =
-  if body.kind == nkEmpty or gCmd == cmdCompileToEcmaScript:
+  if body.kind == nkEmpty or gCmd == cmdCompileToJS:
     # ignore forward declaration:
     result = body
   else:
@@ -566,7 +566,7 @@ proc liftLambdas*(fn: PSym, body: PNode): PNode =
     result = ex
 
 proc liftLambdasForTopLevel*(module: PSym, body: PNode): PNode =
-  if body.kind == nkEmpty or gCmd == cmdCompileToEcmaScript:
+  if body.kind == nkEmpty or gCmd == cmdCompileToJS:
     result = body
   else:
     var o = newOuterContext(module)
diff --git a/compiler/main.nim b/compiler/main.nim
index 41073a591..bb10f0768 100755
--- a/compiler/main.nim
+++ b/compiler/main.nim
@@ -14,7 +14,7 @@ import
   llstream, strutils, ast, astalgo, lexer, syntaxes, renderer, options, msgs, 
   os, lists, condsyms, rodread, rodwrite, ropes, trees, times,
   wordrecg, sem, semdata, idents, passes, docgen, extccomp,
-  cgen, ecmasgen, cgendata,
+  cgen, jsgen, cgendata,
   platform, nimconf, importer, passaux, depends, evals, types, idgen,
   tables, docgen2, service, magicsys, parser, crc, ccgutils
 
@@ -301,14 +301,15 @@ when has_LLVM_Backend:
     #registerPass(cleanupPass())
     compileProject()
 
-proc CommandCompileToEcmaScript =
+proc CommandCompileToJS =
   #incl(gGlobalOptions, optSafeCode)
-  setTarget(osEcmaScript, cpuEcmaScript)
+  setTarget(osJS, cpuJS)
   #initDefines()
   DefineSymbol("nimrod") # 'nimrod' is always defined
-  DefineSymbol("ecmascript")
+  DefineSymbol("ecmascript") # For backward compatibility
+  DefineSymbol("js")
   semanticPasses()
-  registerPass(ecmasgenPass)
+  registerPass(jsgenPass)
   compileProject()
 
 proc InteractivePasses =
@@ -481,10 +482,10 @@ proc MainCommand =
       CommandCompileToC()
     else: 
       rawMessage(errInvalidCommandX, command)
-  of "js", "compiletoecmascript": 
-    gCmd = cmdCompileToEcmaScript
+  of "js", "compiletojs": 
+    gCmd = cmdCompileToJS
     wantMainModule()
-    CommandCompileToEcmaScript()
+    CommandCompileToJS()
   of "compiletollvm": 
     gCmd = cmdCompileToLLVM
     wantMainModule()
diff --git a/compiler/nimrod.dot b/compiler/nimrod.dot
index 36429844f..e9663d7c5 100755
--- a/compiler/nimrod.dot
+++ b/compiler/nimrod.dot
@@ -472,32 +472,32 @@ cgen -> wordrecg;
 cgen -> rnimsyn;
 cgen -> treetab;
 cgen -> cgmeth;
-ecmasgen -> ast;
-ecmasgen -> astalgo;
-ecmasgen -> strutils;
-ecmasgen -> nhashes;
-ecmasgen -> trees;
-ecmasgen -> platform;
-ecmasgen -> magicsys;
-ecmasgen -> extccomp;
-ecmasgen -> options;
-ecmasgen -> nversion;
-ecmasgen -> nimsets;
-ecmasgen -> msgs;
-ecmasgen -> crc;
-ecmasgen -> bitsets;
-ecmasgen -> idents;
-ecmasgen -> lists;
-ecmasgen -> types;
-ecmasgen -> os;
-ecmasgen -> times;
-ecmasgen -> ropes;
-ecmasgen -> math;
-ecmasgen -> passes;
-ecmasgen -> ccgutils;
-ecmasgen -> wordrecg;
-ecmasgen -> rnimsyn;
-ecmasgen -> rodread;
+jsgen -> ast;
+jsgen -> astalgo;
+jsgen -> strutils;
+jsgen -> nhashes;
+jsgen -> trees;
+jsgen -> platform;
+jsgen -> magicsys;
+jsgen -> extccomp;
+jsgen -> options;
+jsgen -> nversion;
+jsgen -> nimsets;
+jsgen -> msgs;
+jsgen -> crc;
+jsgen -> bitsets;
+jsgen -> idents;
+jsgen -> lists;
+jsgen -> types;
+jsgen -> os;
+jsgen -> times;
+jsgen -> ropes;
+jsgen -> math;
+jsgen -> passes;
+jsgen -> ccgutils;
+jsgen -> wordrecg;
+jsgen -> rnimsyn;
+jsgen -> rodread;
 interact -> llstream;
 interact -> strutils;
 interact -> ropes;
@@ -561,7 +561,7 @@ main -> passes;
 main -> docgen;
 main -> extccomp;
 main -> cgen;
-main -> ecmasgen;
+main -> jsgen;
 main -> platform;
 main -> interact;
 main -> nimconf;
diff --git a/compiler/nimrod.ini b/compiler/nimrod.ini
index ea98c743b..74cf534e4 100755
--- a/compiler/nimrod.ini
+++ b/compiler/nimrod.ini
@@ -84,7 +84,7 @@ Files: "lib/wrappers/zip/libzip_all.c"
 
 Files: "lib/windows/*.nim"
 Files: "lib/posix/*.nim"
-Files: "lib/ecmas/*.nim"
+Files: "lib/js/*.nim"
 
 
 [Other]
diff --git a/compiler/nimrod.nim b/compiler/nimrod.nim
index 3666046ea..3fa80cebb 100755
--- a/compiler/nimrod.nim
+++ b/compiler/nimrod.nim
@@ -60,7 +60,7 @@ proc HandleCmdLine() =
         if gCmd == cmdRun:
           tccgen.run()
       if optRun in gGlobalOptions:
-        if gCmd == cmdCompileToEcmaScript:
+        if gCmd == cmdCompileToJS:
           var ex = quoteIfContainsWhite(
             completeCFilePath(changeFileExt(gProjectFull, "js").prependCurDir))
           execExternalProgram("node " & ex & ' ' & service.arguments)
diff --git a/compiler/options.nim b/compiler/options.nim
index d74bc7304..0d9cb6bd6 100755
--- a/compiler/options.nim
+++ b/compiler/options.nim
@@ -68,7 +68,7 @@ type                          # please make sure we have under 32 options
   TCommands* = enum           # Nimrod's commands
                               # **keep binary compatible**
     cmdNone, cmdCompileToC, cmdCompileToCpp, cmdCompileToOC, 
-    cmdCompileToEcmaScript, cmdCompileToLLVM, cmdInterpret, cmdPretty, cmdDoc, 
+    cmdCompileToJS, cmdCompileToLLVM, cmdInterpret, cmdPretty, cmdDoc, 
     cmdGenDepend, cmdDump, 
     cmdCheck,                 # semantic checking for whole project
     cmdParse,                 # parse a single file (for debugging)
diff --git a/compiler/platform.nim b/compiler/platform.nim
index 1e73faa5d..d63fe6636 100755
--- a/compiler/platform.nim
+++ b/compiler/platform.nim
@@ -21,7 +21,7 @@ type
                     # conditionals to condsyms (end of module).
     osNone, osDos, osWindows, osOs2, osLinux, osMorphos, osSkyos, osSolaris, 
     osIrix, osNetbsd, osFreebsd, osOpenbsd, osAix, osPalmos, osQnx, osAmiga, 
-    osAtari, osNetware, osMacos, osMacosx, osHaiku, osEcmaScript, osNimrodVM, 
+    osAtari, osNetware, osMacos, osMacosx, osHaiku, osJS, osNimrodVM, 
     osStandalone
 
 type 
@@ -136,7 +136,7 @@ const
       objExt: ".o", newLine: "\x0A", pathSep: ":", dirSep: "/", 
       scriptExt: ".sh", curDir: ".", exeExt: "", extSep: ".", 
       props: {ospNeedsPIC, ospPosix, ospLacksThreadVars}), 
-     (name: "EcmaScript", parDir: "..", 
+     (name: "JS", parDir: "..", 
       dllFrmt: "lib$1.so", altDirSep: "/", 
       objExt: ".o", newLine: "\x0A", 
       pathSep: ":", dirSep: "/", 
@@ -155,7 +155,7 @@ type
                      # alias conditionals to condsyms (end of module).
     cpuNone, cpuI386, cpuM68k, cpuAlpha, cpuPowerpc, cpuPowerpc64,
     cpuSparc, cpuVm, cpuIa64, cpuAmd64, cpuMips, cpuArm, 
-    cpuEcmaScript, cpuNimrodVM, cpuAVR
+    cpuJS, cpuNimrodVM, cpuAVR
 
 type 
   TEndian* = enum 
@@ -177,7 +177,7 @@ const
     (name: "amd64", intSize: 64, endian: littleEndian, floatSize: 64, bit: 64), 
     (name: "mips", intSize: 32, endian: bigEndian, floatSize: 64, bit: 32), 
     (name: "arm", intSize: 32, endian: littleEndian, floatSize: 64, bit: 32), 
-    (name: "ecmascript", intSize: 32, endian: bigEndian,floatSize: 64,bit: 32), 
+    (name: "js", intSize: 32, endian: bigEndian,floatSize: 64,bit: 32), 
     (name: "nimrodvm", intSize: 32, endian: bigEndian, floatSize: 64, bit: 32),
     (name: "avr", intSize: 16, endian: littleEndian, floatSize: 32, bit: 16)]
 
diff --git a/compiler/rodread.nim b/compiler/rodread.nim
index 5dccee9a7..3db9452c3 100755
--- a/compiler/rodread.nim
+++ b/compiler/rodread.nim
@@ -526,7 +526,7 @@ proc cmdChangeTriggersRecompilation(old, new: TCommands): bool =
   # new command forces us to consider it here :-)
   case old
   of cmdCompileToC, cmdCompileToCpp, cmdCompileToOC,
-      cmdCompileToEcmaScript, cmdCompileToLLVM:
+      cmdCompileToJS, cmdCompileToLLVM:
     if new in {cmdDoc, cmdCheck, cmdIdeTools, cmdPretty, cmdDef,
                cmdInteractive}:
       return false