@@ -249,8 +249,8 @@ def generate_structfile(device, filename, outprefix):
249249 "%s(%s)" % (name ,
250250 ", " .join ((["conf_object_t *_obj" ]
251251 * (not func .independent ))
252- + [t . declaration ( n )
253- for (n , t ) in (
252+ + [decl
253+ for (_ , _ , decl ) in (
254254 func .cparams
255255 if func .independent
256256 else func .cparams [1 :])]))))
@@ -718,7 +718,7 @@ def wrap_method(meth, wrapper_name, indices=()):
718718 is a port object
719719 """
720720
721- inparams = [t .declaration (p ) for p , t in meth .inp ]
721+ inparams = [p .declaration () for p in meth .inp ]
722722 if not meth .outp :
723723 retvar = None
724724 rettype = TVoid ()
@@ -749,7 +749,7 @@ def wrap_method(meth, wrapper_name, indices=()):
749749 None , None , None )).toc ()
750750
751751 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 ]
753753 outargs = [mkLit (meth .site , v , t ) for v , t in meth .outp ]
754754 codegen_call (meth .site , meth ,
755755 indices ,
@@ -804,10 +804,10 @@ def generate_implement_method(device, ifacestruct, meth, indices):
804804 # currently impossible to implement a varargs interface
805805 # method in DML
806806 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 )):
809809 raise EARGT (meth .site , 'implement' , meth .name ,
810- mt , mp , it , 'method' )
810+ mp . typ , mp . logref , it , 'method' )
811811 if iface_num_outputs and dml .globals .dml_version != (1 , 2 ):
812812 [(_ , mt )] = meth .outp
813813 if not safe_realtype_unconst (mt ).eq (
@@ -1355,15 +1355,15 @@ def generate_events(device):
13551355def generate_reg_callback (meth , name ):
13561356 dev_t = crep .structtype (dml .globals .device )
13571357 out ('static bool\n ' )
1358- params = [t .declaration (p ) for p , t in meth .inp ] + [
1358+ params = [p .declaration () for p in meth .inp ] + [
13591359 TPtr (t ).declaration (p ) for p , t in meth .outp ]
13601360 out ('%s(void *_obj, const uint16 *indices, ' % (name ,)
13611361 + ', ' .join (params ) + ')\n ' )
13621362 out ('{\n ' , postindent = 1 )
13631363 out ('%s *_dev = _obj;\n ' % dev_t )
13641364 fail = ReturnFailure (meth .site )
13651365 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 ]
13671367 outargs = [mkLit (meth .site , "*" + n , t ) for n , t in meth .outp ]
13681368 code = [codegen_call (
13691369 meth .site , meth ,
@@ -2027,48 +2027,50 @@ def generate_init(device, initcode, outprefix):
20272027def generate_static_trampoline (func ):
20282028 # static trampolines never need to be generated for independent methods
20292029 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 :])
20332032 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 )))
20352035 out ("{\n " , postindent = 1 )
20362036 out ('ASSERT(_obj);\n ' )
20372037 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 ("" )))
20402040 out ("%s%s(%s);\n " % ("" if func .rettype .void
20412041 else func .rettype .declaration ("result" ) + " = " ,
20422042 func .get_cname (),
2043- ", " .join (n for (n , t ) in func .cparams )))
2043+ ", " .join (n for (n , _ , _ ) in func .cparams )))
20442044 output_dml_state_change (name )
20452045 if not func .rettype .void :
20462046 out ("return result;\n " )
20472047 out ("}\n " , preindent = - 1 )
20482048
20492049def 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 ))
20542057 out ("extern %s\n " % (func .rettype .declaration (
20552058 "%s(%s)" % (exported_name , params_string ))))
20562059 out ("{\n " , postindent = 1 )
20572060 out ("%s%s(%s);\n " % ("return " * (not func .rettype .void ),
20582061 "_trampoline" * (not func .independent )
20592062 + func .get_cname (),
2060- ", " .join (n for (n , t ) in params )))
2063+ ", " .join (n for (n , _ , _ ) in cparams )))
20612064 out ("}\n " , preindent = - 1 )
20622065
20632066def generate_extern_trampoline_dml12 (exported_name , func ):
20642067 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 )))))
20682070 out ("{\n " , postindent = 1 )
20692071 out ("%s%s(%s);\n " % ("" if func .rettype .void else "return " ,
20702072 func .get_cname (),
2071- ", " .join (n for (n , t ) in func .cparams )))
2073+ ", " .join (n for (n , _ , _ ) in func .cparams )))
20722074 out ("}\n " , preindent = - 1 )
20732075
20742076def generate_each_in_table (trait , instances ):
@@ -2202,7 +2204,7 @@ def generate_adjustor_thunk(traitname, name, inp, outp, throws, independent,
22022204 assert vtable_trait is def_path [- 1 ]
22032205 implicit_inargs = vtable_trait .implicit_args ()
22042206 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 )
22062208 out ('(%s)\n {\n ' % (", " .join (t .declaration (n ) for (n , t ) in (preargs
22072209 + inargs ))),
22082210 postindent = 1 )
@@ -2745,11 +2747,12 @@ def resolve_trait_param_values(node):
27452747
27462748def generate_trait_trampoline (method , vtable_trait ):
27472749 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 ])
27532756 rettype = c_rettype (method .outp , method .throws )
27542757
27552758 # guaranteed to exist; created by ObjTraits.mark_referenced
@@ -2770,7 +2773,8 @@ def generate_trait_trampoline(method, vtable_trait):
27702773 reduce (operator .mul , obj .dimsizes [dim + 1 :], 1 ),
27712774 obj .dimsizes [dim ]), TInt (32 , False ))
27722775 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 ])
27742778 call_expr = mkcall_method (site , func , indices )(args )
27752779 if not rettype .void :
27762780 out ('return ' )
@@ -3374,9 +3378,10 @@ def generate_cfile_body(device, footers, full_module, filename_prefix):
33743378 generated_funcs .add (func )
33753379 code = codegen_method_func (func )
33763380
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 ]
33803385
33813386 if gather_size_statistics :
33823387 ctx = StrOutput (lineno = output .current ().lineno ,
0 commit comments