Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for turning calls into compile time constants #2067

Merged

Conversation

michaellilltokiwa
Copy link
Member

@michaellilltokiwa michaellilltokiwa commented Oct 9, 2023

ex is

  a := (u32 65, codepoint 97)
  say a.values.0
  say a.values.1

a instantiation is compiled to:

    fzCur->fzF_0_a = (fzT_2tuple_w_u32_w_codepoint){.fzF_0_values = 65U,.fzF_1_values = (fzT_1codepoint){.fzF_0_val = 97U}};

@michaellilltokiwa michaellilltokiwa force-pushed the call_compile_time_constants branch 5 times, most recently from 3654546 to ec74fd2 Compare October 11, 2023 07:44
@michaellilltokiwa michaellilltokiwa marked this pull request as ready for review October 11, 2023 08:04
@michaellilltokiwa michaellilltokiwa marked this pull request as draft October 11, 2023 08:46
@michaellilltokiwa michaellilltokiwa marked this pull request as ready for review October 11, 2023 10:17
@Override
public boolean isCompileTimeConst()
{
var result =
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of these may be redundant or could be relaxed.

@michaellilltokiwa michaellilltokiwa force-pushed the call_compile_time_constants branch 3 times, most recently from ebdfacc to bebe398 Compare October 18, 2023 12:47
@michaellilltokiwa michaellilltokiwa marked this pull request as draft October 20, 2023 12:27
@michaellilltokiwa michaellilltokiwa force-pushed the call_compile_time_constants branch 2 times, most recently from 963139b to b23155f Compare October 20, 2023 13:12
@michaellilltokiwa michaellilltokiwa marked this pull request as ready for review October 23, 2023 15:28
@michaellilltokiwa michaellilltokiwa marked this pull request as draft October 23, 2023 15:28
@michaellilltokiwa michaellilltokiwa marked this pull request as ready for review October 23, 2023 16:00
Copy link
Member

@fridis fridis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice and clean patch compared with the big impact this has!

One case I am unsure of is this:

  side_effect is say "this does something!"
  point(x,y i32) : side_effect is
    as_string => "$x,$y"
  c := point 3 4
  say c

Does this create a constant out of point 3 4? If so, this might be a bug.

Some more minor comments in the code.

src/dev/flang/ast/AbstractFeature.java Outdated Show resolved Hide resolved
src/dev/flang/ast/AbstractType.java Outdated Show resolved Hide resolved
src/dev/flang/be/jvm/CodeGen.java Outdated Show resolved Hide resolved
src/dev/flang/be/jvm/CodeGen.java Outdated Show resolved Hide resolved
src/dev/flang/be/jvm/CodeGen.java Outdated Show resolved Hide resolved
src/dev/flang/fuir/analysis/dfa/DFA.java Outdated Show resolved Hide resolved
src/dev/flang/be/jvm/CodeGen.java Show resolved Hide resolved
src/dev/flang/ast/AbstractConstant.java Outdated Show resolved Hide resolved
@michaellilltokiwa
Copy link
Member Author

Very nice and clean patch compared with the big impact this has!

One case I am unsure of is this:

  side_effect is say "this does something!"
  point(x,y i32) : side_effect is
    as_string => "$x,$y"
  c := point 3 4
  say c

Does this create a constant out of point 3 4? If so, this might be a bug.

Some more minor comments in the code.

I now check if the inherited features code contains only declarations.

@fridis fridis merged commit 4d3d694 into tokiwa-software:main Nov 2, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants