71 lines
6.2 KiB
Plaintext
71 lines
6.2 KiB
Plaintext
[video member=pervognsen stream_platform=twitch project=bitwise title="C Code Generation" vod_platform=youtube id=X9YWYlp8iQg annotator=Miblo]
|
||
[0:08][Recap and set the stage for the day][:speech]
|
||
[1:30][C Code Generation][:"code generation" :language :speech]
|
||
[6:59][Valid types in Ion][:"code generation" :language :speech]
|
||
[10:02][Translating Ion to C, with a few words on the principle of "declaration follows use" and the quirks of C function declaration syntax[ref
|
||
author=ANSI
|
||
title="ISO/IEC 9899: Information technology – Programming languages – C"
|
||
url=http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf]][:"code generation" :language :speech]
|
||
[16:04][Translating Ion's (ptr int) and (ptr (ptr int))][:"code generation" :language :speech]
|
||
[19:58][Translating Ion's (array 10 (ptr int))][:"code generation" :language :speech]
|
||
[21:21][Translating Ion's (func int (int))][:"code generation" :language :speech]
|
||
[24:09][Q&A][:speech]
|
||
[24:39][Setup to translate Ion's type declarations to C][:"code generation"]
|
||
[25:57][Introduce gen_test() and type_to_cdecl() - handling void, char, int and float - and a strf()][:"code generation"]
|
||
[31:55][:Run it to see that strf() works as expected][:"code generation"]
|
||
[32:38][Add tests for strf() in common_test()][:"code generation"]
|
||
[33:41][:Run it to see that we pass all the tests][:"code generation"]
|
||
[33:45][Implement the TYPE_PTR and TYPE_ARRAY cases in type_to_cdecl()][:"code generation"]
|
||
[35:39][Create and :run tests for type_to_cdelc() in gen_test()][:"code generation" :programming]
|
||
[38:59][Implement the TYPE_FUNC case in type_to_cdelc()][:"code generation"]
|
||
[43:09][Add a test of the function :"code generation" of type_to_cdelc() in gen_test()]
|
||
[43:43][Step through gen_test() to see what it produces][:"code generation" :run]
|
||
[44:15][Remove parentheses from the void, char, int and float types in type_to_cdelc()][:"code generation"]
|
||
[44:42][:Run it to see that it looks reasonable, but for the extra space][:"code generation"]
|
||
[45:08][Stress test the function :"code generation" of type_to_cdelc() in gen_test()]
|
||
[45:56][:Run it to see that it looks vaguely right, and consider how we'll get rid of the extra parentheses][:"code generation"]
|
||
[46:30][Add function pointer tests in gen_test()][:"code generation"]
|
||
[47:21][:Run it to see that we're generating illegal C][:"code generation"]
|
||
[48:18][Fix the TYPE_PTR case in type_to_cdelc()][:"code generation"]
|
||
[48:36][:Run it to see that it looks right][:"code generation"]
|
||
[49:12][Add an array test in get_test()][:"code generation"]
|
||
[49:42][:Run it to see extra parentheses again][:"code generation"]
|
||
[50:22][Introduce opt_paren() to handle parenthesis generation for type_to_cdelc() to call][:"code generation"]
|
||
[54:50][:Run it to see that it looks right][:"code generation"]
|
||
[55:35][@pmttavara][Can't you just pass in some dummy name to workaround the missing name? Like (__arg\[10\])][:"code generation"]
|
||
[56:22][@twitchplaysp0ng][Does Ion support named function pointer parameters][:language]
|
||
[57:02][Rename opt_paren() to cdecl_paren() and clean up the space-generation in type_to_cdelc()][:"code generation"]
|
||
[58:00][:Run it to see that it's starting to look correct][:"code generation"]
|
||
[58:19][][:"code generation"][quote 4]
|
||
[58:49][Further thoughts on dummy names, noting that we'll be using this same code for casts][:"code generation" :speech]
|
||
[1:00:07][@elavid][@PMTTavara's idea works for me at least in GCC. We're specifically talking about the function pointer arguments. Example cast: (int (*)(int dummyname))0][:"code generation"]
|
||
[1:01:22][@0b0000000000000][Function that returns array of function pointers with pointer arguments][quote 5]
|
||
[1:01:29][Add a test of a function that returns (unfortunately unintentionally) a function in gen_test()][:"code generation"]
|
||
[1:02:38][:Run it to see that it looks wrong][:"code generation"]
|
||
[1:04:29][@rygorous][You can't return functions directly][:language]
|
||
[1:04:48][Construct a C-valid function declaration that returns an array of function pointers][:language]
|
||
[1:08:58][@twitchplaysp0ng][@pervognsen Change line 21][:"code generation"]
|
||
[1:09:10][Work through the handling of our torture test in the TYPE_FUNC case in type_to_cdelc()][:"code generation"]
|
||
[1:12:27][:Run it to find that it does work][:"code generation"]
|
||
[1:12:58][@0b0000000000000][You could also typedef any function pointer types to make it easier?][:"code generation"]
|
||
[1:13:19][Add our intended torture test of a function that returns an array of function pointers in gen_test()][:"code generation"]
|
||
[1:14:23][:Run it to see that we correctly generate our torture test case][:"code generation"]
|
||
[1:15:28][A few words on constructing C declarations in the knowledge of its inside-to-out parsing][:language :speech]
|
||
[1:17:03][@rygorous][No, that array is an argument. Or, wait, is it? I don't actually know what the args to type_func are][:"code generation" :language]
|
||
[1:17:17][Rename gen_test() to cdecl_test()][:"code generation"]
|
||
[1:17:46][@rygorous][No, MSVC says that a function returning an array is illegal][:language]
|
||
[1:18:07][Determine to enable type_to_cdecl() to handle structs and unions, introducing cdecl_name() to produce the type strings for our types][:"code generation"]
|
||
[1:21:19][Introduce gen_decl() and genf(), and determine to enable the resolver code to pass the resolve type through to the generator][:"code generation"]
|
||
[1:24:07][Mini :rant on MSVC's "Go to All" feature's regex-style interpretation of "."]
|
||
[1:24:32][Add a Type *type to the Expr struct for resolve_expected_expr() to fill out, and change the Decl struct to contain a Sym *sym rather than a Type *type for sym_global_decl() to set][:parsing]
|
||
[1:29:24][Q&A][:speech]
|
||
[1:29:44][@elavid][Oh, are we gonna have a K&R moment? You should add "void" if the num_params is 0][:language]
|
||
[1:30:06][Make type_to_cdecl() add "void" for functions that take no arguments][:"code generation"]
|
||
[1:30:42][:Run it to see that it correctly adds "void"][:"code generation"]
|
||
[1:31:23][@0b0000000000000][@pervognsen You need break statements on those cases]
|
||
[1:31:37][@0b0000000000000][@pervognsen You broke the switch statement that had returns]
|
||
[1:31:51][Fix resolve_expected_expr() to break out of the cases in its switch statement][:parsing]
|
||
[1:32:47][Stop the recording][:speech]
|
||
[/video]
|
||
|