Skip to content

Commit e6f6ffd

Browse files
authored
Improvements to properties + intrinsic types (#157)
See #157 for all
1 parent 9ec1ce0 commit e6f6ffd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+15377
-8162
lines changed

.github/workflows/performance-and-size.yml

+47-20
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,6 @@ jobs:
2929
with:
3030
packages: hyperfine
3131

32-
# For displaying line count in file
33-
- name: Download scc
34-
run: |
35-
mkdir scc
36-
cd scc
37-
gh release download v3.1.0 -R boyter/scc -p '*Linux_x86_64.tar.gz' -O scc.tar.gz
38-
tar -xf scc.tar.gz
39-
chmod +x scc
40-
pwd >> $GITHUB_PATH
41-
env:
42-
GH_TOKEN: ${{ github.token }}
43-
4432
- name: Build Ezno
4533
run: cargo build --release
4634
env:
@@ -52,8 +40,6 @@ jobs:
5240
# Generate a file which contains everything that Ezno currently implements
5341
cargo run -p ezno-parser --example code_blocks_to_script ./checker/specification/specification.md --comment-headers --out ./demo.tsx
5442
55-
LINES_OF_CODE=$(scc -c --no-cocomo -f json demo.tsx | jq ".[0].Code")
56-
5743
echo "### Checking
5844
\`\`\`shell
5945
$(hyperfine -i './target/release/ezno check demo.tsx')
@@ -62,33 +48,74 @@ jobs:
6248
echo "<details>
6349
<summary>Input</summary>
6450
51+
> Code generated from specification.md. this is not meant to accurately represent a program but instead give an idea for how it scales across all the type checking features
6552
\`\`\`tsx
66-
// $LINES_OF_CODE lines of TypeScript generated from specification.md
67-
// this is not meant to accurately represent a program but instead give an idea
68-
// for how it scales across all the type checking features
6953
$(cat ./demo.tsx)
7054
\`\`\`
7155
</details>
7256
" >> $GITHUB_STEP_SUMMARY
7357
7458
echo "::info::Wrote code to summary"
7559
60+
command_output=$(./target/release/ezno check demo.tsx --timings --max-diagnostics all 2>&1 || true)
61+
diagnostics=""; statistics=""; found_splitter=false;
62+
63+
while IFS= read -r line; do
64+
if [[ "$line" == "---"* ]]; then found_splitter=true;
65+
elif [[ "$found_splitter" == false ]]; then diagnostics+="$line"$'\n';
66+
else statistics+="$line"$'\n'; fi
67+
done <<< "$command_output"
68+
7669
echo "<details>
7770
<summary>Diagnostics</summary>
78-
71+
7972
\`\`\`
80-
$(./target/release/ezno check demo.tsx --timings --max-diagnostics all 2>&1 || true)
73+
$diagnostics
74+
\`\`\`
75+
</details>
76+
77+
<details>
78+
<summary>Statistics</summary>
79+
80+
\`\`\`
81+
$statistics
8182
\`\`\`
8283
</details>
8384
" >> $GITHUB_STEP_SUMMARY
8485
86+
- name: Run checker performance w/staging
87+
shell: bash
88+
if: github.ref_name != 'main'
89+
run: |
90+
echo "::group::Running all"
91+
92+
cat ./checker/specification/specification.md ./checker/specification/staging.md > all.md
93+
cargo run -p ezno-parser --example code_blocks_to_script all.md --comment-headers --out ./all.tsx
94+
95+
./target/release/ezno check all.tsx --timings || true
96+
echo "::endgroup::"
97+
98+
- name: Run checker performance on large file
99+
shell: bash
100+
run: |
101+
echo "::group::Running large"
102+
103+
cat ./checker/specification/specification.md > main.md
104+
cargo run -p ezno-parser --example code_blocks_to_script all.md --comment-headers --out ./code.tsx
105+
for i in {1..10}; do
106+
cat ./code.tsx >> large.tsx
107+
done
108+
109+
./target/release/ezno check large.tsx --timings --max-diagnostics 0 || true
110+
echo "::endgroup::"
111+
85112
- name: Run parser, minfier/stringer performance
86113
shell: bash
87114
run: |
88115
strings=(
89116
"https://esm.sh/v128/react-dom@18.2.0/es2022/react-dom.mjs"
90-
"https://esm.sh/v135/typescript@5.3.3/es2022/typescript.mjs"
91117
)
118+
# Currently broken "https://esm.sh/v135/typescript@5.3.3/es2022/typescript.mjs"
92119
93120
for url in "${strings[@]}"; do
94121
curl -sS $url > input.js

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ node_modules
1010
/TODO.txt
1111
checker/specification/Cargo.lock
1212
checker/definitions/es5.d.ts
13+
.grit

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Now in the `ezno` directory, `cargo run` should show the CLI.
2525
You can run just the checker with
2626

2727
```shell
28-
cargo run -p ezno-checker --example run-checker path/to/file.ts
28+
cargo run -p ezno-checker --example run_checker path/to/file.ts
2929
```
3030

3131
> [!TIP]

Cargo.lock

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+7-3
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,20 @@ js-sys = "0.3"
7979
tsify = "0.4.5"
8080

8181
[workspace.lints.clippy]
82-
all = "deny"
83-
pedantic = "deny"
82+
all = { level = "deny", priority = -1 }
83+
pedantic = { level = "deny", priority = -1 }
8484
cast_precision_loss = "warn"
8585
cast_possible_truncation = "warn"
8686
cast_sign_loss = "warn"
8787
default_trait_access = "allow"
8888
missing_errors_doc = "allow"
8989
missing_panics_doc = "allow"
90-
implicit_hasher = "allow"
9190
module_name_repetitions = "allow"
9291
too_many_lines = "allow"
9392
new_without_default = "allow"
9493
result_unit_err = "allow"
94+
thread_local_initializer_can_be_made_const = "allow"
95+
implicit_hasher = "allow"
96+
97+
[profile.dev]
98+
debug = false

README.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
A JavaScript compiler and TypeScript checker written in Rust with a focus on static analysis and runtime performance.
22

33
> [!IMPORTANT]
4-
> Ezno is in active development and **does not currently support enough features to check existing projects**. Check out the [getting started guide](./checker/documentation/getting-started.md) for experimenting with what it [currently supports](./checker/specification/specification.md).
4+
> Ezno is in active development and **does not currently support enough features to check existing projects** (see [blocking issues](https://github.com/kaleidawave/ezno/labels/blocking)). Check out the [getting started guide](./checker/documentation/getting-started.md) for experimenting with what it [currently supports](./checker/specification/specification.md).
55
66
<!-- ![project lines of code](https://projects.kaleidawave.workers.dev/project/ezno/badge) -->
77

@@ -21,7 +21,7 @@ What Ezno is not
2121
- Be on parity with TSC or 1:1, it has some different behaviors **but** should work in existing projects using TSC
2222
- Faster as a means to serve large codebases. Cut out bloat and complex code first!
2323
- Smarter as a means to allow more *dynamic patterns*. Keep things simple!
24-
- A binary executable compiler. It takes in JavaScript (or a TypeScript or Ezno superset) and does similar processes to traditional compilers, but at the end emits JavaScript. However, in the future, it _could_ generate a lower level format using its event (side-effect) representation.
24+
- A binary executable compiler. It takes in JavaScript (or a TypeScript or Ezno superset) and does similar processes to traditional compilers, but at the end emits JavaScript. However, in the future, it *could* generate a lower level format using its event (side-effect) representation.
2525

2626
Read more about Ezno (in chronological order)
2727
- [Introducing Ezno](https://kaleidawave.github.io/posts/introducing-ezno/)
@@ -40,7 +40,6 @@ This project is a workspace consisting of a few crates:
4040
<!-- | ezno-web-framework | ![](https://projects.kaleidawave.workers.dev/project/framework/badge) | Visitors and code generation for JSX and reactive expression transformations. | -->
4141
<!-- | ezno-lsp | ![](https://projects.kaleidawave.workers.dev/project/framework/badge) | Visitors and code generation for JSX and reactive expression transformations. | -->
4242

43-
4443
## Help contribute
4544

4645
Check out [good first issues]((https://github.com/kaleidawave/ezno/issues?q=is%3Aopen+label%3Agood-first-issue%2Cfeedback-needed)) and comment on discussions! Feel free to ask questions on parts of the code of the checking implementation.

checker/Cargo.toml

+3-1
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,12 @@ tsify = "0.4.5"
4848
# TODO needs unfixed change in source-map
4949
wasm-bindgen = "=0.2.89"
5050

51-
5251
[dependencies.parser]
5352
path = "../parser"
5453
optional = true
5554
version = "0.1.5"
5655
features = ["extras"]
5756
package = "ezno-parser"
57+
58+
[dev-dependencies]
59+
match_deref = "0.1.1"

checker/definitions/internal.ts.d.bin

3.64 KB
Binary file not shown.

checker/definitions/overrides.d.ts

+50-47
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
@Constant
2-
declare function debug_type_independent(t: any): void;
3-
41
// Eventually this will be merged with existing TS es5.d.ts files but for now is the standalone see #121
52

63
interface ImportEnv {
7-
[key: string]: string | undefined;
4+
[key: string]: string;
85
}
96

107
interface ImportMeta {
@@ -14,7 +11,7 @@ interface ImportMeta {
1411
}
1512

1613
declare class Array<T> {
17-
[index: number]: T | undefined;
14+
[index: number]: T;
1815

1916
length: number;
2017

@@ -33,8 +30,7 @@ declare class Array<T> {
3330
return undefined
3431
} else {
3532
const value = this[--this.length];
36-
// TODO this currently breaks value?
37-
// delete this[this.length];
33+
delete this[this.length];
3834
return value
3935
}
4036
}
@@ -101,35 +97,6 @@ declare class Array<T> {
10197
return false
10298
}
10399

104-
// fill(value: T, start: number = 0, end = this.length): this {
105-
// // TODO
106-
// return this
107-
// }
108-
109-
// reduce<U>(cb: (acc: U, t: T, i?: number) => U, initial?: U): U {
110-
// const { length } = this;
111-
// let acc = initial ?? this[0];
112-
// let i: number = typeof initial === "undefined" ? 1 : 0;;
113-
// while (i < length) {
114-
// const value = this[i];
115-
// acc = cb(acc, value, i++);
116-
// }
117-
// return acc;
118-
// }
119-
120-
// includes(searchElement: T, fromIndex?: number): boolean {
121-
// const { length } = this;
122-
// // TODO this is currently broken
123-
// let i: number = fromIndex ?? 0;
124-
// while (i < length) {
125-
// const value = this[i++];
126-
// if (value === searchElement) {
127-
// return true
128-
// }
129-
// }
130-
// return false
131-
// }
132-
133100
join(joiner: string = ","): string {
134101
const { length } = this;
135102
let i: number = 1;
@@ -173,22 +140,28 @@ declare class Math {
173140
static sqrt(x: number): number;
174141
@Constant
175142
static cbrt(x: number): number;
143+
@Constant
144+
static log(x: number): number;
176145

177146
// TODO newer method
178147
@Constant
179148
static trunc(x: number): number;
180149

181150
static PI: 3.141592653589793
151+
static E: 2.718281828459045
152+
153+
@InputOutput
154+
static random(): number;
182155
}
183156

184157
@Primitive("string")
185158
declare class String {
186-
[index: number]: string | undefined;
159+
[index: number]: string;
187160

188161
@Constant
189-
toUpperCase(): string;
162+
toUpperCase(this: string): string;
190163
@Constant
191-
toLowerCase(): string;
164+
toLowerCase(this: string): string;
192165

193166
get length(): number;
194167

@@ -294,11 +267,11 @@ declare class SyntaxError extends Error {
294267

295268
declare class JSON {
296269
// TODO any temp
297-
@Constant("json:parse", SyntaxError)
270+
@Constant("JSON:parse", SyntaxError)
298271
static parse(input: string): any;
299272

300273
// TODO any temp
301-
@Constant("json:stringify")
274+
@Constant("JSON:stringify")
302275
static stringify(input: any): string;
303276
}
304277

@@ -308,26 +281,46 @@ declare class Function {
308281

309282
declare class Symbols {
310283
// TODO temp
311-
iterator: 199
284+
static iterator: unique symbol "iterator"
312285
}
313286

314287
declare class Proxy {
315288
@Constant("proxy:constructor")
316289
constructor(obj: any, cb: any);
317290
}
318291

292+
// Copied from `es5.d.ts`. Could this be an or
293+
// TODO string keys temp because parser broke
294+
interface PropertyDescriptor {
295+
value?: any;
296+
["get" ? (): any;
297+
["set" ? (v: any): void;
298+
299+
writable?: boolean;
300+
configurable?: boolean;
301+
enumerable?: boolean;
302+
}
303+
319304
declare class Object {
320305
@Constant
321306
static setPrototypeOf(on: object, to: object): object;
322307

323308
@Constant
324309
static getPrototypeOf(on: object): object | null;
325310

326-
// static create(prototype: object): object {
327-
// const n = {};
328-
// Object.setProtoTypeOf(n, prototype);
329-
// return n
330-
// }
311+
@Constant
312+
static freeze(on: object): object;
313+
314+
@Constant
315+
static isFrozen(on: object): boolean;
316+
317+
// TODO defineProperties via body (not constant)
318+
@Constant
319+
static defineProperty(on: object, property: string, discriminator: PropertyDescriptor): boolean;
320+
321+
// TODO getOwnPropertyDescriptors via body (not constant)
322+
@Constant
323+
static getOwnPropertyDescriptor(on: object, property: string): PropertyDescriptor;
331324

332325
static keys(on: { [s: string]: any }): Array<string> {
333326
const keys: Array<string> = [];
@@ -353,6 +346,14 @@ declare class Object {
353346
return entries
354347
}
355348

349+
// TODO multiple arguments
350+
static assign(target: object, source: object): object {
351+
for (const key in source) {
352+
target[key] = source[key]
353+
}
354+
return target
355+
}
356+
356357
// static fromEntries(iterator: any): object {
357358
// const obj = {};
358359
// for (const item of iterator) {
@@ -415,6 +416,8 @@ declare function debug_context(): void;
415416
declare function context_id(): void;
416417
@Constant
417418
declare function context_id_chain(): void;
419+
@Constant
420+
declare function debug_type_independent(t: any): void;
418421

419422
// A function, as it should be!
420423
@Constant

0 commit comments

Comments
 (0)