summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndreas Rumpf <andreas@andreas-laptop>2010-07-21 20:59:06 +0200
committerAndreas Rumpf <andreas@andreas-laptop>2010-07-21 20:59:06 +0200
commitcdf03b06b93d8bf5023d7c4b38a761675a20d514 (patch)
treef41ea10b1d54502600e841605d8fb0767558e5d3
parentde27098546773b9af5d1a1c06f68f06fadbf3008 (diff)
downloadNim-cdf03b06b93d8bf5023d7c4b38a761675a20d514.tar.gz
added system.appType magic
-rwxr-xr-xdoc/apis.txt1
-rwxr-xr-xdoc/nimrodc.txt11
-rwxr-xr-xlib/system.nim10
-rwxr-xr-xlib/system/mmdisp.nim (renamed from lib/system/mm.nim)6
-rwxr-xr-xrod/ast.nim6
-rwxr-xr-xrod/c2nim/c2nim.cfg4
-rw-r--r--rod/c2nim/manual.txt2
-rwxr-xr-xrod/commands.nim8
-rwxr-xr-xrod/ropes.nim4
-rwxr-xr-xrod/semfold.nim9
-rwxr-xr-xtools/nimrepl.nim2
11 files changed, 49 insertions, 14 deletions
diff --git a/doc/apis.txt b/doc/apis.txt
index 93484b8b7..2932c05a9 100755
--- a/doc/apis.txt
+++ b/doc/apis.txt
@@ -56,6 +56,7 @@ extension               ext
 separator               sep
 column                  col, column    col is preferred, inconsistent right
                                        now
+application             app
 configuration           cfg
 message                 msg
 argument                arg
diff --git a/doc/nimrodc.txt b/doc/nimrodc.txt
index cdad6efa8..b4960c5e4 100755
--- a/doc/nimrodc.txt
+++ b/doc/nimrodc.txt
@@ -66,9 +66,18 @@ The generated files that Nimrod produces all go into a subdirectory called
 ``nimcache`` in your project directory. This makes it easy to delete all

 generated files.

 

-However, the generated C code is not platform independant. C code generated for

+However, the generated C code is not platform independent. C code generated for

 Linux does not compile on Windows, for instance. The comment on top of the

 C file lists the OS, CPU and CC the file has been compiled for.

+
+..
+  DLL generation
+  ==============
+
+  Nimrod supports the generation of DLLs. However, there must be only one 
+  instance of the GC per address space. This instance is contained in
+  ``nimrtl.dll``. This means that every generated Nimrod DLL depends
+  on ``nimrtl.dll``. 
 

 

 Additional Features

diff --git a/lib/system.nim b/lib/system.nim
index 5265c2365..7d1d2a867 100755
--- a/lib/system.nim
+++ b/lib/system.nim
@@ -813,11 +813,15 @@ const
   hostOS* {.magic: "HostOS"}: string = ""
     ## a string that describes the host operating system. Possible values:
     ## "windows", "macosx", "linux", "netbsd", "freebsd", "openbsd", "solaris",
-    ## "aix"
+    ## "aix".
         
   hostCPU* {.magic: "HostCPU"}: string = ""
     ## a string that describes the host CPU. Possible values:
-    ## "i386", "alpha", "powerpc", "sparc", "amd64", "mips", "arm"
+    ## "i386", "alpha", "powerpc", "sparc", "amd64", "mips", "arm".
+  
+  appType* {.magic: "AppType"}: string = ""
+    ## a string that describes the application type. Possible values:
+    ## "console", "gui", "lib".
   
 proc toFloat*(i: int): float {.
   magic: "ToFloat", noSideEffect, importc: "toFloat".}
@@ -1570,7 +1574,7 @@ when not defined(EcmaScript) and not defined(NimrodVM):
       result = n.sons[n.len]
 
   include "system/systhread"
-  include "system/mm"
+  include "system/mmdisp"
   include "system/sysstr"
   include "system/assign"
   include "system/repr"
