implemented incompleteStruct pragma; embedded debugger works with posix module
This commit is contained in:
parent
9152193e41
commit
8aa4e46707
19 changed files with 85 additions and 47 deletions
|
|
@ -339,6 +339,7 @@ type
|
|||
const
|
||||
routineKinds* = {skProc, skMethod, skIterator, skConverter,
|
||||
skMacro, skTemplate}
|
||||
tfIncompleteStruct* = tfVarargs
|
||||
|
||||
type
|
||||
TMagic* = enum # symbols that require compiler magic:
|
||||
|
|
|
|||
|
|
@ -241,8 +241,8 @@ proc typeNameOrLiteral(t: PType, literal: string): PRope =
|
|||
|
||||
proc getSimpleTypeDesc(m: BModule, typ: PType): PRope =
|
||||
const
|
||||
NumericalTypeToStr: array[tyInt..tyFloat128, string] = ["NI", "NI8", "NI16",
|
||||
"NI32", "NI64", "NF", "NF32", "NF64", "NF128"]
|
||||
NumericalTypeToStr: array[tyInt..tyFloat128, string] = ["NI", "NI8",
|
||||
"NI16", "NI32", "NI64", "NF", "NF32", "NF64", "NF128"]
|
||||
case typ.Kind
|
||||
of tyPointer:
|
||||
result = typeNameOrLiteral(typ, "void*")
|
||||
|
|
@ -301,7 +301,8 @@ proc mangleRecFieldName(field: PSym, rectype: PType): PRope =
|
|||
result = toRope(mangle(field.name.s))
|
||||
if result == nil: InternalError(field.info, "mangleRecFieldName")
|
||||
|
||||
proc genRecordFieldsAux(m: BModule, n: PNode, accessExpr: PRope, rectype: PType,
|
||||
proc genRecordFieldsAux(m: BModule, n: PNode,
|
||||
accessExpr: PRope, rectype: PType,
|
||||
check: var TIntSet): PRope =
|
||||
var
|
||||
ae, uname, sname, a: PRope
|
||||
|
|
@ -560,9 +561,13 @@ proc genTypeInfoAuxBase(m: BModule, typ: PType, name, base: PRope) =
|
|||
nimtypeKind = ord(tyPureObject)
|
||||
else:
|
||||
nimtypeKind = ord(typ.kind)
|
||||
|
||||
var size: PRope
|
||||
if tfIncompleteStruct in typ.flags: size = toRope"void*"
|
||||
else: size = getTypeDesc(m, typ)
|
||||
appf(m.s[cfsTypeInit3],
|
||||
"$1->size = sizeof($2);$n" & "$1->kind = $3;$n" & "$1->base = $4;$n",
|
||||
[name, getTypeDesc(m, typ), toRope(nimtypeKind), base])
|
||||
[name, size, toRope(nimtypeKind), base])
|
||||
# compute type flags for GC optimization
|
||||
var flags = 0
|
||||
if not containsGarbageCollectedRef(typ): flags = flags or 1
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ proc GetUniqueType*(key: PType): PType =
|
|||
result = GetUniqueType(lastSon(key))
|
||||
of tyArrayConstr, tyGenericInvokation, tyGenericBody, tyGenericParam,
|
||||
tyOpenArray, tyArray, tyTuple, tySet, tyRange,
|
||||
tyPtr, tyRef, tySequence, tyForward, tyVarargs, tyProxy:
|
||||
tyPtr, tyRef, tySequence, tyForward, tyVarargs, tyProxy, tyVar:
|
||||
# we have to do a slow linear search because types may need
|
||||
# to be compared by their structure:
|
||||
if IdTableHasObjectAsKey(gTypeTable[k], key): return key
|
||||
|
|
@ -121,8 +121,8 @@ proc GetUniqueType*(key: PType): PType =
|
|||
if result == nil:
|
||||
IdTablePut(gTypeTable[k], key, key)
|
||||
result = key
|
||||
of tyProc, tyVar:
|
||||
# tyVar is not 100% correct, but speeds things up a little:
|
||||
of tyProc:
|
||||
# tyVar is not 100% correct, but would speeds things up a little:
|
||||
result = key
|
||||
|
||||
proc TableGetType*(tab: TIdTable, key: PType): PObject =
|
||||
|
|
|
|||
|
|
@ -383,8 +383,8 @@ proc assignLocalVar(p: BProc, s: PSym) =
|
|||
if s.kind == skLet: incl(s.loc.flags, lfNoDeepCopy)
|
||||
app(p.s[cpsLocals], getTypeDesc(p.module, s.loc.t))
|
||||
if sfRegister in s.flags: app(p.s[cpsLocals], " register")
|
||||
elif skipTypes(s.typ, abstractInst).kind in GcTypeKinds:
|
||||
app(p.s[cpsLocals], " GC_GUARD")
|
||||
#elif skipTypes(s.typ, abstractInst).kind in GcTypeKinds:
|
||||
# app(p.s[cpsLocals], " GC_GUARD")
|
||||
if (sfVolatile in s.flags) or (p.nestedTryStmts.len > 0):
|
||||
app(p.s[cpsLocals], " volatile")
|
||||
appf(p.s[cpsLocals], " $1;$n", [s.loc.r])
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ const
|
|||
wDeprecated, wExtern, wThread, wImportcpp, wImportobjc, wNoStackFrame}
|
||||
typePragmas* = {wImportc, wExportc, wDeprecated, wMagic, wAcyclic, wNodecl,
|
||||
wPure, wHeader, wCompilerProc, wFinal, wSize, wExtern, wShallow,
|
||||
wImportcpp, wImportobjc, wError}
|
||||
wImportcpp, wImportobjc, wError, wIncompleteStruct}
|
||||
fieldPragmas* = {wImportc, wExportc, wDeprecated, wExtern,
|
||||
wImportcpp, wImportobjc, wError}
|
||||
varPragmas* = {wImportc, wExportc, wVolatile, wRegister, wThreadVar, wNodecl,
|
||||
|
|
@ -571,6 +571,10 @@ proc pragma(c: PContext, sym: PSym, n: PNode, validPragmas: TSpecialWords) =
|
|||
of wEmit: PragmaEmit(c, it)
|
||||
of wUnroll: PragmaUnroll(c, it)
|
||||
of wLinearScanEnd: PragmaLinearScanEnd(c, it)
|
||||
of wIncompleteStruct:
|
||||
noVal(it)
|
||||
if sym.typ == nil: invalidPragma(it)
|
||||
incl(sym.typ.flags, tfIncompleteStruct)
|
||||
else: invalidPragma(it)
|
||||
else: invalidPragma(it)
|
||||
else: processNote(c, it)
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ type
|
|||
wMagic, wThread, wFinal, wProfiler, wObjChecks,
|
||||
wImportCpp, wImportObjC,
|
||||
wImportCompilerProc,
|
||||
wImportc, wExportc, wExtern,
|
||||
wImportc, wExportc, wExtern, wIncompleteStruct,
|
||||
wAlign, wNodecl, wPure, wVolatile, wRegister, wSideeffect, wHeader,
|
||||
wNosideeffect, wNoreturn, wMerge, wLib, wDynlib, wCompilerproc, wProcVar,
|
||||
wFatal, wError, wWarning, wHint, wLine, wPush, wPop, wDefine, wUndef,
|
||||
|
|
@ -80,7 +80,7 @@ const
|
|||
"magic", "thread", "final", "profiler", "objchecks",
|
||||
|
||||
"importcpp", "importobjc",
|
||||
"importcompilerproc", "importc", "exportc", "extern",
|
||||
"importcompilerproc", "importc", "exportc", "extern", "incompletestruct",
|
||||
"align", "nodecl", "pure", "volatile", "register", "sideeffect",
|
||||
"header", "nosideeffect", "noreturn", "merge", "lib", "dynlib",
|
||||
"compilerproc", "procvar", "fatal", "error", "warning", "hint", "line",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue