@@ -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 ,
@@ -2029,48 +2029,50 @@ def generate_init(device, initcode, outprefix):
2029
2029
def generate_static_trampoline (func ):
2030
2030
# static trampolines never need to be generated for independent methods
2031
2031
assert not func .independent
2032
- params = [("_obj" , TPtr (TNamed ("conf_object_t" )))] + func .cparams [1 :]
2033
- params_string = ('void' if not params
2034
- else ", " .join (t .declaration (n ) for (n , t ) in params ))
2032
+
2033
+ params_string = '' .join (", " + decl for (_ , _ , decl ) in func .cparams [1 :])
2035
2034
start_function_definition (func .rettype .declaration (
2036
- "%s(%s)" % ("_trampoline" + func .get_cname (), params_string )))
2035
+ "%s(conf_object_t *_obj%s)" % ("_trampoline" + func .get_cname (),
2036
+ params_string )))
2037
2037
out ("{\n " , postindent = 1 )
2038
2038
out ('ASSERT(_obj);\n ' )
2039
2039
out ('ASSERT(SIM_object_class(_obj) == _dev_class);\n ' )
2040
- (name , typ ) = func .cparams [0 ]
2041
- out ("%s = (%s)_obj;\n " % (typ . declaration ( name ) , typ .declaration ("" )))
2040
+ (name , typ , decl ) = func .cparams [0 ]
2041
+ out ("%s = (%s)_obj;\n " % (decl , typ .declaration ("" )))
2042
2042
out ("%s%s(%s);\n " % ("" if func .rettype .void
2043
2043
else func .rettype .declaration ("result" ) + " = " ,
2044
2044
func .get_cname (),
2045
- ", " .join (n for (n , t ) in func .cparams )))
2045
+ ", " .join (n for (n , _ , _ ) in func .cparams )))
2046
2046
output_dml_state_change (name )
2047
2047
if not func .rettype .void :
2048
2048
out ("return result;\n " )
2049
2049
out ("}\n " , preindent = - 1 )
2050
2050
2051
2051
def generate_extern_trampoline (exported_name , func ):
2052
- params = (func .cparams if func .independent else
2053
- [("_obj" , TPtr (TNamed ("conf_object_t" )))] + func .cparams [1 :])
2054
- params_string = ('void' if not params
2055
- else ", " .join (t .declaration (n ) for (n , t ) in params ))
2052
+ cparams = list (func .cparams )
2053
+ if not func .independent :
2054
+ cparams [0 ] = (
2055
+ '_obj' , TPtr (TNamed ("conf_object_t" )),
2056
+ TPtr (TNamed ("conf_object_t" )).declaration ('_obj' ))
2057
+ params_string = ('void' if not cparams else ", " .join (
2058
+ decl for (_ , _ , decl ) in cparams ))
2056
2059
out ("extern %s\n " % (func .rettype .declaration (
2057
2060
"%s(%s)" % (exported_name , params_string ))))
2058
2061
out ("{\n " , postindent = 1 )
2059
2062
out ("%s%s(%s);\n " % ("return " * (not func .rettype .void ),
2060
2063
"_trampoline" * (not func .independent )
2061
2064
+ func .get_cname (),
2062
- ", " .join (n for (n , t ) in params )))
2065
+ ", " .join (n for (n , _ , _ ) in cparams )))
2063
2066
out ("}\n " , preindent = - 1 )
2064
2067
2065
2068
def generate_extern_trampoline_dml12 (exported_name , func ):
2066
2069
out ("static UNUSED %s\n " % (func .rettype .declaration (
2067
- "%s(%s)" % (exported_name ,
2068
- ", " .join (t .declaration (n )
2069
- for (n , t ) in func .cparams )))))
2070
+ "%s(%s)" % (exported_name ,", " .join (
2071
+ decl for (_ , _ , decl ) in func .cparams )))))
2070
2072
out ("{\n " , postindent = 1 )
2071
2073
out ("%s%s(%s);\n " % ("" if func .rettype .void else "return " ,
2072
2074
func .get_cname (),
2073
- ", " .join (n for (n , t ) in func .cparams )))
2075
+ ", " .join (n for (n , _ , _ ) in func .cparams )))
2074
2076
out ("}\n " , preindent = - 1 )
2075
2077
2076
2078
def generate_each_in_table (trait , instances ):
@@ -2204,7 +2206,7 @@ def generate_adjustor_thunk(traitname, name, inp, outp, throws, independent,
2204
2206
assert vtable_trait is def_path [- 1 ]
2205
2207
implicit_inargs = vtable_trait .implicit_args ()
2206
2208
preargs = crep .maybe_dev_arg (independent ) + implicit_inargs
2207
- inargs = c_inargs ( inp , outp , throws )
2209
+ inargs = [( p . c_ident , p . typ ) for p in inp ] + c_extra_inargs ( outp , throws )
2208
2210
out ('(%s)\n {\n ' % (", " .join (t .declaration (n ) for (n , t ) in (preargs
2209
2211
+ inargs ))),
2210
2212
postindent = 1 )
@@ -2747,11 +2749,12 @@ def resolve_trait_param_values(node):
2747
2749
2748
2750
def generate_trait_trampoline (method , vtable_trait ):
2749
2751
implicit_inargs = vtable_trait .implicit_args ()
2750
- explicit_inargs = c_inargs (list (method .inp ), method .outp , method .throws )
2751
- inparams = ", " .join (
2752
- t .declaration (n )
2753
- for (n , t ) in (crep .maybe_dev_arg (method .independent ) + implicit_inargs
2754
- + explicit_inargs ))
2752
+ extra_inargs = c_extra_inargs (method .outp , method .throws )
2753
+ inparams = ", " .join ([t .declaration (n )
2754
+ for (n , t ) in (crep .maybe_dev_arg (method .independent )
2755
+ + implicit_inargs )]
2756
+ + [p .declaration () for p in method .inp ]
2757
+ + [t .declaration (n ) for (n , t ) in extra_inargs ])
2755
2758
rettype = c_rettype (method .outp , method .throws )
2756
2759
2757
2760
# guaranteed to exist; created by ObjTraits.mark_referenced
@@ -2772,7 +2775,8 @@ def generate_trait_trampoline(method, vtable_trait):
2772
2775
reduce (operator .mul , obj .dimsizes [dim + 1 :], 1 ),
2773
2776
obj .dimsizes [dim ]), TInt (32 , False ))
2774
2777
for dim in range (obj .dimensions )]
2775
- args = [mkLit (site , n , t ) for (n , t ) in explicit_inargs ]
2778
+ args = ([mkLit (site , p .c_ident , p .typ ) for p in method .inp ]
2779
+ + [mkLit (site , n , t ) for (n , t ) in extra_inargs ])
2776
2780
call_expr = mkcall_method (site , func , indices )(args )
2777
2781
if not rettype .void :
2778
2782
out ('return ' )
@@ -3376,9 +3380,10 @@ def generate_cfile_body(device, footers, full_module, filename_prefix):
3376
3380
generated_funcs .add (func )
3377
3381
code = codegen_method_func (func )
3378
3382
3379
- specializations = [(n , 'undefined' if undefined (v ) else v .value )
3380
- for (n , v ) in func .inp
3381
- if isinstance (v , Expression )]
3383
+ specializations = [(p .ident ,
3384
+ 'undefined' if undefined (p .expr ) else p .expr .value )
3385
+ for p in func .inp
3386
+ if p .ident is not None and p .expr is not None ]
3382
3387
3383
3388
if gather_size_statistics :
3384
3389
ctx = StrOutput (lineno = output .current ().lineno ,
0 commit comments