summary refs log tree commit diff stats
path: root/compiler/vmgen.nim
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/vmgen.nim')
-rw-r--r--compiler/vmgen.nim17
1 files changed, 8 insertions, 9 deletions
diff --git a/compiler/vmgen.nim b/compiler/vmgen.nim
index 3c0f8dbc9..7c0c3d4f5 100644
--- a/compiler/vmgen.nim
+++ b/compiler/vmgen.nim
@@ -328,6 +328,7 @@ proc canonValue*(n: PNode): PNode =
 
 proc rawGenLiteral(c: PCtx; n: PNode): int =
   result = c.constants.len
+  assert(n.kind != nkCall)
   c.constants.add n.canonValue
   internalAssert result < 0x7fff
 
@@ -1033,6 +1034,7 @@ proc genAsgn(c: PCtx; dest: TDest; ri: PNode; requiresCopy: bool) =
 proc setSlot(c: PCtx; v: PSym) =
   # XXX generate type initialization here?
   if v.position == 0:
+    if c.prc.maxSlots == 0: c.prc.maxSlots = 1
     v.position = c.prc.maxSlots
     c.prc.slots[v.position] = (inUse: true,
         kind: if v.kind == skLet: slotFixedLet else: slotFixedVar)
@@ -1285,16 +1287,13 @@ proc genVarSection(c: PCtx; n: PNode) =
         if s.position == 0:
           if sfImportc in s.flags: c.importcSym(a.info, s)
           else:
-            let sa = if s.ast.isNil: getNullValue(s.typ, a.info) 
-                     else: canonValue(s.ast)
+            let sa = getNullValue(s.typ, a.info)
+            #if s.ast.isNil: getNullValue(s.typ, a.info)
+            #else: canonValue(s.ast)
+            assert sa.kind != nkCall
             c.globals.add(sa)
             s.position = c.globals.len
-        if a.sons[2].kind == nkEmpty:
-          when false:
-            withTemp(tmp, s.typ):
-              c.gABx(a, opcLdNull, tmp, c.genType(s.typ))
-              c.gABx(a, whichAsgnOpc(a.sons[0], opcWrGlobal), tmp, s.position)
-        else:
+        if a.sons[2].kind != nkEmpty:
           let tmp = c.genx(a.sons[0], {gfAddrOf})
           let val = c.genx(a.sons[2])
           c.gABC(a, opcWrDeref, tmp, val)
@@ -1502,7 +1501,7 @@ proc gen(c: PCtx; n: PNode; dest: var TDest; flags: TGenFlags = {}) =
     else:
       localError(n.info, errGenerated, "VM is not allowed to 'cast'")
   else:
-    internalError n.info, "too implement " & $n.kind
+    internalError n.info, "cannot generate VM code for " & n.renderTree
 
 proc removeLastEof(c: PCtx) =
   let last = c.code.len-1
le='Blame the previous revision' href='/gbmor/getwtxt/blame/main.go?h=v0.4.13&id=1f8b2ce166e104bca99e4a758bb658dd27d5e4d6'>^
c87acad ^

d2680fb ^
3bc4358 ^
d2680fb ^
efa99ed ^
d6fbc25 ^
3bc4358 ^
d6fbc25 ^
efa99ed ^
d2680fb ^
3bc4358 ^
d2680fb ^
efa99ed ^
5310d08 ^

d2680fb ^
3bc4358 ^
d2680fb ^
efa99ed ^
3bc4358 ^





5310d08 ^

bd2800a ^
3bc4358 ^
5310d08 ^
efa99ed ^
5310d08 ^
3bc4358 ^

bd2800a ^
efa99ed ^
37bf8b0 ^

d2680fb ^
dfab6f2 ^
d2680fb ^
d2680fb ^
efa99ed ^
37bf8b0 ^






3bc4358 ^
37bf8b0 ^





d437b89 ^
d2680fb ^
3bc4358 ^






d2680fb ^
efa99ed ^
711012e ^
dfab6f2 ^
3bc4358 ^






d2680fb ^
fb63b07 ^
cd635e6 ^


711012e ^
bd5e602 ^

c87acad ^
747f4fb ^
06cffd8 ^
c87acad ^


893123c ^
bd23ef0 ^
78f4d8a ^
bd5e602 ^
d083ce6 ^
893123c ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118