From: Johnny Richard <johnny@johnnyrichard.com>
To: Carlos Maniero <carlos@maniero.me>
Cc: ~johnnyrichard/olang-devel@lists.sr.ht
Subject: Re: [PATCH olang v1 3/3] cli: add compilation -o option with --save-temps
Date: Tue, 5 Mar 2024 09:27:58 +0100 [thread overview]
Message-ID: <crldafmpmj646yqvuz2qre4hhvntutph44h2jm7h2slukhrys3@kyekjo22smul> (raw)
In-Reply-To: <CZLG3530TMZL.2F7UL2NLVP17H@maniero.me>
On Mon, Mar 04, 2024 at 11:02:14PM -0300, Carlos Maniero wrote:
>
> > +typedef enum
> > +{
> > + CLI_OPT_DUMP_TOKENS = 1 << 1,
> > + CLI_OPT_OUTPUT = 1 << 2,
> > + CLI_OPT_SAVE_TEMPS = 1 << 3
> > +} cli_opt;
>
> nitpick: Any particular reason to avoid using the first bit?
no reason, I will fix it!
> What is the point of making *file_path* a SV? Ever single place it is
> used you are accessing it's char pointer directly - *file_path.chars*.
> It looks unsafe to just ignore the SV's size, example:
> *print_token(opts->file_path.chars, &token)*
I made file_path a string view to keep alined with other string view
fields. It was just cosmetic. I agree on keep a cstr instead.
> > - char *prog = cli_args_shift(&args);
> > + opts.prog = string_view_from_cstr(cli_args_shift(&args));
>
> nitpick: Is that a standard calling arg0 as prog? I know it was already
> there, but taking a fresh look at this name, I find it hard to
> understand. WDYT about *opts.compiler_path*, *opts.the_0c_path* or
> *opts.this_path*? The point is that, program can be ambiguos here as it
> could be both the compiler's program or the program to be compiled.
I will go with **compiler_path** for this one.
> > + assert(opts && "args is required");
>
> s/opts/args
Opss...
> > + string_view_t asm_ext = string_view_from_cstr(".s");
> > + char asm_file[opts->output_bin.size + asm_ext.size + 1];
> > + memcpy(asm_file, opts->output_bin.chars, opts->output_bin.size);
> > + memcpy(asm_file + opts->output_bin.size, asm_ext.chars, asm_ext.size);
> > + asm_file[opts->output_bin.size + asm_ext.size] = 0;
>
> nitpick: you have achieved the same later at this same file using
> *sprintf* which I think reads better.
>
> + char asm_file[opts->output_bin.size + 3];
> + sprintf(asm_file, "" SV_FMT ".s", SV_ARG(opts->output_bin));
Sure...
next prev parent reply other threads:[~2024-03-05 7:27 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-04 19:23 [PATCH olang v1 0/3] implement assembly linux x86_64 compiler Johnny Richard
2024-03-04 19:23 ` [PATCH olang v1 1/3] be: create linux-x86_64 gas asm codegen Johnny Richard
2024-03-04 19:23 ` [PATCH olang v1 2/3] string_view: add function to create from cstr Johnny Richard
2024-03-04 19:23 ` [PATCH olang v1 3/3] cli: add compilation -o option with --save-temps Johnny Richard
2024-03-04 18:33 ` [olang/patches/.build.yml] build failed builds.sr.ht
2024-03-04 19:39 ` Johnny Richard
2024-03-05 2:05 ` Carlos Maniero
2024-03-05 2:02 ` [PATCH olang v1 3/3] cli: add compilation -o option with --save-temps Carlos Maniero
2024-03-05 8:27 ` Johnny Richard [this message]
2024-03-05 8:53 ` [PATCH olang v1 0/3] implement assembly linux x86_64 compiler Johnny Richard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=crldafmpmj646yqvuz2qre4hhvntutph44h2jm7h2slukhrys3@kyekjo22smul \
--to=johnny@johnnyrichard.com \
--cc=carlos@maniero.me \
--cc=~johnnyrichard/olang-devel@lists.sr.ht \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.johnnyrichard.com/olang.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox