summary refs log tree commit diff stats
path: root/poems-1.html
blob: d9dba2477d92121c90b7014f575fe77d27fd6251 (plain) (blame)
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
	<head>
		<title>Poem Collection 1</title>
		<link rel="stylesheet" href="/oldstyle.css" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
		<meta charset="utf-8" />
	</head>
	<body>
		<h1>Poem Collection 1</h1>
		

<p>
Had witness my fall you recalled the path I took,<br />
Projectiles to pass by space; time closed thy book<br />
To ram but slow I shut my ears and eyes<br />
Flowing through called history thy trust no doubt?
</p>
<hr />
<p>
Damaged walls, flake of snow<br />
Fluorescent bulbs to the wicked glow<br />
Copper-plated zinc, as electrons fly off—<br />
Less energy, more mass,<br />
Bonds fuse and dissipate through.
</p>
<hr />
<p>
Call for distress I pull through wind and <br />
Reciprocal squares guard my flame!<br />
Gift of time we lost our brain,<br />
Collectively trialed to the scent of law.
</p>
<hr />
<p>
A tie, a knot<br />
Blank tile of red paper<br />
No truth I behold<br />
booklets I then fold<br />
Leaves have fallen through<br />
The last rupture of space<br />
Time hauls, halts, as<br />
My inertia approaches the essence<br />
Subjectivity I entail<br />
That last, final mail.<br />
First straw thy burnt<br />
Reducingly brick red I turn<br />
Why, the notion of myself?<br />
What basis vectors I base upon?<br />
Me, contra-variant perspectives<br />
Limited at zero but never approaching<br />
in finite steps.<br />
Impedance to the arrow<br />
Coils induce, right thumb.<br />
Like a diverging series I pass<br />
Through covariant species.
</p>
<hr />

<p>
Maple trees that vanish<br />
While last it's me who's banished,<br />
FLEE, RUN WHILE YOU'RE ALIVE—<br />
Equations you cannot derive.<br />
Integrate; syndicate; resonate!<br />
Iterating through the ashes of history<br />
We being in the gory and your glory.<br />
We're all in a hurry, but worry you not;<br />
I had my best at calculating my determinant,<br />
What's left is all but ultimately permanent.<br />
Clot! Shot? Weeding through time and space.<br />
No eigenvalues that mind could could encompass,<br />
While you still have the privilege for forecasts!
</p>
<hr />

<p>
A game of roulette<br />
That starry of a couplet;<br />
Seeking knowledge<br />
Without that assuage.<br />
<i>Thy brain is <b>squishy</b></i><br />
Heart ceases to be wishy.<br />
Dreams crushed,<br />
Faces blushed.<br />
Perpetually elevated,<br />
Never subjugated.
</p>
<hr />

<p>
May the base case be proven, by induction<br />
we arrive at a construction.<br />
Blocks of clay invisibly built,<br />
No sense of pride or guilt.<br />
Cold and austere,<br />
Painting a sphere clear near.<br />
Dreams of symbols,<br />
Winge for the last call.<br />
But it always awaits,<br />
Never do you demodulate.<br />
No need to be redemptive,<br />
Truth itself relative.
</p>
<hr />

<p>
At the end of the day I phew<br />
Lips turn blue;<br />
Falling into misery<br />
No degree that I've deprived!<br />
Painting my soul,<br />
Let go of that control.<br />
Strolling enrolling a whole percent.<br />
Nothing to represent, scent of intent—<br />
Reproaching the limit<br />
only Pis and Sigmas<br />
By what they underlie.<br />
Goodbye?<br />
No reply.
</p>
<hr />

<p>
Deprived of truth that I see eternal,<br />
I swear to god, none that saw feudal.<br />
Coaxially aligned my heart's contrived,<br />
By pen and ink thy mind has arrived.<br />
<br />
Standing on the shoulder of giants—<br />
or rather under the shoes of no alliant's.<br />
I burn, I oxidize, but then reduce,<br />
But no theorem or method could induce.<br />
<br />
May those not maligned shall fly,<br />
No key of mine might apply.<br />
Bombard the idea that I survive<br />
All I am is alive.
</p>

		<div id="footer">
			<hr />
			<p><a href="/">Runxi Yu's Website</a></p>
			
		</div>
	</body>
</html>
/ahoang/Nim/blame/compiler/sem.nim?h=devel&id=5e15dec1757e6013cbeb5d6baf9d9579cf025361'>^
5e15dec17 ^
eaeed1f84 ^






2f066395b ^

b595fc834 ^
2f066395b ^
12bac28d2 ^



