Skip to content

Commit 0c42906

Browse files
committed
Add space after comma in name mangling
1 parent 4558515 commit 0c42906

File tree

3 files changed

+24
-26
lines changed

3 files changed

+24
-26
lines changed

design/mvp/CanonicalABI.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,7 +1442,7 @@ def mangle_funcvec(es):
14421442
return mangle_valtype(es[0])
14431443
assert(all(type(e) == tuple and len(e) == 2 for e in es))
14441444
mangled_elems = (e[0] + ':' + mangle_valtype(e[1]) for e in es)
1445-
return '(' + ','.join(mangled_elems) + ')'
1445+
return '(' + ', '.join(mangled_elems) + ')'
14461446

14471447
def mangle_valtype(t):
14481448
match t:
@@ -1471,29 +1471,29 @@ def mangle_valtype(t):
14711471

14721472
def mangle_recordtype(fields):
14731473
mangled_fields = (f.label + ':' + mangle_valtype(f.t) for f in fields)
1474-
return 'record{' + ','.join(mangled_fields) + '}'
1474+
return 'record{' + ', '.join(mangled_fields) + '}'
14751475

14761476
def mangle_tupletype(ts):
1477-
return 'tuple<' + ','.join(mangle_valtype(t) for t in ts) + '>'
1477+
return 'tuple<' + ', '.join(mangle_valtype(t) for t in ts) + '>'
14781478

14791479
def mangle_flags(labels):
1480-
return 'flags{' + ','.join(labels) + '}'
1480+
return 'flags{' + ', '.join(labels) + '}'
14811481

14821482
def mangle_varianttype(cases):
14831483
mangled_cases = (c.label + '(' + mangle_maybevaltype(c.t) + ')' for c in cases)
1484-
return 'variant{' + ','.join(mangled_cases) + '}'
1484+
return 'variant{' + ', '.join(mangled_cases) + '}'
14851485

14861486
def mangle_enumtype(labels):
1487-
return 'enum{' + ','.join(labels) + '}'
1487+
return 'enum{' + ', '.join(labels) + '}'
14881488

14891489
def mangle_uniontype(ts):
1490-
return 'union{' + ','.join(mangle_valtype(t) for t in ts) + '}'
1490+
return 'union{' + ', '.join(mangle_valtype(t) for t in ts) + '}'
14911491

14921492
def mangle_optiontype(t):
14931493
return 'option<' + mangle_valtype(t) + '>'
14941494

14951495
def mangle_resulttype(ok, error):
1496-
return 'result<' + mangle_maybevaltype(ok) + ',' + mangle_maybevaltype(error) + '>'
1496+
return 'result<' + mangle_maybevaltype(ok) + ', ' + mangle_maybevaltype(error) + '>'
14971497

