alias analysis as required for the code gen and the HLO
This commit is contained in:
parent
c6213c9774
commit
2962ca7890
12 changed files with 262 additions and 80 deletions
36
compiler/semmagic.nim
Normal file
36
compiler/semmagic.nim
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
#
|
||||
#
|
||||
# The Nimrod Compiler
|
||||
# (c) Copyright 2011 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
#
|
||||
|
||||
# This include file implements the semantic checking for magics.
|
||||
|
||||
proc semIsPartOf(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
||||
var r = isPartOf(n[1], n[2])
|
||||
result = newIntNodeT(ord(r), n)
|
||||
|
||||
proc semSlurp(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
||||
assert sonsLen(n) == 2
|
||||
var a = expectStringArg(c, n, 0)
|
||||
try:
|
||||
var filename = a.strVal.FindFile
|
||||
var content = readFile(filename)
|
||||
result = newStrNode(nkStrLit, content)
|
||||
result.typ = getSysType(tyString)
|
||||
result.info = n.info
|
||||
c.slurpedFiles.add(filename)
|
||||
except EIO:
|
||||
GlobalError(a.info, errCannotOpenFile, a.strVal)
|
||||
|
||||
proc magicsAfterOverloadResolution(c: PContext, n: PNode,
|
||||
flags: TExprFlags): PNode =
|
||||
case n[0].sym.magic
|
||||
of mSlurp: result = semSlurp(c, n, flags)
|
||||
of mIsPartOf: result = semIsPartOf(c, n, flags)
|
||||
else: result = n
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue