[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] pkl: Use `format` function in `assert` implementation
From: |
Mohammad-Reza Nabipoor |
Subject: |
Re: [PATCH] pkl: Use `format` function in `assert` implementation |
Date: |
Sat, 31 Jul 2021 18:54:24 +0430 |
Hi, Jose.
On Sat, Jul 31, 2021 at 03:47:01PM +0200, Jose E. Marchesi wrote:
>
> Hi Mohammad.
>
> Sorry it took so long for me to look at this.
>
I'm happy that you're hacking poke again :)
> > This commit changes the implementation of `assert` statement to
> > pass source location info (FILENAME, LINE and COLUMN) separately,
> > instead of passing a pre-formated string
> > ("<FILENAME>:<LINE>:<COLUMN>"). And makes `msg` string using `format`
> > function.
> >
> > The reason that this commit, separates the runtime library (`pkl-rt.pk`)
> > into two separate files (`pkl-rt-1.pk` and `pkl-rt-2.pk`) is that
> > codegen of `format` generates a function call to
> > `_pkl_reduce_string_array`, and it's inaccessible to codegen at this
> > stage. Because `_pkl_reduce_string_array` is also defined in the runtime
> > library. Moving `_pkl_assert` function to `pkl-rt-2.pk` makes codegen
> > happy!
>
> I would like to understand why this is happening. Moving the definition
> of _pkl_assert down in pkl-rt.pk after _pkl_reduce_string_array doesn't
> fix the problem?
>
This is what I get when the `_pkl_assert` is defined in the same compilation
unit as `_pkl_reduce_string_array`:
```
lt-poke: ../../libpoke/pkl-asm.c:2117: pkl_asm_call: Assertion `tmp != NULL'
failed.
Aborted (core dumped)
```
Even moving it down after the `_pkl_reduce_string_array` doesn't fix the
problem.
The following assertion is the problem in `pkl_asm_call` function:
```c
tmp = pkl_env_lookup (compiler_env, PKL_ENV_NS_MAIN,
funcname, &back, &over);
assert (tmp != NULL);
```
I've checked the `compiler_env`; it's empty.
And the `funcname` is `"_pkl_reduce_string_array"`.
Regards,
Mohammad-Reza