b4844a189 ^
12bac28d2 ^
af7c92c00 ^
12bac28d2 ^


e5bd3b5b9 ^
e25474154 ^
42516c008 ^
e25474154 ^
e5bd3b5b9 ^
b595fc834 ^


e5bd3b5b9 ^



b595fc834 ^

e5bd3b5b9 ^

b64eeeb43 ^
071b1e395 ^
2aabae702 ^









e25474154 ^
69997af8e ^



e25474154 ^
a59abdf8e ^
12bac28d2 ^
f7884717c ^
a59abdf8e ^









2aabae702 ^

a59abdf8e ^



69997af8e ^
e25474154 ^
b4844a189 ^
7063670a2 ^
e25474154 ^
4d9a5dc8f ^

2e5265bef ^
a0a8934a4 ^
36e25a684 ^
2e5265bef ^








b4844a189 ^
e25474154 ^
e25474154 ^
032599c15 ^


032599c15 ^

b595fc834 ^




032599c15 ^
b595fc834 ^


032599c15 ^
23c3af80f ^
e25474154 ^
55f8ed245 ^




e25474154 ^
b0c11d3ef ^

55f8ed245 ^
e25474154 ^
36e25a684 ^

b0c11d3ef ^
e25474154 ^
eebee0eff ^
3051c52f5 ^
8d19a93f1 ^
121519301 ^
42d0911d6 ^
623fd8a8a ^
e25474154 ^
3d1c6de63 ^

e25474154 ^

e25474154 ^
3d1c6de63 ^
e25474154 ^
3d1c6de63 ^
e25474154 ^

36e25a684 ^

244c14db0 ^
e25474154 ^
5b28d0820 ^

7063670a2 ^
55f8ed245 ^
7063670a2 ^
e25474154 ^


5b28d0820 ^
e25474154 ^
b64eeeb43 ^
cb6ad8cb7 ^

244c14db0 ^
cb6ad8cb7 ^
623fd8a8a ^



7a2b1a752 ^
af081f995 ^
623fd8a8a ^


5b28d0820 ^





087b8621d ^
043921c7a ^
5b28d0820 ^

de338526e ^
623fd8a8a ^
043921c7a ^
087b8621d ^
7e31134ff ^

de338526e ^
5b28d0820 ^
ca637c019 ^
99bcc233c ^
ca637c019 ^
99bcc233c ^
ca637c019 ^
e25474154 ^
7063670a2 ^
9a6f47ae6 ^

b0c11d3ef ^

e25474154 ^

a1da1f987 ^

ca637c019 ^
e25474154 ^
623fd8a8a ^
e25474154 ^
091c1b307 ^

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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326


                               
                                         






                                                    
      
                                                                        
                                                                               

                                                                             
                                                                            
                                              
 

                


                                                                              

                                                                         
                                              
 
                                                           
                                                      
 
                                                               


                                                                
                                                     
                                                   
                                                                      
                                                                  

                                        
                                              
                                       
 
                                                                 
 
                                                     



                                                                       




                                                              


                          
 

                                         


                                                          

                       


                                       



                                            



                                                                





















                                                                 
                                                
                            

                                                            
                                                               


                                                            
                     



                                           
                                                                 
 






                                                               

                                                          
                                                           
 



                                                                            
                                                           
                                               
                                                                 


                                                                 
                                                  
                                    
                   
                                       
                                               


                                              



                                                 

                                            

                              
                             
 









                                                                     
                                                                



                                                          
            
                          
                               
       









                                                                               

                                              



                                                                             
                          
 
                                                           
                                                  
                  

                                                            
 
                          
                                                      








                                                         
                                                      
                                                         
 


                                               

                                                      




                                             
                                         


                                            
 
                                                       
 




                                                                          
                                                            

                          
                                   
 

                                         
                                                         
                               
                     
                           
                                       
                                         
                             
                        
                     

                                                      

                                                         
        
                                                                               
                                              
                                

            

                                                               
                                                
 

                                                                
                                                                  
                                       
                                        


                                        
                                                  
                
                             

                                                            
                                          
    



                                                                              
                                  
                                                    


                                                                 





                                                                           
                                                
                                          

                                               
                                           
                       
                                        
                                           

                                                            
                                                
  
                                
                                      
                                      
                                                    
  
                                                       
                           

                                                                        

                              

                                                       

                            
                 
            
               
 

                                                                   
#
#
#           The Nimrod Compiler
#        (c) Copyright 2013 Andreas Rumpf
#
#    See the file "copying.txt", included in this
#    distribution, for details about the copyright.
#

# This module implements the semantic checking pass.

import
  ast, strutils, hashes, lists, options, lexer, astalgo, trees, treetab,
  wordrecg, ropes, msgs, os, condsyms, idents, renderer, types, platform, math,
  magicsys, parser, nversion, nimsets, semfold, importer,
  procfind, lookups, rodread, pragmas, passes, semdata, semtypinst, sigmatch,
  semthreads, intsets, transf, evals, idgen, aliases, cgmeth, lambdalifting,
  evaltempl, patterns, parampatterns, sempass2

# implementation

proc semExpr(c: PContext, n: PNode, flags: TExprFlags = {}): PNode {.procvar.}
proc semExprWithType(c: PContext, n: PNode, flags: TExprFlags = {}): PNode {.
  procvar.}
proc semExprNoType(c: PContext, n: PNode): PNode
proc semExprNoDeref(c: PContext, n: PNode, flags: TExprFlags = {}): PNode
proc semProcBody(c: PContext, n: PNode): PNode

proc fitNode(c: PContext, formal: PType, arg: PNode): PNode
proc changeType(n: PNode, newType: PType, check: bool)

proc semLambda(c: PContext, n: PNode, flags: TExprFlags): PNode
proc semTypeNode(c: PContext, n: PNode, prev: PType): PType
proc semStmt(c: PContext, n: PNode): PNode
proc semParamList(c: PContext, n, genericParams: PNode, s: PSym)
proc addParams(c: PContext, n: PNode, kind: TSymKind)
proc maybeAddResult(c: PContext, s: PSym, n: PNode)
proc instGenericContainer(c: PContext, n: PNode, header: PType): PType
proc tryExpr(c: PContext, n: PNode, flags: TExprFlags = {}): PNode
proc fixImmediateParams(n: PNode): PNode
proc activate(c: PContext, n: PNode)
proc semQuoteAst(c: PContext, n: PNode): PNode
proc finishMethod(c: PContext, s: PSym)

proc IndexTypesMatch(c: PContext, f, a: PType, arg: PNode): PNode

proc typeMismatch(n: PNode, formal, actual: PType) = 
  if formal.kind != tyError and actual.kind != tyError: 
    LocalError(n.Info, errGenerated, msgKindToString(errTypeMismatch) &
        typeToString(actual) & ") " &
        `%`(msgKindToString(errButExpectedX), [typeToString(formal)]))

proc fitNode(c: PContext, formal: PType, arg: PNode): PNode = 
  result = IndexTypesMatch(c, formal, arg.typ, arg)
  if result == nil:
    typeMismatch(arg, formal, arg.typ)
    # error correction:
    result = copyNode(arg)
    result.typ = formal

var CommonTypeBegin = PType(kind: tyExpr)

proc commonType*(x, y: PType): PType =
  # new type relation that is used for array constructors,
  # if expressions, etc.:
  if x == nil: return x
  if y == nil: return y
  var a = skipTypes(x, {tyGenericInst})
  var b = skipTypes(y, {tyGenericInst})
  result = x
  if a.kind in {tyExpr, tyNil}: result = y
  elif b.kind in {tyExpr, tyNil}: result = x
  elif a.kind == tyStmt: result = a
  elif b.kind == tyStmt: result = b
  elif a.kind == tyTypeDesc:
    # turn any concrete typedesc into the abstract typedesc type
    if a.sons == nil: result = a
    else: result = newType(tyTypeDesc, a.owner)
  elif b.kind in {tyArray, tyArrayConstr, tySet, tySequence} and 
      a.kind == b.kind:
    # check for seq[empty] vs. seq[int]
    let idx = ord(b.kind in {tyArray, tyArrayConstr})
    if a.sons[idx].kind == tyEmpty: return y
    #elif b.sons[idx].kind == tyEmpty: return x
  else:
    var k = tyNone
    if a.kind in {tyRef, tyPtr}:
      k = a.kind
      if b.kind != a.kind: return x
      a = a.sons[0]
      b = b.sons[0]
    if a.kind == tyObject and b.kind == tyObject:
      result = commonSuperclass(a, b)
      # this will trigger an error later:
      if result.isNil: return x
      if k != tyNone:
        let r = result
        result = NewType(k, r.owner)
        result.addSonSkipIntLit(r)

proc isTopLevel(c: PContext): bool {.inline.} = 
  result = c.scopeDepth <= 2

proc newSymS(kind: TSymKind, n: PNode, c: PContext): PSym = 
  result = newSym(kind, considerAcc(n), getCurrOwner(), n.info)