diff --git a/lib/system/mm.nim b/lib/system/mmdisp.nim
index 76b5d83bd..f28b6b931 100755
--- a/lib/system/mm.nim
+++ b/lib/system/mmdisp.nim
@@ -130,6 +130,12 @@ when defined(boehmgc):
 
   include "system/cellsets"
 elif defined(nogc):
+  # Even though we don't want the GC, we cannot simply use C's memory manager
+  # because Nimrod's runtime wants ``realloc`` to zero out the additional
+  # space which C's ``realloc`` does not. And we cannot get the old size of an
+  # object, because C does not support this operation... Even though every
+  # possible implementation has to have a way to determine the object's size.
+  # C just sucks.
   include "system/alloc"
 
   when false:
diff --git a/rod/ast.nim b/rod/ast.nim
index fde238eaa..15e74198c 100755
--- a/rod/ast.nim
+++ b/rod/ast.nim
@@ -308,7 +308,8 @@ type
     mShrI, mShlI, mBitandI, mBitorI, mBitxorI, mMinI, mMaxI, 
     mShrI64, mShlI64, mBitandI64, mBitorI64, mBitxorI64, mMinI64, mMaxI64,
     mMinF64, mMaxF64, mAddU, mSubU, mMulU, 
-    mDivU, mModU, mAddU64, mSubU64, mMulU64, mDivU64, mModU64, mEqI, mLeI, mLtI, 
+    mDivU, mModU, mAddU64, mSubU64, mMulU64, mDivU64, mModU64, mEqI, mLeI,
+    mLtI, 
     mEqI64, mLeI64, mLtI64, mEqF64, mLeF64, mLtF64, mLeU, mLtU, mLeU64, mLtU64, 
     mEqEnum, mLeEnum, mLtEnum, mEqCh, mLeCh, mLtCh, mEqB, mLeB, mLtB, mEqRef, 
     mEqProc, mEqUntracedRef, mLePtr, mLtPtr, mEqCString, mXor, mUnaryMinusI, 
@@ -326,7 +327,8 @@ type
     mInt64, mFloat, mFloat32, mFloat64, mBool, mChar, mString, mCstring, 
     mPointer, mEmptySet, mIntSetBaseType, mNil, mExpr, mStmt, mTypeDesc, 
     mIsMainModule, mCompileDate, mCompileTime, mNimrodVersion, mNimrodMajor, 
-    mNimrodMinor, mNimrodPatch, mCpuEndian, mHostOS, mHostCPU, mNaN, mInf, 
+    mNimrodMinor, mNimrodPatch, mCpuEndian, mHostOS, mHostCPU, mAppType, 
+    mNaN, mInf, 
     mNegInf, mNLen, mNChild, mNSetChild, mNAdd, mNAddMultiple, mNDel, mNKind, 
     mNIntVal, mNFloatVal, mNSymbol, mNIdent, mNGetType, mNStrVal, mNSetIntVal, 
     mNSetFloatVal, mNSetSymbol, mNSetIdent, mNSetType, mNSetStrVal, 
diff --git a/rod/c2nim/c2nim.cfg b/rod/c2nim/c2nim.cfg
new file mode 100755
index 000000000..789e6ec7f
--- /dev/null
+++ b/rod/c2nim/c2nim.cfg
@@ -0,0 +1,4 @@
+# Use the modules of the compiler
+
+path: "$nimrod/rod"
+
diff --git a/rod/c2nim/manual.txt b/rod/c2nim/manual.txt
index b2bb3dc06..68ad7a8bd 100644
--- a/rod/c2nim/manual.txt
+++ b/rod/c2nim/manual.txt
@@ -170,7 +170,7 @@ in the future as it cannot work for backends that do not generate C code.
 that can be used for the same purpose.
 
 c2nim does not do any name mangling by default. However the 
- ``#prefix`` and ``#suffix`` directives can be used to strip prefixes and
+``#prefix`` and ``#suffix`` directives can be used to strip prefixes and
 suffixes from the identifiers in the C code: 
  
 .. code-block:: C
