Bug 1500926 - Part 2: Support a test-only edgecase in Codegen.py, r=bzbarsky

When running tests, we can build a WebIDL environment with no interfaces
exposed on the primary global. Unfortunately, due to the perfecthash.py logic
not handling empty tables, this causes an assertion to be raised. 

We can work around this by generating some dummy code for that situation, as we
will never try to build it.

Differential Revision: https://phabricator.services.mozilla.com/D9407
This commit is contained in:
Nika Layzell 2018-10-22 00:57:24 -04:00
Родитель 23c990d165
Коммит 65b231b95c
1 изменённых файлов: 9 добавлений и 0 удалений

Просмотреть файл

@ -13730,6 +13730,15 @@ class CGGlobalNames(CGGeneric):
entries.append((name, nativeEntry))
# Unfortunately, when running tests, we may have no entries.
# PerfectHash will assert if we give it an empty set of entries, so we
# just generate a dummy value.
if len(entries) == 0:
CGGeneric.__init__(self, define=dedent('''
static_assert(false, "No WebIDL global name entries!");
'''))
return
# Build the perfect hash function.
phf = PerfectHash(entries, GLOBAL_NAMES_PHF_SIZE)