proc newSymG*(kind: TSymKind, n: PNode, c: PContext): PSym =
  # like newSymS, but considers gensym'ed symbols
  if n.kind == nkSym:
    result = n.sym
    InternalAssert sfGenSym in result.flags
    InternalAssert result.kind == kind
  else:
    result = newSym(kind, considerAcc(n), getCurrOwner(), n.info)

proc semIdentVis(c: PContext, kind: TSymKind, n: PNode,
                 allowed: TSymFlags): PSym
  # identifier with visability
proc semIdentWithPragma(c: PContext, kind: TSymKind, n: PNode, 
                        allowed: TSymFlags): PSym
proc semStmtScope(c: PContext, n: PNode): PNode

proc ParamsTypeCheck(c: PContext, typ: PType) {.inline.} =
  if not typeAllowed(typ, skConst):
    LocalError(typ.n.info, errXisNoType, typeToString(typ))

proc expectMacroOrTemplateCall(c: PContext, n: PNode): PSym

proc semTemplateExpr(c: PContext, n: PNode, s: PSym, semCheck = true): PNode

proc semMacroExpr(c: PContext, n, nOrig: PNode, sym: PSym, 
                  semCheck: bool = true): PNode
proc semDirectOp(c: PContext, n: PNode, flags: TExprFlags): PNode

proc semWhen(c: PContext, n: PNode, semCheck: bool = true): PNode

proc evalTypedExpr(c: PContext, e: PNode): PNode =
  result = getConstExpr(c.module, e)
  if result == nil:
    result = evalConstExpr(c.module, e)
    if result == nil or result.kind == nkEmpty:
      LocalError(e.info, errConstExprExpected)
      # error correction:
      result = e

proc semConstExpr(c: PContext, n: PNode): PNode =
  var e = semExprWithType(c, n)
  if e == nil:
    LocalError(n.info, errConstExprExpected)
    return n
  result = evalTypedExpr(c, e)

include hlo, seminst, semcall

proc symFromType(t: PType, info: TLineInfo): PSym =
  if t.sym != nil: return t.sym
  result = newSym(skType, getIdent"AnonType", t.owner, info)
  result.flags.incl sfAnon
  result.typ = t

proc symNodeFromType(c: PContext, t: PType, info: TLineInfo): PNode =
  result = newSymNode(symFromType(t, info), info)
  result.typ = makeTypeDesc(c, t)

proc semAfterMacroCall(c: PContext, n: PNode, s: PSym): PNode = 
  inc(evalTemplateCounter)
  if evalTemplateCounter > 100:
    GlobalError(s.info, errTemplateInstantiationTooNested)

  result = n
  if s.typ.sons[0] == nil:
    result = semStmt(c, result)
  else:
    case s.typ.sons[0].kind
    of tyExpr:
      # BUGFIX: we cannot expect a type here, because module aliases would not 
      # work then (see the ``tmodulealias`` test)
      # semExprWithType(c, result)
      result = semExpr(c, result)
    of tyStmt:
      result = semStmt(c, result)
    of tyTypeDesc:
      if n.kind == nkStmtList: result.kind = nkStmtListType
      var typ = semTypeNode(c, result, nil)
      result = symNodeFromType(c, typ, n.info)
    else:
      result = semExpr(c, result)
      result = fitNode(c, s.typ.sons[0], result)
      #GlobalError(s.info, errInvalidParamKindX, typeToString(s.typ.sons[0]))
  dec(evalTemplateCounter)

proc semMacroExpr(c: PContext, n, nOrig: PNode, sym: PSym, 
                  semCheck: bool = true): PNode = 
  markUsed(n, sym)
  if sym == c.p.owner:
    GlobalError(n.info, errRecursiveDependencyX, sym.name.s)

  if c.evalContext == nil:
    c.evalContext = newEvalContext(c.module, emStatic)
    c.evalContext.getType = proc (n: PNode): PNode =
      var e = tryExpr(c, n)
      if e == nil:
        result = symNodeFromType(c, errorType(c), n.info)
      elif e.typ == nil:
        result = newSymNode(getSysSym"void")
      else:
        result = symNodeFromType(c, e.typ, n.info)

  result = evalMacroCall(c.evalContext, n, nOrig, sym)
  if semCheck: result = semAfterMacroCall(c, result, sym)

proc forceBool(c: PContext, n: PNode): PNode = 
  result = fitNode(c, getSysType(tyBool), n)
  if result == nil: result = n

