alpha
Login
or
Join now
nandi.uk
/
gleam
Star
2
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
Fork of daniellemaywood.uk/gleam — Wasm codegen work
Star
2
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
Overview
Issues
Pulls
Pipelines
Use existing atom escape code
author
Benjamin Milde
committer
Louis Pilfold
date
1 year ago
(Feb 9, 2025, 1:16 PM UTC)
commit
d43ef83b
d43ef83b28b8be891472c9104fa09f1a740cd9aa
parent
d2424a53
d2424a5347a3f6c6fd5479e6bc1864acc4779616
+4
-19
3 changed files
Expand all
Collapse all
Unified
Split
compiler-core
src
codegen.rs
erlang.rs
test
external_only_erlang
test.sh
+2
-17
compiler-core/src/codegen.rs
View file
Reviewed
···
9
9
Result,
10
10
};
11
11
use ecow::EcoString;
12
12
+
use erlang::escape_atom_string;
12
13
use itertools::Itertools;
13
14
use std::fmt::Debug;
14
15
···
115
116
.chain(native_modules)
116
117
.unique()
117
118
.sorted()
118
118
-
.map(|m| Self::format_atom(&m))
119
119
+
.map(|m| escape_atom_string((&m).clone().into()))
119
120
.join(",\n ");
120
121
121
122
// TODO: When precompiling for production (i.e. as a precompiled hex
···
153
154
);
154
155
155
156
writer.write(&path, &text)
156
156
-
}
157
157
-
158
158
-
fn format_atom(s: &EcoString) -> EcoString {
159
159
-
let mut chars = s.chars();
160
160
-
161
161
-
let Some(first) = chars.next() else {
162
162
-
return "''".into();
163
163
-
};
164
164
-
165
165
-
let needs_escape = |c: char| !(c.is_alphanumeric() || c == '_' || c == '@');
166
166
-
167
167
-
if !first.is_ascii_lowercase() || chars.any(needs_escape) {
168
168
-
format!("'{}'", s).into()
169
169
-
} else {
170
170
-
s.clone()
171
171
-
}
172
157
}
173
158
}
174
159
+1
-1
compiler-core/src/erlang.rs
View file
Reviewed
···
654
654
}
655
655
}
656
656
657
657
-
fn escape_atom_string(value: String) -> EcoString {
657
657
+
pub fn escape_atom_string(value: String) -> EcoString {
658
658
if is_erlang_reserved_word(&value) {
659
659
// Escape because of keyword collision
660
660
eco_format!("'{value}'")
+1
-1
test/external_only_erlang/test.sh
View file
Reviewed
···
33
33
exit 1
34
34
fi
35
35
36
36
-
echo Running erlang shippment should succeed
36
36
+
echo Running erlang shipment should succeed
37
37
g export erlang-shipment
38
38
grep "external_only_erlang_ffi" "build/erlang-shipment/external_only_erlang/ebin/external_only_erlang.app"
39
39