diff options
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/astalgo.nim | 4 | ||||
-rw-r--r-- | compiler/canonicalizer.nim | 4 | ||||
-rw-r--r-- | compiler/ccgthreadvars.nim | 2 | ||||
-rw-r--r-- | compiler/ccgtypes.nim | 4 | ||||
-rw-r--r-- | compiler/idgen.nim | 2 | ||||
-rw-r--r-- | compiler/jsgen.nim | 31 | ||||
-rw-r--r-- | compiler/options.nim | 4 | ||||
-rw-r--r-- | compiler/platform.nim | 2 |
8 files changed, 38 insertions, 15 deletions
diff --git a/compiler/astalgo.nim b/compiler/astalgo.nim index 3ba43b4c5..1a70875d4 100644 --- a/compiler/astalgo.nim +++ b/compiler/astalgo.nim @@ -137,7 +137,7 @@ proc sameValue*(a, b: PNode): bool = of nkStrLit..nkTripleStrLit: if b.kind in {nkStrLit..nkTripleStrLit}: result = a.strVal == b.strVal else: - # don't raise an internal error for 'nimrod check': + # don't raise an internal error for 'nim check': #InternalError(a.info, "SameValue") discard @@ -152,7 +152,7 @@ proc leValue*(a, b: PNode): bool = of nkStrLit..nkTripleStrLit: if b.kind in {nkStrLit..nkTripleStrLit}: result = a.strVal <= b.strVal else: - # don't raise an internal error for 'nimrod check': + # don't raise an internal error for 'nim check': #InternalError(a.info, "leValue") discard diff --git a/compiler/canonicalizer.nim b/compiler/canonicalizer.nim index dc6445035..9afe4ab10 100644 --- a/compiler/canonicalizer.nim +++ b/compiler/canonicalizer.nim @@ -11,7 +11,7 @@ import strutils, db_sqlite, md5 -var db: TDbConn +var db: DbConn # We *hash* the relevant information into 128 bit hashes. This should be good # enough to prevent any collisions. @@ -33,7 +33,7 @@ type const cb64 = [ "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", - "O", "P", "Q", "R", "S", "T" "U", "V", "W", "X", "Y", "Z", + "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", diff --git a/compiler/ccgthreadvars.nim b/compiler/ccgthreadvars.nim index d741c47a9..ab771d240 100644 --- a/compiler/ccgthreadvars.nim +++ b/compiler/ccgthreadvars.nim @@ -24,7 +24,7 @@ proc accessThreadLocalVar(p: BProc, s: PSym) = ropecg(p.module, "\tNimTV = (NimThreadVars*) #GetThreadLocalVars();$n")) var - nimtv: Rope # nimrod thread vars; the struct body + nimtv: Rope # Nim thread vars; the struct body nimtvDeps: seq[PType] = @[] # type deps: every module needs whole struct nimtvDeclared = initIntSet() # so that every var/field exists only once # in the struct diff --git a/compiler/ccgtypes.nim b/compiler/ccgtypes.nim index 1ed9ce113..39f16ff0d 100644 --- a/compiler/ccgtypes.nim +++ b/compiler/ccgtypes.nim @@ -47,7 +47,7 @@ proc mangleName(s: PSym): Rope = # I need to study where these come from. # # about sfShadowed: - # consider the following nimrod code: + # consider the following Nim code: # var x = 10 # block: # var x = something(x) @@ -64,7 +64,7 @@ proc mangleName(s: PSym): Rope = # use that in the inner scope. # # about isCKeyword: - # nimrod variable names can be C keywords. + # Nim variable names can be C keywords. # We need to avoid such names in the generated code. # XXX: Study whether mangleName is called just once per variable. # Otherwise, there might be better place to do this. diff --git a/compiler/idgen.nim b/compiler/idgen.nim index c07782fb2..906c16546 100644 --- a/compiler/idgen.nim +++ b/compiler/idgen.nim @@ -44,7 +44,7 @@ proc toGid(f: string): string = # we used to use ``f.addFileExt("gid")`` (aka ``$project.gid``), but this # will cause strange bugs if multiple projects are in the same folder, so # we simply use a project independent name: - result = options.completeGeneratedFilePath("nimrod.gid") + result = options.completeGeneratedFilePath("nim.gid") proc saveMaxIds*(project: string) = var f = open(project.toGid, fmWrite) diff --git a/compiler/jsgen.nim b/compiler/jsgen.nim index 9424a9fc5..7ff822dd1 100644 --- a/compiler/jsgen.nim +++ b/compiler/jsgen.nim @@ -1138,6 +1138,18 @@ proc createObjInitList(p: PProc, typ: PType, excludedFieldIDs: IntSet, output: v createRecordVarAux(p, t.n, excludedFieldIDs, output) t = t.sons[0] +proc arrayTypeForElemType(typ: PType): string = + case typ.kind + of tyInt, tyInt32: "Int32Array" + of tyInt16: "Int16Array" + of tyInt8: "Int8Array" + of tyUint, tyUint32: "Uint32Array" + of tyUint16: "Uint16Array" + of tyUint8: "Uint8Array" + of tyFloat32: "Float32Array" + of tyFloat64, tyFloat: "Float64Array" + else: nil + proc createVar(p: PProc, typ: PType, indirect: bool): Rope = var t = skipTypes(typ, abstractInst) case t.kind @@ -1152,9 +1164,12 @@ proc createVar(p: PProc, typ: PType, indirect: bool): Rope = of tyBool: result = putToSeq("false", indirect) of tyArray, tyArrayConstr: - var length = int(lengthOrd(t)) - var e = elemType(t) - if length > 32: + let length = int(lengthOrd(t)) + let e = elemType(t) + let jsTyp = arrayTypeForElemType(e) + if not jsTyp.isNil: + result = "new $1($2)" % [rope(jsTyp), rope(length)] + elif length > 32: useMagic(p, "arrayConstr") # XXX: arrayConstr depends on nimCopy. This line shouldn't be necessary. useMagic(p, "nimCopy") @@ -1766,7 +1781,15 @@ proc genHeader(): Rope = "/* (c) 2015 Andreas Rumpf */$n$n" & "var framePtr = null;$n" & "var excHandler = 0;$n" & - "var lastJSError = null;$n") % + "var lastJSError = null;$n" & + "if (typeof Int8Array === 'undefined') Int8Array = Array;$n" & + "if (typeof Int16Array === 'undefined') Int16Array = Array;$n" & + "if (typeof Int32Array === 'undefined') Int32Array = Array;$n" & + "if (typeof Uint8Array === 'undefined') Uint8Array = Array;$n" & + "if (typeof Uint16Array === 'undefined') Uint16Array = Array;$n" & + "if (typeof Uint32Array === 'undefined') Uint32Array = Array;$n" & + "if (typeof Float32Array === 'undefined') Float32Array = Array;$n" & + "if (typeof Float64Array === 'undefined') Float64Array = Array;$n") % [rope(VersionAsString)] proc genModule(p: PProc, n: PNode) = diff --git a/compiler/options.nim b/compiler/options.nim index 9b587fcdb..c9e5e5b76 100644 --- a/compiler/options.nim +++ b/compiler/options.nim @@ -147,8 +147,8 @@ var gDllOverrides = newStringTable(modeCaseInsensitive) gPrefixDir* = "" # Overrides the default prefix dir in getPrefixDir proc. libpath* = "" - gProjectName* = "" # holds a name like 'nimrod' - gProjectPath* = "" # holds a path like /home/alice/projects/nimrod/compiler/ + gProjectName* = "" # holds a name like 'nim' + gProjectPath* = "" # holds a path like /home/alice/projects/nim/compiler/ gProjectFull* = "" # projectPath/projectName gProjectIsStdin* = false # whether we're compiling from stdin gProjectMainIdx*: int32 # the canonical path id of the main module diff --git a/compiler/platform.nim b/compiler/platform.nim index 8376c2b32..dc414bfeb 100644 --- a/compiler/platform.nim +++ b/compiler/platform.nim @@ -10,7 +10,7 @@ # This module contains data about the different processors # and operating systems. # Note: Unfortunately if an OS or CPU is listed here this does not mean that -# Nimrod has been tested on this platform or that the RTL has been ported. +# Nim has been tested on this platform or that the RTL has been ported. # Feel free to test for your excentric platform! import |