proc semConstBoolExpr(c: PContext, n: PNode): PNode = 
  let nn = semExprWithType(c, n)
  result = fitNode(c, getSysType(tyBool), nn)
  if result == nil:
    LocalError(n.info, errConstExprExpected)
    return nn
  result = getConstExpr(c.module, result)
  if result == nil: 
    LocalError(n.info, errConstExprExpected)
    result = nn

include semtypes, semtempl, semgnrc, semstmts, semexprs

proc addCodeForGenerics(c: PContext, n: PNode) =
  for i in countup(c.lastGenericIdx, c.generics.len - 1):
    var prc = c.generics[i].inst.sym
    if prc.kind in {skProc, skMethod, skConverter} and prc.magic == mNone:
      if prc.ast == nil or prc.ast.sons[bodyPos] == nil:
        InternalError(prc.info, "no code for " & prc.name.s)
      else:
        addSon(n, prc.ast)
  c.lastGenericIdx = c.generics.len

proc myOpen(module: PSym): PPassContext =
  var c = newContext(module)
  if c.p != nil: InternalError(module.info, "sem.myOpen")
  c.semConstExpr = semConstExpr
  c.semExpr = semExpr
  c.semOperand = semOperand
  c.semConstBoolExpr = semConstBoolExpr
  c.semOverloadedCall = semOverloadedCall
  c.semTypeNode = semTypeNode
  pushProcCon(c, module)
  pushOwner(c.module)
  c.importTable = openScope(c)
  c.importTable.addSym(module) # a module knows itself
  if sfSystemModule in module.flags: 
    magicsys.SystemModule = module # set global variable!
  else: 
    c.importTable.addSym magicsys.SystemModule # import the "System" identifier
    importAllSymbols(c, magicsys.SystemModule)
  c.topLevelScope = openScope(c)
  result = c

proc myOpenCached(module: PSym, rd: PRodReader): PPassContext =
  result = myOpen(module)
  for m in items(rd.methods): methodDef(m, true)

proc SemStmtAndGenerateGenerics(c: PContext, n: PNode): PNode = 
  result = semStmt(c, n)
  # BUGFIX: process newly generated generics here, not at the end!
  if c.lastGenericIdx < c.generics.len:
    var a = newNodeI(nkStmtList, n.info)
    addCodeForGenerics(c, a)
    if sonsLen(a) > 0: 
      # a generic has been added to `a`:
      if result.kind != nkEmpty: addSon(a, result)
      result = a
  result = hloStmt(c, result)
  if gCmd == cmdInteractive and not isEmptyType(result.typ):
    result = buildEchoStmt(c, result)
  result = transformStmt(c.module, result)
    
proc RecoverContext(c: PContext) = 
  # clean up in case of a semantic error: We clean up the stacks, etc. This is
  # faster than wrapping every stack operation in a 'try finally' block and 
  # requires far less code.
  c.currentScope = c.topLevelScope
  c.scopeDepth = 2 # importTable and top-level scope
  while getCurrOwner().kind != skModule: popOwner()
  while c.p != nil and c.p.owner.kind != skModule: c.p = c.p.next

proc myProcess(context: PPassContext, n: PNode): PNode = 
  var c = PContext(context)    
  # no need for an expensive 'try' if we stop after the first error anyway:
  if msgs.gErrorMax <= 1:
    result = SemStmtAndGenerateGenerics(c, n)
  else:
    let oldContextLen = msgs.getInfoContextLen()
    let oldInGenericInst = c.InGenericInst
    try:
      result = SemStmtAndGenerateGenerics(c, n)
    except ERecoverableError, ESuggestDone:
      RecoverContext(c)
      c.InGenericInst = oldInGenericInst
      msgs.setInfoContextLen(oldContextLen)
      if getCurrentException() of ESuggestDone: result = nil
      else: result = ast.emptyNode
      #if gCmd == cmdIdeTools: findSuggest(c, n)
  
proc checkThreads(c: PContext) =
  if not needsGlobalAnalysis(): return
  for i in 0 .. c.threadEntries.len-1:
    semthreads.AnalyseThreadProc(c.threadEntries[i])
  
proc myClose(context: PPassContext, n: PNode): PNode = 
  var c = PContext(context)
  closeScope(c)         # close module's scope
  rawCloseScope(c)      # imported symbols; don't check for unused ones!
  result = newNode(nkStmtList)
  if n != nil:
    InternalError(n.info, "n is not nil") #result := n;
  addCodeForGenerics(c, result)
  if c.module.ast != nil:
    result.add(c.module.ast)
  checkThreads(c)
  popOwner()
  popProcCon(c)

const semPass* = makePass(myOpen, myOpenCached, myProcess, myClose)