14981498
def mangle_maybevaltype(t):
14991499
if t is None:
@@ -1516,7 +1516,7 @@ the `canonical_module_type` would be:
15161516
```wasm
15171517
(module
15181518
(import "" "foo: func () -> ()" (func))
1519-
(import "" "a.bar: func (x:u32,y:u32) -> u32" (func param i32 i32) (result i32))
1519+
(import "" "a.bar: func (x:u32, y:u32) -> u32" (func param i32 i32) (result i32))
15201520
(export "_memory" (memory 0))
15211521
(export "_realloc" (func (param i32 i32 i32 i32) (result i32)))
15221522
(export "_start{cabi=0.1}: func (v1:string) -> (v2:list<list<string>>)" (func (param i32 i32) (result i32)))

design/mvp/canonical-abi/definitions.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,9 +1089,7 @@ def mangle_funcvec(es):
10891089
return mangle_valtype(es[0])
10901090
assert(all(type(e) == tuple and len(e) == 2 for e in es))
10911091
mangled_elems = (e[0] + ':' + mangle_valtype(e[1]) for e in es)
1092-
return '(' + ','.join(mangled_elems) + ')'
1093-
1094-
#
1092+
return '(' + ', '.join(mangled_elems) + ')'
10951093

10961094
def mangle_valtype(t):
10971095
match t:
@@ -1120,29 +1118,29 @@ def mangle_valtype(t):
11201118

11211119
def mangle_recordtype(fields):
11221120
mangled_fields = (f.label + ':' + mangle_valtype(f.t) for f in fields)
1123-
return 'record{' + ','.join(mangled_fields) + '}'
1121+
return 'record{' + ', '.join(mangled_fields) + '}'
11241122

11251123
def mangle_tupletype(ts):
1126-
return 'tuple<' + ','.join(mangle_valtype(t) for t in ts) + '>'
1124+
return 'tuple<' + ', '.join(mangle_valtype(t) for t in ts) + '>'
11271125

11281126
def mangle_flags(labels):
1129-
return 'flags{' + ','.join(labels) + '}'
1127+
return 'flags{' + ', '.join(labels) + '}'
11301128

11311129
def mangle_varianttype(cases):
11321130
mangled_cases = (c.label + '(' + mangle_maybevaltype(c.t) + ')' for c in cases)
1133-
return 'variant{' + ','.join(mangled_cases) + '}'
1131+
return 'variant{' + ', '.join(mangled_cases) + '}'
11341132

11351133
def mangle_enumtype(labels):
1136-
return 'enum{' + ','.join(labels) + '}'
1134+
return 'enum{' + ', '.join(labels) + '}'
11371135

11381136
def mangle_uniontype(ts):
1139-
return 'union{' + ','.join(mangle_valtype(t) for t in ts) + '}'
1137+
return 'union{' + ', '.join(mangle_valtype(t) for t in ts) + '}'
11401138

11411139
def mangle_optiontype(t):
11421140
return 'option<' + mangle_valtype(t) + '>'
11431141

11441142
def mangle_resulttype(ok, error):
1145-
return 'result<' + mangle_maybevaltype(ok) + ',' + mangle_maybevaltype(error) + '>'
1143+
return 'result<' + mangle_maybevaltype(ok) + ', ' + mangle_maybevaltype(error) + '>'
11461144

11471145
def mangle_maybevaltype(t):
11481146
if t is None:

design/mvp/canonical-abi/run_tests.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -379,21 +379,21 @@ def test_mangle_functype(params, results, expect):
379379
test_mangle_functype([('x',U8())], [('y',U8())], 'func (x:u8) -> (y:u8)')
380380
test_mangle_functype([('a',Bool()),('b',U8()),('c',S16()),('d',U32()),('e',S64())],
381381
[('a',S8()),('b',U16()),('c',S32()),('d',U64())],
382-
'func (a:bool,b:u8,c:s16,d:u32,e:s64) -> (a:s8,b:u16,c:s32,d:u64)')
382+
'func (a:bool, b:u8, c:s16, d:u32, e:s64) -> (a:s8, b:u16, c:s32, d:u64)')
383383
test_mangle_functype([List(List(String()))], [],
384384
'func list<list<string>> -> ()')
385385
test_mangle_functype([Record([Field('x',Record([Field('y',String())])),Field('z',U32())])], [],
386-
'func record{x:record{y:string},z:u32} -> ()')
386+
'func record{x:record{y:string}, z:u32} -> ()')
387387
test_mangle_functype([Tuple([U8()])], [Tuple([U8(),U8()])],
388-
'func tuple<u8> -> tuple<u8,u8>')
388+
'func tuple<u8> -> tuple<u8, u8>')
389389
test_mangle_functype([Flags(['a','b'])], [Enum(['a','b'])],
390-
'func flags{a,b} -> enum{a,b}')
390+
'func flags{a, b} -> enum{a, b}')
391391
test_mangle_functype([Variant([Case('a',None),Case('b',U8())])], [Union([U8(),List(String())])],
392-
'func variant{a(_),b(u8)} -> union{u8,list<string>}')
392+
'func variant{a(_), b(u8)} -> union{u8, list<string>}')
393393
test_mangle_functype([Option(Bool())],[Option(List(U8()))],
394394
'func option<bool> -> option<list<u8>>')
395395
test_mangle_functype([], [('a',Result(None,None)),('b',Result(U8(),None)),('c',Result(None,U8()))],
396-
'func () -> (a:result<_,_>,b:result<u8,_>,c:result<_,u8>)')
396+
'func () -> (a:result<_, _>, b:result<u8, _>, c:result<_, u8>)')
397397

398398
def test_cabi(ct, expect):
399399
got = canonical_module_type(ct)
@@ -449,7 +449,7 @@ def test_cabi(ct, expect):
449449
),
450450
ModuleType(
451451
[CoreImportDecl('','foo: func () -> ()', CoreFuncType([],[])),
452-
CoreImportDecl('','a.bar: func (x:u32,y:u32) -> u32', CoreFuncType(['i32','i32'],['i32']))],
452+
CoreImportDecl('','a.bar: func (x:u32, y:u32) -> u32', CoreFuncType(['i32','i32'],['i32']))],
453453
[CoreExportDecl('_memory', CoreMemoryType(0, None)),
454454
CoreExportDecl('_realloc', CoreFuncType(['i32','i32','i32','i32'],['i32'])),
455455
CoreExportDecl('_start{cabi=0.1}: func (v1:string) -> (v2:list<list<string>>)',

0 commit comments

Comments
 (0)