Просмотр исходного кода

Forgot something in desigaring docs

Taddeus Kroes 12 лет назад
Родитель
Сommit
1572d2d5dd
1 измененных файлов с 19 добавлено и 8 удалено
  1. 19 8
      phases/desug.mli

+ 19 - 8
phases/desug.mli

@@ -7,15 +7,26 @@
     generalize the AST format. This makes context analysis easier, since
     initialisations need not be considered. The assignments are placed in the
     function body, after local fuction declarations (which are not in the
-    example):
-
-{v int foo = 0;
-int bar = foo; v}
+    example below). Initialisations fo global variables are moved to a new
+    function called "__init", which is a reserved function that is called by the
+    VM before the main function is called.
+
+{v int glob = 1;
+export int main() \{
+  int foo = 0;
+  int bar = foo;
+\} v}
     becomes:
-{v int foo;
-int bar;
-foo = 0;
-bar = foo; v}
+{v export void __init() \{
+    glob = 1;
+\}
+int glob;
+export int main() \{
+  int foo;
+  int bar;
+  foo = 0;
+  bar = foo;
+\} v}
 
     {3 Array initialisations}