diff --git a/rod/commands.nim b/rod/commands.nim
index 289f9c68e..f67a8e765 100755
--- a/rod/commands.nim
+++ b/rod/commands.nim
@@ -156,14 +156,14 @@ proc splitSwitch(switch: string, cmd, arg: var string, pass: TCmdLinePass,
                  info: TLineInfo) = 
   cmd = ""
   var i = 0
-  if (i < len(switch) + 0) and (switch[i] == '-'): inc(i)
-  if (i < len(switch) + 0) and (switch[i] == '-'): inc(i)
-  while i < len(switch) + 0: 
+  if i < len(switch) and switch[i] == '-': inc(i)
+  if i < len(switch) and switch[i] == '-': inc(i)
+  while i < len(switch): 
     case switch[i]
     of 'a'..'z', 'A'..'Z', '0'..'9', '_', '.': add(cmd, switch[i])
     else: break 
     inc(i)
-  if i >= len(switch) + 0: arg = ""
+  if i >= len(switch): arg = ""
   elif switch[i] in {':', '=', '['}: arg = copy(switch, i + 1)
   else: InvalidCmdLineOption(pass, switch, info)
   
diff --git a/rod/ropes.nim b/rod/ropes.nim
index 0139daf2b..542c6b3b3 100755
--- a/rod/ropes.nim
+++ b/rod/ropes.nim
@@ -52,9 +52,9 @@
 #  Note that the left and right pointers are not needed for leafs.
 #  Leafs have relatively high memory overhead (~30 bytes on a 32
 #  bit machines) and we produce many of them. This is why we cache and
-#  share leafs accross different rope trees.
+#  share leaves accross different rope trees.
 #  To cache them they are inserted in another tree, a splay tree for best
-#  performance. But for the caching tree we use the leafs' left and right
+#  performance. But for the caching tree we use the leaves' left and right
 #  pointers.
 #
 
diff --git a/rod/semfold.nim b/rod/semfold.nim
index 7aa6da1a6..a4de04e4f 100755
--- a/rod/semfold.nim
+++ b/rod/semfold.nim
@@ -274,6 +274,14 @@ proc magicCall(m: PSym, n: PNode): PNode =
     b = nil
   result = evalOp(s.magic, n, a, b, c)
   
+proc getAppType(n: PNode): PNode = 
+  if gGlobalOptions.contains(optGenDynLib):
+    result = newStrNodeT("lib", n)
+  elif gGlobalOptions.contains(optGenGuiApp):
+    result = newStrNodeT("gui", n)
+  else:
+    result = newStrNodeT("console", n)
+  
 proc getConstExpr(m: PSym, n: PNode): PNode = 
   result = nil
   case n.kind
@@ -293,6 +301,7 @@ proc getConstExpr(m: PSym, n: PNode): PNode =
       of mCpuEndian: result = newIntNodeT(ord(CPU[targetCPU].endian), n)
       of mHostOS: result = newStrNodeT(toLower(platform.OS[targetOS].name), n)
       of mHostCPU: result = newStrNodeT(toLower(platform.CPU[targetCPU].name), n)
+      of mAppType: result = getAppType(n)
       of mNaN: result = newFloatNodeT(NaN, n)
       of mInf: result = newFloatNodeT(Inf, n)
       of mNegInf: result = newFloatNodeT(NegInf, n)
diff --git a/tools/nimrepl.nim b/tools/nimrepl.nim
index 6f4478816..247bf0d10 100755
--- a/tools/nimrepl.nim
+++ b/tools/nimrepl.nim
@@ -17,7 +17,7 @@ proc execCode(code: string): string =
   else:
     raise newException(EIO, "Unable to open file")    
   result = osproc.execProcess(
-      "nimrod run --verbosity:0 --hint[Conf]:off temp.nim")
+      "nimrod c -r --verbosity:0 --hint[Conf]:off temp.nim")
 
 var shiftPressed = False
 var w: gtk2.PWindow