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

(many) Support string concatenation in compiled mode #470

Merged

Conversation

perlun
Copy link
Collaborator

@perlun perlun commented May 4, 2024

Because we now have an idea around how to allocate Perlang strings dynamically (#453), we can also implement the + operator now which fixes one of the remaining "not supported in compiled mode" features.

@perlun perlun force-pushed the feature/support-ASCIIString-concatenation-in-compiled-mode branch from c117b73 to 32cdf9f Compare May 4, 2024 05:56
@@ -79,6 +79,7 @@ ClrType switch

// Cannot use typeof(AsciiString) since Perlang.Common cannot depend on Perlang.Stdlib
var t when t.FullName == "Perlang.Lang.AsciiString" => true,
var t when t.FullName == "Perlang.Lang.Utf8String" => true,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was necessary for one of the tests to pass, and should be added here anyway.

if (expr.TypeReference.ClrType != expr.Right.TypeReference.ClrType && !(
expr.TypeReference.ClrType == typeof(Lang.String) ||
expr.TypeReference.ClrType == typeof(Lang.AsciiString) ||
expr.TypeReference.ClrType == typeof(Lang.Utf8String)))
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These were added here to avoid peculiar constructs like *s1 + *(perlang::String)perlang::ASCIIString::from_static_string(" ")) + *s2 in the generated code. The problem is that while this would be kind-of-valid in C# and Java, we can't really cast to a perlang::String like this because this triggers an instantiation => perlang::String is abstract and cannot (and should not!) ever be instantiated. Ignoring the cast for now is the simplest approach here; let's see if all the tests are still passing or if this breaks something else now...

output.Should()
.Be("Årets varmaste temperatur (Celsius): 32");
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These tests were added while working on this, but they are not yet operational because the underlying (C++) stdlib code isn't there yet. Will be fixed in an upcoming PR.

@perlun perlun force-pushed the feature/support-ASCIIString-concatenation-in-compiled-mode branch from 32cdf9f to 861d88b Compare May 4, 2024 06:08
@perlun perlun enabled auto-merge (squash) May 4, 2024 06:09
@perlun perlun force-pushed the feature/support-ASCIIString-concatenation-in-compiled-mode branch from 861d88b to d920924 Compare May 5, 2024 05:31
@perlun perlun force-pushed the feature/support-ASCIIString-concatenation-in-compiled-mode branch from d920924 to 685d1b6 Compare May 5, 2024 05:31
@perlun perlun disabled auto-merge May 5, 2024 05:35
@perlun perlun changed the title (stdlib) Support string concatenation in compiled mode (many) Support string concatenation in compiled mode May 5, 2024
@perlun perlun merged commit 31e1213 into master May 5, 2024
11 checks passed
@perlun perlun deleted the feature/support-ASCIIString-concatenation-in-compiled-mode branch May 5, 2024 05:37
@perlun perlun mentioned this pull request May 8, 2024
12 tasks
@perlun perlun added stdlib Things related to the Perlang API/stdlib experimental compilation Issues which are relevant when using experimental compilation labels May 10, 2024
@perlun perlun added this to the 0.5.0 milestone May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
experimental compilation Issues which are relevant when using experimental compilation stdlib Things related to the Perlang API/stdlib
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant