about summary refs log tree commit diff stats
path: root/src
Commit message (Expand)AuthorAgeFilesLines
...
* Add StyledNode stringifier for debuggingbptato2023-07-081-0/+14
* Fix toHex weirdnessbptato2023-07-072-11/+11
* layout: refactor table layoutbptato2023-07-072-92/+109
* layout: show [img] instead of image urlbptato2023-07-071-1/+1
* url: fix empty hostnames being acceptedbptato2023-07-071-1/+1
* Fixes in ipv6 parser and serializerbptato2023-07-072-14/+30
* Add separate type for premultiplied colorbptato2023-07-071-10/+16
* color: replace straight alpha table with bit shifting magicbptato2023-07-061-14/+11
* term: fix ANSI color approximationbptato2023-07-062-11/+8
* select: simplify popCursorPos()bptato2023-07-061-3/+1
* decoderstream: fix incorrect Big5 decodingbptato2023-07-061-4/+4
* Fix regression in twidthbptato2023-07-061-3/+3
* Add popup menu for select elementbptato2023-07-056-192/+627
* js: remove unused functionbptato2023-07-051-4/+0
* dom: work around bad codegenbptato2023-07-041-4/+6
* png: print zstream errorsbptato2023-07-041-1/+5
* painter: fix off by one error in getCharBmpbptato2023-07-041-2/+2
* Add utf-8 support to libregexpbptato2023-07-041-96/+10
* Add libregexp header to libregexp bindingbptato2023-07-042-15/+12
* dom: add NodeType consts to Nodebptato2023-07-042-1/+1
* Event: add some properties, js: add defineConstsbptato2023-07-042-3/+35
* Fix bug in media-query parsingbptato2023-07-044-32/+61
* Fix table cellspacing not being counted in row widthbptato2023-07-041-0/+7
* Add proxy supportbptato2023-07-045-25/+64
* pager: do not store jsctxbptato2023-07-041-12/+12
* calculateErrorY: fix regression by using intbptato2023-07-041-2/+2
* Use LayoutUnit in layoutbptato2023-07-046-152/+242
* Do not conditionally disable CastSizesbptato2023-07-032-12/+2
* htmltokenizer: fix regressionbptato2023-07-031-0/+3
* Fix JS type conversion regressionsbptato2023-07-034-16/+27
* nim_finalize_for_js: use withValuebptato2023-07-031-2/+2
* tokenizer: fix unreachable code warningbptato2023-07-031-1/+0
* Fix CastSize warningsbptato2023-07-038-21/+31
* Fix compilation failurebptato2023-07-031-1/+2
* Add XHR/Event stubsbptato2023-07-026-8/+80
* FormData fixesbptato2023-07-022-7/+22
* Use or type for FormData.appendbptato2023-07-021-30/+8
* Add platform object conversion to union typebptato2023-07-023-20/+67
* return Result[T, JSError] from fromJSbptato2023-07-0210-131/+129
* Add finalizer to WebFilebptato2023-07-021-0/+6
* fromJSObject: throw on invalid object classbptato2023-07-021-12/+24
* Remove outdated commentbptato2023-07-021-7/+0
* Cache Node.children, Node.childNodesbptato2023-07-011-4/+23
* Factor out headers into separate modulebptato2023-07-0112-61/+77
* Use separate flag for adding getset instead of reprbptato2023-07-012-6/+6
* use =destroy instead of finalizersbptato2023-07-0116-3/+98
* png: fix grayscale regressionbptato2023-06-291-1/+1
* dom: synchronously load scriptsbptato2023-06-291-17/+13
* Add assign, replace, reload to locationbptato2023-06-291-1/+13
* Add window.locationbptato2023-06-296-67/+245
"nf">importPureEnumField*(c: PContext; s: PSym) = let check = strTableGet(c.importTable.symbols, s.name) if check == nil: let checkB = strTableGet(c.pureEnumFields, s.name) if checkB == nil: strTableAdd(c.pureEnumFields, s) else: # mark as ambigous: incl(c.ambiguousSymbols, checkB.id) incl(c.ambiguousSymbols, s.id) proc rawImportSymbol(c: PContext, s: PSym) = # This does not handle stubs, because otherwise loading on demand would be # pointless in practice. So importing stubs is fine here! # check if we have already a symbol of the same name: var check = strTableGet(c.importTable.symbols, s.name) if check != nil and check.id != s.id: if s.kind notin OverloadableSyms or check.kind notin OverloadableSyms: # s and check need to be qualified: incl(c.ambiguousSymbols, s.id) incl(c.ambiguousSymbols, check.id) # thanks to 'export' feature, it could be we import the same symbol from # multiple sources, so we need to call 'StrTableAdd' here: strTableAdd(c.importTable.symbols, s) if s.kind == skType: var etyp = s.typ if etyp.kind in {tyBool, tyEnum}: for j in countup(0, sonsLen(etyp.n) - 1): var e = etyp.n.sons[j].sym if e.kind != skEnumField: internalError(c.config, s.info, "rawImportSymbol") # BUGFIX: because of aliases for enums the symbol may already # have been put into the symbol table # BUGFIX: but only iff they are the same symbols! var it: TIdentIter check = initIdentIter(it, c.importTable.symbols, e.name) while check != nil: if check.id == e.id: e = nil break check = nextIdentIter(it, c.importTable.symbols) if e != nil: if sfPure notin s.flags: rawImportSymbol(c, e) else: importPureEnumField(c, e) else: # rodgen assures that converters and patterns are no stubs if s.kind == skConverter: addConverter(c, s) if hasPattern(s): addPattern(c, s) proc importSymbol(c: PContext, n: PNode, fromMod: PSym) = let ident = lookups.considerQuotedIdent(c, n) let s = strTableGet(fromMod.tab, ident) if s == nil: errorUndeclaredIdentifier(c, n.info, ident.s) else: when false: if s.kind == skStub: loadStub(s) if s.kind notin ExportableSymKinds: internalError(c.config, n.info, "importSymbol: 2") # for an enumeration we have to add all identifiers case s.kind of skProcKinds: # for a overloadable syms add all overloaded routines var it: TIdentIter var e = initIdentIter(it, fromMod.tab, s.name) while e != nil: if e.name.id != s.name.id: internalError(c.config, n.info, "importSymbol: 3") rawImportSymbol(c, e) e = nextIdentIter(it, fromMod.tab) else: rawImportSymbol(c, s) proc importAllSymbolsExcept(c: PContext, fromMod: PSym, exceptSet: IntSet) = var i: TTabIter var s = initTabIter(i, fromMod.tab) while s != nil: if s.kind != skModule: if s.kind != skEnumField: if s.kind notin ExportableSymKinds: internalError(c.config, s.info, "importAllSymbols: " & $s.kind) if exceptSet.isNil or s.name.id notin exceptSet: rawImportSymbol(c, s) s = nextIter(i, fromMod.tab) proc importAllSymbols*(c: PContext, fromMod: PSym) = var exceptSet: IntSet importAllSymbolsExcept(c, fromMod, exceptSet) proc importForwarded(c: PContext, n: PNode, exceptSet: IntSet) = if n.isNil: return case n.kind of nkExportStmt: for a in n: assert a.kind == nkSym let s = a.sym if s.kind == skModule: importAllSymbolsExcept(c, s, exceptSet) elif exceptSet.isNil or s.name.id notin exceptSet: rawImportSymbol(c, s) of nkExportExceptStmt: localError(c.config, n.info, "'export except' not implemented") else: for i in 0..safeLen(n)-1: importForwarded(c, n.sons[i], exceptSet) proc importModuleAs(c: PContext; n: PNode, realModule: PSym): PSym = result = realModule if n.kind != nkImportAs: discard elif n.len != 2 or n.sons[1].kind != nkIdent: localError(c.config, n.info, "module alias must be an identifier") elif n.sons[1].ident.id != realModule.name.id: # some misguided guy will write 'import abc.foo as foo' ... result = createModuleAlias(realModule, n.sons[1].ident, realModule.info, c.config.options) proc myImportModule(c: PContext, n: PNode; importStmtResult: PNode): PSym = let f = checkModuleName(c.config, n) if f != InvalidFileIDX: let L = c.graph.importStack.len let recursion = c.graph.importStack.find(f) c.graph.importStack.add f #echo "adding ", toFullPath(f), " at ", L+1 if recursion >= 0: var err = "" for i in countup(recursion, L-1): if i > recursion: err.add "\n" err.add toFullPath(c.config, c.graph.importStack[i]) & " imports " & toFullPath(c.config, c.graph.importStack[i+1]) c.recursiveDep = err result = importModuleAs(c, n, c.graph.importModuleCallback(c.graph, c.module, f)) #echo "set back to ", L c.graph.importStack.setLen(L) # we cannot perform this check reliably because of # test: modules/import_in_config) when true: if result.info.fileIndex == c.module.info.fileIndex and result.info.fileIndex == n.info.fileIndex: localError(c.config, n.info, "A module cannot import itself") if sfDeprecated in result.flags: if result.constraint != nil: message(c.config, n.info, warnDeprecated, result.constraint.strVal & "; " & result.name.s) else: message(c.config, n.info, warnDeprecated, result.name.s) suggestSym(c.config, n.info, result, c.graph.usageSym, false) importStmtResult.add newSymNode(result, n.info) #newStrNode(toFullPath(c.config, f), n.info) proc transformImportAs(c: PContext; n: PNode): PNode = if n.kind == nkInfix and considerQuotedIdent(c, n[0]).s == "as": result = newNodeI(nkImportAs, n.info) result.add n.sons[1] result.add n.sons[2] else: result = n proc impMod(c: PContext; it: PNode; importStmtResult: PNode) = let it = transformImportAs(c, it) let m = myImportModule(c, it, importStmtResult) if m != nil: var emptySet: IntSet # ``addDecl`` needs to be done before ``importAllSymbols``! addDecl(c, m, it.info) # add symbol to symbol table of module importAllSymbolsExcept(c, m, emptySet) #importForwarded(c, m.ast, emptySet) proc evalImport*(c: PContext, n: PNode): PNode = result = newNodeI(nkImportStmt, n.info) for i in countup(0, sonsLen(n) - 1): let it = n.sons[i] if it.kind == nkInfix and it.len == 3 and it[2].kind == nkBracket: let sep = it[0] let dir = it[1] var imp = newNodeI(nkInfix, it.info) imp.add sep imp.add dir imp.add sep # dummy entry, replaced in the loop for x in it[2]: # transform `a/b/[c as d]` to `/a/b/c as d` if x.kind == nkInfix and x.sons[0].ident.s == "as": let impAs = copyTree(x) imp.sons[2] = x.sons[1] impAs.sons[1] = imp impMod(c, imp, result) else: imp.sons[2] = x impMod(c, imp, result) else: impMod(c, it, result) proc evalFrom*(c: PContext, n: PNode): PNode = result = newNodeI(nkImportStmt, n.info) checkMinSonsLen(n, 2, c.config) n.sons[0] = transformImportAs(c, n.sons[0]) var m = myImportModule(c, n.sons[0], result) if m != nil: n.sons[0] = newSymNode(m) addDecl(c, m, n.info) # add symbol to symbol table of module for i in countup(1, sonsLen(n) - 1): if n.sons[i].kind != nkNilLit: importSymbol(c, n.sons[i], m) proc evalImportExcept*(c: PContext, n: PNode): PNode = result = newNodeI(nkImportStmt, n.info) checkMinSonsLen(n, 2, c.config) n.sons[0] = transformImportAs(c, n.sons[0]) var m = myImportModule(c, n.sons[0], result) if m != nil: n.sons[0] = newSymNode(m) addDecl(c, m, n.info) # add symbol to symbol table of module importAllSymbolsExcept(c, m, readExceptSet(c, n)) #importForwarded(c, m.ast, exceptSet)