summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2014-08-20 01:11:47 +0200
committerAraq <rumpf_a@web.de>2014-08-20 01:11:47 +0200
commitbc2e83fe170bdd01b2f251405702f69366a63107 (patch)
treec2af3c18ebac67f7a453738c2ddadf629938e301
parent9ee59da4121ea43a646c373c83844d44c4a574c4 (diff)
downloadNim-bc2e83fe170bdd01b2f251405702f69366a63107.tar.gz
documented the JS codegen
-rw-r--r--compiler/jsgen.nim19
1 files changed, 19 insertions, 0 deletions
diff --git a/compiler/jsgen.nim b/compiler/jsgen.nim
index 72fe4ecc5..dfe498e47 100644
--- a/compiler/jsgen.nim
+++ b/compiler/jsgen.nim
@@ -10,6 +10,25 @@
 # This is the JavaScript code generator.
 # Soon also a Luajit code generator. ;-)
 
+discard """
+The JS code generator contains only 2 tricks:
+
+Trick 1
+-------
+Some locations (for example 'var int') require "fat pointers" (``etyBaseIndex``)
+which are pairs (array, index). The derefence operation is then 'array[index]'.
+Check ``mapType`` for the details.
+
+Trick 2
+-------
+It is preferable to generate '||' and '&&' if possible since that is more
+idiomatic and hence should be friendlier for the JS JIT implementation. However
+code like ``foo and (let bar = baz())`` cannot be translated this way. Instead
+the expressions need to be transformed into statements. ``isSimpleExpr``
+implements the required case distinction.
+"""
+
+
 import
   ast, astalgo, strutils, hashes, trees, platform, magicsys, extccomp,
   options, nversion, nimsets, msgs, crc, bitsets, idents, lists, types, os,