diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2018-06-11 01:25:48 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2018-06-11 01:25:48 +0200 |
commit | 61d92920956dc8ebd83017b23def63dbb4aa3c76 (patch) | |
tree | 359352303c36b13a47ec506a8b0b6a9ee417284a /compiler | |
parent | 61e189792220b7eb3b6a6b2ac543c6de84862aae (diff) | |
parent | 5f2cdcd4fa0f3d5dd0156026c0685aa59d9f7f92 (diff) | |
download | Nim-61d92920956dc8ebd83017b23def63dbb4aa3c76.tar.gz |
fixes merge conflict
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/ccgtypes.nim | 2 | ||||
-rw-r--r-- | compiler/cgen.nim | 10 | ||||
-rw-r--r-- | compiler/semstmts.nim | 2 | ||||
-rw-r--r-- | compiler/sighashes.nim | 25 |
4 files changed, 24 insertions, 15 deletions
diff --git a/compiler/ccgtypes.nim b/compiler/ccgtypes.nim index d0433f9ae..82508e37e 100644 --- a/compiler/ccgtypes.nim +++ b/compiler/ccgtypes.nim @@ -731,8 +731,6 @@ proc getTypeDescAux(m: BModule, origTyp: PType, check: var IntSet): Rope = else: addAbiCheck(m, t, result) of tyObject, tyTuple: if isImportedCppType(t) and origTyp.kind == tyGenericInst: - # for instantiated templates we do not go through the type cache as the - # the type cache is not aware of 'tyGenericInst'. let cppName = getTypeName(m, t, sig) var i = 0 var chunkStart = 0 diff --git a/compiler/cgen.nim b/compiler/cgen.nim index c66b25b00..ee60e62d2 100644 --- a/compiler/cgen.nim +++ b/compiler/cgen.nim @@ -1036,14 +1036,19 @@ proc genMainProc(m: BModule) = "}$N$N" GenodeNimMain = - "Libc::Env *genodeEnv;$N" & + "extern Genode::Env *nim_runtime_env;$N" & + "extern void nim_component_construct(Genode::Env*);$N$N" & NimMainBody ComponentConstruct = "void Libc::Component::construct(Libc::Env &env) {$N" & - "\tgenodeEnv = &env;$N" & + "\t// Set Env used during runtime initialization$N" & + "\tnim_runtime_env = &env;$N" & "\tLibc::with_libc([&] () {$N\t" & + "\t// Initialize runtime and globals$N" & MainProcs & + "\t// Call application construct$N" & + "\t\tnim_component_construct(&env);$N" & "\t});$N" & "}$N$N" @@ -1060,6 +1065,7 @@ proc genMainProc(m: BModule) = elif m.config.target.targetOS == osGenode: nimMain = GenodeNimMain otherMain = ComponentConstruct + m.includeHeader("<libc/component.h>") elif optGenDynLib in m.config.globalOptions: nimMain = PosixNimDllMain otherMain = PosixCDllMain diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index 0e143e7c1..af853ec52 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -496,7 +496,7 @@ proc semVarOrLet(c: PContext, n: PNode, symkind: TSymKind): PNode = def = fitNode(c, typ, def, def.info) #changeType(def.skipConv, typ, check=true) else: - typ = skipIntLit(def.typ) + typ = def.typ.skipTypes({tyStatic}).skipIntLit if typ.kind in tyUserTypeClasses and typ.isResolvedUserTypeClass: typ = typ.lastSon if hasEmpty(typ): diff --git a/compiler/sighashes.nim b/compiler/sighashes.nim index 46b83c386..0b95387cd 100644 --- a/compiler/sighashes.nim +++ b/compiler/sighashes.nim @@ -12,7 +12,7 @@ import ast, md5, tables, ropes from hashes import Hash from astalgo import debug -from types import typeToString, preferDesc +import types from strutils import startsWith, contains when false: @@ -148,19 +148,23 @@ proc hashType(c: var MD5Context, t: PType; flags: set[ConsiderFlag]) = of tyGenericInvocation: for i in countup(0, sonsLen(t) - 1): c.hashType t.sons[i], flags - return of tyDistinct: if CoType in flags: c.hashType t.lastSon, flags else: c.hashSym(t.sym) - return - of tyAlias, tySink, tyGenericInst, tyUserTypeClasses: + of tyGenericInst: + if sfInfixCall in t.base.sym.flags: + # This is an imported C++ generic type. + # We cannot trust the `lastSon` to hold a properly populated and unique + # value for each instantiation, so we hash the generic parameters here: + let normalizedType = t.skipGenericAlias + for i in 0 .. normalizedType.len - 2: + c.hashType t.sons[i], flags + else: + c.hashType t.lastSon, flags + of tyAlias, tySink, tyUserTypeClasses: c.hashType t.lastSon, flags - return - else: - discard - case t.kind of tyBool, tyChar, tyInt..tyUInt64: # no canonicalization for integral types, so that e.g. ``pid_t`` is # produced instead of ``NI``: @@ -168,11 +172,12 @@ proc hashType(c: var MD5Context, t: PType; flags: set[ConsiderFlag]) = if t.sym != nil and {sfImportc, sfExportc} * t.sym.flags != {}: c.hashSym(t.sym) of tyObject, tyEnum: - c &= char(t.kind) if t.typeInst != nil: assert t.typeInst.kind == tyGenericInst - for i in countup(1, sonsLen(t.typeInst) - 2): + for i in countup(0, sonsLen(t.typeInst) - 2): c.hashType t.typeInst.sons[i], flags + return + c &= char(t.kind) # Every cyclic type in Nim need to be constructed via some 't.sym', so this # is actually safe without an infinite recursion check: if t.sym != nil: |