diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2015-08-25 10:54:05 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2015-08-25 10:54:05 +0200 |
commit | 5cfce2623b0ba1fba0085881c3e1cc42912a5225 (patch) | |
tree | 59e17aee6873104de39fa9796fb27b7045687fcd /compiler | |
parent | 3a01eab4df76e24b67ea62337411a23bc5987e28 (diff) | |
parent | 24ad2cb39247039c50db1b0a8633d00130814fda (diff) | |
download | Nim-5cfce2623b0ba1fba0085881c3e1cc42912a5225.tar.gz |
Merge pull request #3160 from r-ku/coroutines
Coroutines
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/commands.nim | 4 | ||||
-rw-r--r-- | compiler/extccomp.nim | 49 | ||||
-rw-r--r-- | compiler/msgs.nim | 4 | ||||
-rw-r--r-- | compiler/pragmas.nim | 2 |
4 files changed, 57 insertions, 2 deletions
diff --git a/compiler/commands.nim b/compiler/commands.nim index fc28577aa..dba117516 100644 --- a/compiler/commands.nim +++ b/compiler/commands.nim @@ -612,6 +612,10 @@ proc processSwitch(switch, arg: string, pass: TCmdLinePass, info: TLineInfo) = of "experimental": expectNoArg(switch, arg, pass, info) gExperimentalMode = true + of "assembler": + cAssembler = nameToCC(arg) + if cAssembler notin cValidAssemblers: + localError(info, errGenerated, "'$1' is not a valid assembler." % [arg]) else: if strutils.find(switch, '.') >= 0: options.setConfigVar(switch, arg) else: invalidCmdLineOption(pass, switch, info) diff --git a/compiler/extccomp.nim b/compiler/extccomp.nim index 44a13e2f4..683de67e0 100644 --- a/compiler/extccomp.nim +++ b/compiler/extccomp.nim @@ -19,7 +19,7 @@ import type TSystemCC* = enum ccNone, ccGcc, ccLLVM_Gcc, ccCLang, ccLcc, ccBcc, ccDmc, ccWcc, ccVcc, - ccTcc, ccPcc, ccUcc, ccIcl + ccTcc, ccPcc, ccUcc, ccIcl, asmFasm TInfoCCProp* = enum # properties of the C compiler: hasSwitchRange, # CC allows ranges in switch statements (GNU C) hasComputedGoto, # CC has computed goto (GNU C extension) @@ -318,6 +318,31 @@ compiler ucc: packedPragma: "", # XXX: not supported yet props: {}) +# fasm assembler +compiler fasm: + result = ( + name: "fasm", + objExt: "o", + optSpeed: "", + optSize: "", + compilerExe: "fasm", + cppCompiler: "fasm", + compileTmpl: "$file $objfile", + buildGui: "", + buildDll: "", + buildLib: "", + linkerExe: "", + linkTmpl: "", + includeCmd: "", + linkDirCmd: "", + linkLibCmd: "", + debug: "", + pic: "", + asmStmtFrmt: "", + structStmtFmt: "", + packedPragma: "", + props: {}) + const CC*: array[succ(low(TSystemCC))..high(TSystemCC), TInfoCC] = [ gcc(), @@ -331,17 +356,22 @@ const tcc(), pcc(), ucc(), - icl()] + icl(), + fasm()] hExt* = ".h" var cCompiler* = ccGcc # the used compiler + cAssembler* = ccNone gMixedMode*: bool # true if some module triggered C++ codegen cIncludes*: seq[string] = @[] # directories to search for included files cLibs*: seq[string] = @[] # directories to search for lib files cLinkedLibs*: seq[string] = @[] # libraries to link +const + cValidAssemblers* = {asmFasm} + # implementation proc libNameTmpl(): string {.inline.} = @@ -527,6 +557,21 @@ proc getLinkerExe(compiler: TSystemCC): string = proc getCompileCFileCmd*(cfilename: string, isExternal = false): string = var c = cCompiler + if cfilename.endswith(".asm"): + var customAssembler = getConfigVar("assembler") + if customAssembler.len > 0: + c = nameToCC(customAssembler) + else: + if targetCPU == cpuI386 or targetCPU == cpuAmd64: + c = asmFasm + else: + c = ccNone + + if c == ccNone: + rawMessage(errExternalAssemblerNotFound, "") + elif c notin cValidAssemblers: + rawMessage(errExternalAssemblerNotValid, customAssembler) + var options = cFileSpecificOptions(cfilename) var exe = getConfigVar(c, ".exe") if exe.len == 0: exe = c.getCompilerExe diff --git a/compiler/msgs.nim b/compiler/msgs.nim index 9bff6c123..1b1f0a76e 100644 --- a/compiler/msgs.nim +++ b/compiler/msgs.nim @@ -108,6 +108,8 @@ type errCannotInferReturnType, errGenericLambdaNotAllowed, errCompilerDoesntSupportTarget, + errExternalAssemblerNotFound, + errExternalAssemblerNotValid, errUser, warnCannotOpenFile, warnOctalEscape, warnXIsNeverRead, warnXmightNotBeenInit, @@ -371,6 +373,8 @@ const "it is used as an operand to another routine and the types " & "of the generic paramers can be inferred from the expected signature.", errCompilerDoesntSupportTarget: "The current compiler \'$1\' doesn't support the requested compilation target", + errExternalAssemblerNotFound: "External assembler not found", + errExternalAssemblerNotValid: "External assembler '$1' is not a valid assembler", errUser: "$1", warnCannotOpenFile: "cannot open \'$1\'", warnOctalEscape: "octal escape sequences do not exist; leading zero is ignored", diff --git a/compiler/pragmas.nim b/compiler/pragmas.nim index 128a90138..5f317ed24 100644 --- a/compiler/pragmas.nim +++ b/compiler/pragmas.nim @@ -395,6 +395,8 @@ proc processCompile(c: PContext, n: PNode) = var found = findFile(s) if found == "": found = s var trunc = changeFileExt(found, "") + if not isAbsolute(found): + found = parentDir(n.info.toFullPath) / found extccomp.addExternalFileToCompile(found) extccomp.addFileToLink(completeCFilePath(trunc, false)) |