From 42d0911d6a1daa60cfe0dcd2cf8c403083f6ca65 Mon Sep 17 00:00:00 2001 From: Araq Date: Thu, 1 Nov 2012 01:11:48 +0100 Subject: [PATCH] nimbuild should work again --- build.bat | 2 +- build64.bat | 2 +- compiler/nimrod.ini | 2 +- compiler/pragmas.nim | 28 +++++++++--- compiler/sem.nim | 1 + compiler/semdata.nim | 1 + compiler/sempass2.nim | 91 ++++++++++++++++++++++++++++++-------- compiler/semstmts.nim | 1 + lib/pure/sockets.nim | 6 +-- lib/system.nim | 1 - tools/niminst/buildsh.tmpl | 2 +- 11 files changed, 106 insertions(+), 31 deletions(-) diff --git a/build.bat b/build.bat index 6582f957c2..2795fe5cbd 100755 --- a/build.bat +++ b/build.bat @@ -3,7 +3,7 @@ REM Generated by niminst SET CC=gcc SET LINKER=gcc SET COMP_FLAGS=-w -O3 -fno-strict-aliasing -SET LINK_FLAGS=-lsocket -lnsl +SET LINK_FLAGS= REM call the compiler: diff --git a/build64.bat b/build64.bat index 97dfefdc56..5e7f982604 100644 --- a/build64.bat +++ b/build64.bat @@ -3,7 +3,7 @@ REM Generated by niminst SET CC=gcc SET LINKER=gcc SET COMP_FLAGS=-w -O3 -fno-strict-aliasing -SET LINK_FLAGS=-lsocket -lnsl +SET LINK_FLAGS= REM call the compiler: diff --git a/compiler/nimrod.ini b/compiler/nimrod.ini index 3f820e5054..ea98c743b7 100755 --- a/compiler/nimrod.ini +++ b/compiler/nimrod.ini @@ -2,7 +2,7 @@ Name: "Nimrod" Version: "$version" ; Windows and i386 must be first! -OS: "windows;linux;macosx;freebsd;netbsd;openbsd;solaris" +OS: "windows;linux;macosx;solaris;freebsd;netbsd;openbsd" CPU: "i386;amd64;powerpc64;arm" # ;sparc Authors: "Andreas Rumpf" Description: """This is the Nimrod Compiler. Nimrod is a new statically typed, diff --git a/compiler/pragmas.nim b/compiler/pragmas.nim index e5854d93de..65574e80eb 100755 --- a/compiler/pragmas.nim +++ b/compiler/pragmas.nim @@ -12,7 +12,7 @@ import os, platform, condsyms, ast, astalgo, idents, semdata, msgs, renderer, wordrecg, ropes, options, strutils, lists, extccomp, math, magicsys, trees, - rodread + rodread, types const FirstCallConv* = wNimcall @@ -24,7 +24,7 @@ const wCompilerProc, wProcVar, wDeprecated, wVarargs, wCompileTime, wMerge, wBorrow, wExtern, wImportCompilerProc, wThread, wImportCpp, wImportObjC, wNoStackFrame, wError, wDiscardable, wNoInit, wDestructor, wHoist, - wGenSym, wInject} + wGenSym, wInject, wRaises} converterPragmas* = procPragmas methodPragmas* = procPragmas templatePragmas* = {wImmediate, wDeprecated, wError, wGenSym, wInject, wDirty} @@ -33,7 +33,7 @@ const wImportcpp, wImportobjc, wError, wDiscardable, wGenSym, wInject} iteratorPragmas* = {FirstCallConv..LastCallConv, wNosideEffect, wSideEffect, wImportc, wExportc, wNodecl, wMagic, wDeprecated, wBorrow, wExtern, - wImportcpp, wImportobjc, wError, wDiscardable, wGenSym, wInject} + wImportcpp, wImportobjc, wError, wDiscardable, wGenSym, wInject, wRaises} exprPragmas* = {wLine} stmtPragmas* = {wChecks, wObjChecks, wFieldChecks, wRangechecks, wBoundchecks, wOverflowchecks, wNilchecks, wAssertions, wWarnings, wHints, @@ -44,7 +44,8 @@ const wLinearScanEnd, wPatterns, wEffects} lambdaPragmas* = {FirstCallConv..LastCallConv, wImportc, wExportc, wNodecl, wNosideEffect, wSideEffect, wNoreturn, wDynLib, wHeader, - wDeprecated, wExtern, wThread, wImportcpp, wImportobjc, wNoStackFrame} + wDeprecated, wExtern, wThread, wImportcpp, wImportobjc, wNoStackFrame, + wRaises} typePragmas* = {wImportc, wExportc, wDeprecated, wMagic, wAcyclic, wNodecl, wPure, wHeader, wCompilerProc, wFinal, wSize, wExtern, wShallow, wImportcpp, wImportobjc, wError, wIncompleteStruct, wByCopy, wByRef, @@ -59,7 +60,7 @@ const wExtern, wImportcpp, wImportobjc, wError, wGenSym, wInject} letPragmas* = varPragmas procTypePragmas* = {FirstCallConv..LastCallConv, wVarargs, wNosideEffect, - wThread} + wThread, wRaises} allRoutinePragmas* = procPragmas + iteratorPragmas + lambdaPragmas proc pragma*(c: PContext, sym: PSym, n: PNode, validPragmas: TSpecialWords) @@ -463,6 +464,22 @@ proc processPragma(c: PContext, n: PNode, i: int) = userPragma.ast = body StrTableAdd(c.userPragmas, userPragma) +proc pragmaRaises(c: PContext, n: PNode) = + proc processExc(c: PContext, x: PNode) = + var t = skipTypes(c.semTypeNode(c, x, nil), skipPtrs) + if t.kind != tyObject: + localError(x.info, errGenerated, "invalid exception type") + x.typ = t + + if n.kind == nkExprColonExpr: + let it = n.sons[1] + if it.kind notin {nkCurly, nkBracket}: + processExc(c, it) + else: + for e in items(it): processExc(c, e) + else: + invalidPragma(n) + proc pragma(c: PContext, sym: PSym, n: PNode, validPragmas: TSpecialWords) = if n == nil: return for i in countup(0, sonsLen(n) - 1): @@ -679,6 +696,7 @@ proc pragma(c: PContext, sym: PSym, n: PNode, validPragmas: TSpecialWords) = noVal(it) if sym == nil: invalidPragma(it) of wLine: PragmaLine(c, it) + of wRaises: pragmaRaises(c, it) else: invalidPragma(it) else: invalidPragma(it) else: processNote(c, it) diff --git a/compiler/sem.nim b/compiler/sem.nim index 21bbdf4d26..93d0238065 100755 --- a/compiler/sem.nim +++ b/compiler/sem.nim @@ -208,6 +208,7 @@ proc myOpen(module: PSym, filename: string): PPassContext = c.semExpr = semExprNoFlags c.semConstBoolExpr = semConstBoolExpr c.semOverloadedCall = semOverloadedCall + c.semTypeNode = semTypeNode pushProcCon(c, module) pushOwner(c.module) openScope(c.tab) # scope for imported symbols diff --git a/compiler/semdata.nim b/compiler/semdata.nim index fe6f43f448..57721bdc0c 100755 --- a/compiler/semdata.nim +++ b/compiler/semdata.nim @@ -78,6 +78,7 @@ type semConstBoolExpr*: proc (c: PContext, n: PNode): PNode {.nimcall.} # XXX bite the bullet semOverloadedCall*: proc (c: PContext, n, nOrig: PNode, filter: TSymKinds): PNode {.nimcall.} + semTypeNode*: proc(c: PContext, n: PNode, prev: PType): PType {.nimcall.} includedFiles*: TIntSet # used to detect recursive include files filename*: string # the module's filename userPragmas*: TStrTable diff --git a/compiler/sempass2.nim b/compiler/sempass2.nim index bdc4e7028f..89d8d45d88 100644 --- a/compiler/sempass2.nim +++ b/compiler/sempass2.nim @@ -8,7 +8,8 @@ # import - ast, astalgo, msgs, renderer, magicsys, types, idents, trees, wordrecg + intsets, ast, astalgo, msgs, renderer, magicsys, types, idents, trees, + wordrecg # Second semantic checking pass over the AST. Necessary because the old # way had some inherent problems. Performs: @@ -48,8 +49,6 @@ when false: proc sem2call(c: PContext, n: PNode): PNode = assert n.kind in nkCallKinds - - proc sem2sym(c: PContext, n: PNode): PNode = assert n.kind == nkSym @@ -97,16 +96,17 @@ proc excType(n: PNode): PType = else: n.sons[0].typ result = skipTypes(t, skipPtrs) -proc addEffect(a: PEffects, e: PNode) = +proc addEffect(a: PEffects, e: PNode, useLineInfo=true) = assert e.kind == nkRaiseStmt var aa = a.exc for i in a.bottom ..