@@ -249,8 +249,8 @@ def generate_structfile(device, filename, outprefix):
249
249
"%s(%s)" % (name ,
250
250
", " .join ((["conf_object_t *_obj" ]
251
251
* (not func .independent ))
252
- + [t . declaration ( n )
253
- for (n , t ) in (
252
+ + [decl
253
+ for (_ , _ , decl ) in (
254
254
func .cparams
255
255
if func .independent
256
256
else func .cparams [1 :])]))))
@@ -718,7 +718,7 @@ def wrap_method(meth, wrapper_name, indices=()):
718
718
is a port object
719
719
"""
720
720
721
- inparams = [t .declaration (p ) for p , t in meth .inp ]
721
+ inparams = [p .declaration () for p in meth .inp ]
722
722
if not meth .outp :
723
723
retvar = None
724
724
rettype = TVoid ()
@@ -749,7 +749,7 @@ def wrap_method(meth, wrapper_name, indices=()):
749
749
None , None , None )).toc ()
750
750
751
751
with LogFailure (meth .site , meth , indices ):
752
- inargs = [mkLit (meth .site , v , t ) for v , t in meth .inp ]
752
+ inargs = [mkLit (meth .site , p . c_ident , p . typ ) for p in meth .inp ]
753
753
outargs = [mkLit (meth .site , v , t ) for v , t in meth .outp ]
754
754
codegen_call (meth .site , meth ,
755
755
indices ,
@@ -804,10 +804,10 @@ def generate_implement_method(device, ifacestruct, meth, indices):
804
804
# currently impossible to implement a varargs interface
805
805
# method in DML
806
806
raise EMETH (meth .site , None , 'interface method is variadic' )
807
- for (( mp , mt ) , it ) in zip (meth .inp , iface_input_types ):
808
- if not safe_realtype_unconst (mt ).eq (safe_realtype_unconst (it )):
807
+ for (mp , it ) in zip (meth .inp , iface_input_types ):
808
+ if not safe_realtype_unconst (mp . typ ).eq (safe_realtype_unconst (it )):
809
809
raise EARGT (meth .site , 'implement' , meth .name ,
810
- mt , mp , it , 'method' )
810
+ mp . typ , mp . logref , it , 'method' )
811
811
if iface_num_outputs and dml .globals .dml_version != (1 , 2 ):
812
812
[(_ , mt )] = meth .outp
813
813
if not safe_realtype_unconst (mt ).eq (
@@ -1355,15 +1355,15 @@ def generate_events(device):
1355
1355
def generate_reg_callback (meth , name ):
1356
1356
dev_t = crep .structtype (dml .globals .device )
1357
1357
out ('static bool\n ' )
1358
- params = [t .declaration (p ) for p , t in meth .inp ] + [
1358
+ params = [p .declaration () for p in meth .inp ] + [
1359
1359
TPtr (t ).declaration (p ) for p , t in meth .outp ]
1360
1360
out ('%s(void *_obj, const uint16 *indices, ' % (name ,)
1361
1361
+ ', ' .join (params ) + ')\n ' )
1362
1362
out ('{\n ' , postindent = 1 )
1363
1363
out ('%s *_dev = _obj;\n ' % dev_t )
1364
1364
fail = ReturnFailure (meth .site )
1365
1365
with fail , crep .DeviceInstanceContext ():
1366
- inargs = [mkLit (meth .site , n , t ) for n , t in meth .inp ]
1366
+ inargs = [mkLit (meth .site , p . c_ident , p . typ ) for p in meth .inp ]
1367
1367
outargs = [mkLit (meth .site , "*" + n , t ) for n , t in meth .outp ]
1368
1368
code = [codegen_call (
1369
1369
meth .site , meth ,
@@ -2027,48 +2027,50 @@ def generate_init(device, initcode, outprefix):
2027
2027
def generate_static_trampoline (func ):
2028
2028
# static trampolines never need to be generated for independent methods
2029
2029
assert not func .independent
2030
- params = [("_obj" , TPtr (TNamed ("conf_object_t" )))] + func .cparams [1 :]
2031
- params_string = ('void' if not params
2032
- else ", " .join (t .declaration (n ) for (n , t ) in params ))
2030
+
2031
+ params_string = '' .join (", " + decl for (_ , _ , decl ) in func .cparams [1 :])
2033
2032
start_function_definition (func .rettype .declaration (
2034
- "%s(%s)" % ("_trampoline" + func .get_cname (), params_string )))
2033
+ "%s(conf_object_t *_obj%s)" % ("_trampoline" + func .get_cname (),
2034
+ params_string )))
2035
2035
out ("{\n " , postindent = 1 )
2036
2036
out ('ASSERT(_obj);\n ' )
2037
2037
out ('ASSERT(SIM_object_class(_obj) == _dev_class);\n ' )
2038
- (name , typ ) = func .cparams [0 ]
2039
- out ("%s = (%s)_obj;\n " % (typ . declaration ( name ) , typ .declaration ("" )))
2038
+ (name , typ , decl ) = func .cparams [0 ]
2039
+ out ("%s = (%s)_obj;\n " % (decl , typ .declaration ("" )))
2040
2040
out ("%s%s(%s);\n " % ("" if func .rettype .void
2041
2041
else func .rettype .declaration ("result" ) + " = " ,
2042
2042
func .get_cname (),
2043
- ", " .join (n for (n , t ) in func .cparams )))
2043
+ ", " .join (n for (n , _ , _ ) in func .cparams )))
2044
2044
output_dml_state_change (name )
2045
2045
if not func .rettype .void :
2046
2046
out ("return result;\n " )
2047
2047
out ("}\n " , preindent = - 1 )
2048
2048
2049
2049
def generate_extern_trampoline (exported_name , func ):
2050
- params = (func .cparams if func .independent else
2051
- [("_obj" , TPtr (TNamed ("conf_object_t" )))] + func .cparams [1 :])
2052
- params_string = ('void' if not params
2053
- else ", " .join (t .declaration (n ) for (n , t ) in params ))
2050
+ cparams = list (func .cparams )
2051
+ if not func .independent :
2052
+ cparams [0 ] = (
2053
+ '_obj' , TPtr (TNamed ("conf_object_t" )),
2054
+ TPtr (TNamed ("conf_object_t" )).declaration ('_obj' ))
2055
+ params_string = ('void' if not cparams else ", " .join (
2056
+ decl for (_ , _ , decl ) in cparams ))
2054
2057
out ("extern %s\n " % (func .rettype .declaration (
2055
2058
"%s(%s)" % (exported_name , params_string ))))
2056
2059
out ("{\n " , postindent = 1 )
2057
2060
out ("%s%s(%s);\n " % ("return " * (not func .rettype .void ),
2058
2061
"_trampoline" * (not func .independent )
2059
2062
+ func .get_cname (),
2060
- ", " .join (n for (n , t ) in params )))
2063
+ ", " .join (n for (n , _ , _ ) in cparams )))
2061
2064
out ("}\n " , preindent = - 1 )
2062
2065
2063
2066
def generate_extern_trampoline_dml12 (exported_name , func ):
2064
2067
out ("static UNUSED %s\n " % (func .rettype .declaration (
2065
- "%s(%s)" % (exported_name ,
2066
- ", " .join (t .declaration (n )
2067
- for (n , t ) in func .cparams )))))
2068
+ "%s(%s)" % (exported_name ,", " .join (
2069
+ decl for (_ , _ , decl ) in func .cparams )))))
2068
2070
out ("{\n " , postindent = 1 )
2069
2071
out ("%s%s(%s);\n " % ("" if func .rettype .void else "return " ,
2070
2072
func .get_cname (),
2071
- ", " .join (n for (n , t ) in func .cparams )))
2073
+ ", " .join (n for (n , _ , _ ) in func .cparams )))
2072
2074
out ("}\n " , preindent = - 1 )
2073
2075
2074
2076
def generate_each_in_table (trait , instances ):
@@ -2202,7 +2204,7 @@ def generate_adjustor_thunk(traitname, name, inp, outp, throws, independent,
2202
2204
assert vtable_trait is def_path [- 1 ]
2203
2205
implicit_inargs = vtable_trait .implicit_args ()
2204
2206
preargs = crep .maybe_dev_arg (independent ) + implicit_inargs
2205
- inargs = c_inargs ( inp , outp , throws )
2207
+ inargs = [( p . c_ident , p . typ ) for p in inp ] + c_extra_inargs ( outp , throws )
2206
2208
out ('(%s)\n {\n ' % (", " .join (t .declaration (n ) for (n , t ) in (preargs
2207
2209
+ inargs ))),
2208
2210
postindent = 1 )
@@ -2745,11 +2747,12 @@ def resolve_trait_param_values(node):
2745
2747
2746
2748
def generate_trait_trampoline (method , vtable_trait ):
2747
2749
implicit_inargs = vtable_trait .implicit_args ()
2748
- explicit_inargs = c_inargs (list (method .inp ), method .outp , method .throws )
2749
- inparams = ", " .join (
2750
- t .declaration (n )
2751
- for (n , t ) in (crep .maybe_dev_arg (method .independent ) + implicit_inargs
2752
- + explicit_inargs ))
2750
+ extra_inargs = c_extra_inargs (method .outp , method .throws )
2751
+ inparams = ", " .join ([t .declaration (n )
2752
+ for (n , t ) in (crep .maybe_dev_arg (method .independent )
2753
+ + implicit_inargs )]
2754
+ + [p .declaration () for p in method .inp ]
2755
+ + [t .declaration (n ) for (n , t ) in extra_inargs ])
2753
2756
rettype = c_rettype (method .outp , method .throws )
2754
2757
2755
2758
# guaranteed to exist; created by ObjTraits.mark_referenced
@@ -2770,7 +2773,8 @@ def generate_trait_trampoline(method, vtable_trait):
2770
2773
reduce (operator .mul , obj .dimsizes [dim + 1 :], 1 ),
2771
2774
obj .dimsizes [dim ]), TInt (32 , False ))
2772
2775
for dim in range (obj .dimensions )]
2773
- args = [mkLit (site , n , t ) for (n , t ) in explicit_inargs ]
2776
+ args = ([mkLit (site , p .c_ident , p .typ ) for p in method .inp ]
2777
+ + [mkLit (site , n , t ) for (n , t ) in extra_inargs ])
2774
2778
call_expr = mkcall_method (site , func , indices )(args )
2775
2779
if not rettype .void :
2776
2780
out ('return ' )
@@ -3374,9 +3378,10 @@ def generate_cfile_body(device, footers, full_module, filename_prefix):
3374
3378
generated_funcs .add (func )
3375
3379
code = codegen_method_func (func )
3376
3380
3377
- specializations = [(n , 'undefined' if undefined (v ) else v .value )
3378
- for (n , v ) in func .inp
3379
- if isinstance (v , Expression )]
3381
+ specializations = [(p .ident ,
3382
+ 'undefined' if undefined (p .expr ) else p .expr .value )
3383
+ for p in func .inp
3384
+ if p .ident is not None and p .expr is not None ]
3380
3385
3381
3386
if gather_size_statistics :
3382
3387
ctx = StrOutput (lineno = output .current ().lineno ,
0 commit comments