@@ -374,8 +374,8 @@ def main():
374374 benchmark_V (results = results , code_paths = code_paths , args = args , op = 'Build' , templated = True )
375375
376376 if 'C3' in args .languages :
377- if 'Build' in args .operations :
378- benchmark_C3 (results = results , code_paths = code_paths , args = args , op = 'Build' , templated = False )
377+ for op in args .operations :
378+ benchmark_C3 (results = results , code_paths = code_paths , args = args , op = op , templated = False )
379379
380380 if 'Zig' in args .languages :
381381 if 'Check' in args .operations :
@@ -834,12 +834,21 @@ def benchmark_C3(results, code_paths, args, op, templated):
834834 exe = (match_lang (args , lang , 'c3c' ) or
835835 which (os .path .join (HOME , 'ware/c3c/build/c3c' )))
836836 if exe :
837- version = 'unknown'
837+ exe_flags = ['-O0' ]
838+
839+ if op == 'Check' :
840+ exe_flags += ['compile-only' ] + ['-C' ]
841+ elif op == 'Compile' :
842+ exe_flags += ['compile-only' ]
843+ else :
844+ exe_flags += ['compile' ]
845+
846+ version = sp .run ([exe , '--version' ], stdout = sp .PIPE ).stdout .decode ('utf-8' ).split (':' )[1 ].split ()[0 ]
838847 compile_file (code_paths ,
839848 out_flag_and_exe = ['-o' , out_binary (lang )],
840849 exe = exe ,
841850 runner = True ,
842- exe_flags = [ 'compile' ] ,
851+ exe_flags = exe_flags ,
843852 args = args ,
844853 op = op ,
845854 compiler_version = version ,
@@ -1299,7 +1308,7 @@ def generate_test_language_specific_postfix(lang, types, f):
12991308 elif lang == 'nim' :
13001309 f .write (Tm ('\n \n ' ).substitute (T = types [0 ]))
13011310 elif lang == 'c3' :
1302- f .write (Tm ('\n }\n ' ).substitute (T = types [0 ])) # TODO exit
1311+ f .write (Tm (' return (int)(${T}_sum); \n }\n ' ).substitute (T = types [0 ]))
13031312 elif lang == 'julia' :
13041313 f .write (Tm (''' return ${T}_sum;
13051314end
@@ -1395,7 +1404,7 @@ def generate_test_function_definition(args, lang, typ, findex, fheight, f,
13951404 if lang in ('c' ):
13961405 f .write (Tm ('${T} ${F}(${T} x) { return ${X}; }\n ' ).substitute (T = typ , F = str (fname ), N = nconst , X = expr ))
13971406 elif lang in ('c3' ):
1398- f .write (Tm ('func ${T} ${F}(${T} x) { return ${X}; }\n ' ).substitute (T = typ , F = str (fname ), N = nconst , X = expr ))
1407+ f .write (Tm ('fn ${T} ${F}(${T} x) { return ${X}; }\n ' ).substitute (T = typ , F = str (fname ), N = nconst , X = expr ))
13991408 elif lang in ['ada' ]:
14001409 f .write (Tm (''' function ${F} (x: ${T}) return ${T} is (${X});
14011410''' ).substitute (T = typ , F = str (fname ), N = nconst , X = expr ))
@@ -1449,13 +1458,13 @@ def generate_test_function_definition(args, lang, typ, findex, fheight, f,
14491458 f .write (Tm ('proc ${F}(x: ${T}): ${T} = \n return ${X}\n ' ).substitute (T = typ , F = str (fname ), N = nconst , H = str (fheight ), X = expr ))
14501459 elif lang == 'c3' :
14511460 if templated :
1452- f .write (Tm ('func ${F}<${T}>(x: ${T}) -> ${T} { return ${X} }\n ' ).substitute (T = 'T' ,
1461+ f .write (Tm ('fn ${F}<${T}>(x: ${T}) -> ${T} { return ${X} }\n ' ).substitute (T = 'T' ,
14531462 F = str (fname ),
14541463 N = nconst ,
14551464 H = str (fheight ),
14561465 X = expr ))
14571466 else :
1458- f .write (Tm ('func ${T} ${F}(${T} x) { return ${X} }\n ' ).substitute (T = typ , F = str (fname ), N = nconst , H = str (fheight ), X = expr ))
1467+ f .write (Tm ('fn ${T} ${F}(${T} x) { return ${X} }\n ' ).substitute (T = typ , F = str (fname ), N = nconst , H = str (fheight ), X = expr ))
14591468 elif lang == 'zig' :
14601469 if templated :
14611470 f .write (Tm ('fn ${F}(comptime T: type, x: T) T { return ${X}; }\n ' ).substitute (T = typ , F = str (fname ), N = nconst , H = str (fheight ), X = expr ))
@@ -1497,7 +1506,7 @@ def generate_test_main_header(lang, types, f, templated):
14971506 elif lang == 'zig' :
14981507 f .write (Tm ('pub fn main() void {\n ' ).substitute (T = types [0 ]))
14991508 elif lang == 'c3' :
1500- f .write (Tm ('func void main() {\n ' ).substitute (T = types [0 ]))
1509+ f .write (Tm ('fn int main() {\n ' ).substitute (T = types [0 ]))
15011510 elif lang == 'go' :
15021511 f .write (Tm ('func main() {\n ' ).substitute (T = types [0 ]))
15031512 elif lang == 'v' :
@@ -1596,11 +1605,14 @@ def generate_test_program_2(function_count, lang, templated):
15961605
15971606 for typ in types :
15981607 for findex in range (0 , function_count ):
1599- if lang in ('c' , 'c3' , ' c++' ):
1608+ if lang in ('c' , 'c++' ):
16001609 f .write (Tm ('''${T} add_${T}_n${N}(${T} x) { return x + ${N}; }
16011610''' ).substitute (T = typ , N = str (findex )))
16021611 if lang in ('d' , 'vox' ):
16031612 f .write (Tm ('''${T} add_${T}_n${N}(${T} x) pure { return x + ${N}; }
1613+ ''' ).substitute (T = typ , N = str (findex )))
1614+ elif lang == 'c3' :
1615+ f .write (Tm ('''fn ${T} add_${T}_n${N}(${T} x) { return x + ${N}; }
16041616''' ).substitute (T = typ , N = str (findex )))
16051617 elif lang == 'rust' :
16061618 f .write (Tm ('''fn add_${T}_n${N}(x: ${T}) -> ${T} { x + ${N} }
0 commit comments