Commit Graph

196 Commits

Author SHA1 Message Date
강동윤
12944c006a Fix to publish it 2019-01-17 23:38:45 +09:00
강동윤
eebf14fbef
Allow stable rust (#118)
This pr introduces some cargo features. For `swc_common` and `swc_ecma_ast`, it introduces a feature flag `fold`.
`Fold` and `Visit` traits exist only if the feature is enabled.

For `swc_ecma_parser`, flag called `verify` is added. When disabled, we skip checking of validity of some expressions.

e.g. `{foo = bar}`

Verification is disabled by default it requires nightly compiler
2019-01-17 23:17:16 +09:00
강동윤
338759110f Fix parsing of large integers 2019-01-16 11:53:41 +09:00
강동윤
bb28d81ed4 Strip typescript declarations 2019-01-15 20:51:13 +09:00
강동윤
a126afaf42 Better error messages for unimplemented!s 2019-01-15 20:18:41 +09:00
강동윤
b9eb110549 Cache compiled helpers 2019-01-15 11:53:43 +09:00
강동윤
e85bcce9cf implement Clone for passes 2019-01-15 11:15:18 +09:00
강동윤
66eab1bc85 enable flag for the simplifier pass 2019-01-15 10:59:40 +09:00
강동윤
1710bb6e8a Allow using Pass as a trait object 2019-01-14 17:54:42 +09:00
강동윤
2a49e1e896 implement clone for transform passes 2019-01-14 17:36:15 +09:00
강동윤
fefc4c88c7 camelCase for react options 2019-01-14 13:45:19 +09:00
강동윤
1fabc3fa3e debug_assert! instead of assert!
This reduces binary size
2019-01-10 18:54:40 +09:00
강동윤
7aee29d91d Fix tests 2019-01-10 18:33:32 +09:00
강동윤
d4fefa8615
Reduce binary size (#116)
- remove unused debug impls
2019-01-10 18:23:25 +09:00
강동윤
0f0dc1451a Make procmacro2_semver_exempt optional 2019-01-09 09:46:38 +09:00
강동윤
eb22cfb1bd default for syntax configs 2019-01-08 18:27:38 +09:00
강동윤
fc3a9d6180
.swcrc file for configuration (#115)
libswc:
 - use config file
2019-01-08 16:34:35 +09:00
강동윤
ea610c6ded
Typescript & parser for decorators
swc_atoms:
 - add some atoms

swc_ecma_ast:
 - ast nodes for typescript
 - `ClassMethod` -> `Method`, `ClassMethodKind` -> `MethodKind`
 - private class method / class property
 - use separate type for tagged template literals
 - add `declare` field to `Decl`s
 - make function body optional

swc_ecma_parser:
 - rename Type to TokenContext
 - support decorators
 Note: error reporting for invalid decorator is not implemented yet
 - merge `Config` into `Syntax`
 - Use DiagnosticBuilder for error type
This is to make backtracking cheaper.

swc_ecma_transforms:
 - add `strip` pass
2019-01-07 19:43:47 +09:00
강동윤
2e22397f42
Fix hygiene bug (#109) 2018-12-31 23:10:50 +09:00
Leviathan Jeanis
75e83860be
Update proc_macro2 to fix missing join() 2018-12-30 09:48:56 -06:00
강동윤
f89a227d5e implement more traits for Syntax 2018-12-30 13:06:13 +09:00
강동윤
b437488082
implement es3::reserved_word (#103) 2018-12-30 12:56:04 +09:00
강동윤
72c9ac0b5a remove unused fields 2018-12-30 12:14:51 +09:00
강동윤
603b83291d
jsx support (#100)
swc_ecma_parser:
 - implement parser for jsx

swc_ecma_transforms:
 - implement react::jsx transform

swc_ecma_codegen:
 - implement code generator for jsx
2018-12-30 11:57:27 +09:00
강동윤
b6a0d2303b Comment out printlns 2018-12-27 19:20:30 +09:00
강동윤
4d4e4ce979
Implement object rest / spread (#98)
swc_ecma_parser:
 - improve parser's tests
It now shows the code failed to parse
 - allow rest pattern in catch clause
 - fix parsing of named export (semicolon)

swc_ecma_transforms:
 - implement array spread
 - add helper methods (objectWithoutProperties)
 - add some fast paths
 - make es2015::parameters handle catch clauses
 - don't show helpers when execution failed
 - export fixer
2018-12-26 17:09:48 +09:00
강동윤
fbf70a3803 improve performance 2018-12-24 12:49:00 +09:00
강동윤
22b40e2b17
implements async to generator (#91)
swc_ecma_parser:
 - fix parsing of arrow expression

swc_ecma_codegen:
 - fix codegen of async function

swc_ecma_transforms:
 - implement es2017::async_to_generator
2018-12-24 10:58:40 +09:00
강동윤
a5362ebdb8 inline benchmark files and remove submodule 2018-12-22 18:35:44 +09:00
강동윤
6a0a2cf34e
Class getter / setter (#86)
Implement class getter / setter.
2018-12-22 12:15:04 +09:00
강동윤
145d6f39eb
For-of loop (#85)
Implements `es2015::for_of`
2018-12-21 21:39:42 +09:00
강동윤
4ff6d4ed4a
Performance & Node binding (#84)
swc_common:
 - update rustc-ap crates to v313

swc_ecma_ast:
 - use bool instead of Option<Span>


swc_ecma_parser:
 - remove LexerInput
 - use uncons_while
 - assert only on debug mode
 - use Visit instead of Fold while verifying
 - replace debug! with trace!
 - disable logging while benchmarking
 - drop slog

swc_ecma_transforms:
 - classes: fold Decl instead of Stmt

swc:
 - add nodejs binding
2018-12-21 16:54:36 +09:00
강동윤
222bdc191f
Performance (#82)
`Map<T>` adds a method named `map` which is actually `Box<T>` -> `Box<T>` without reallocation.

swc_ecma_transforms:
 - chain_at!(Type, passes)
This macro deeply joins path at 'Type' level.
2018-12-01 22:24:26 +09:00
강동윤
ab7d46c5bc
Es2015 (#80)
swc_common:
 - implement VisitWith for &T and [T]

swc_ecma_ast:
 - fix codegen of `===`

swc_ecma_parser:
 - fix parsing of array pattern


swc_ecma_transforms:
 - implement es2015::destructuring
 - implement es2015::computed_properties
 - implement es2015::duplicate_keys
 - implement es2015::parameters
 - fix `InjectHelper` pass

Note that getters / setters in class are not supported yet

 - Run execution tests via jest
 - ignore es2016::exponentation tests
2018-11-28 12:24:08 +09:00
강동윤
33d296af31
block scoped function and tagged template literal (#77)
swc_ecma_transforms:
 - implement es2015::block_scoped_functions
 - implement tagged template literal without escape handling
 - hygiene: rename to different number
 - scope: handle pattern by folding children


swc_ecma_ast:
 - use Str instead of String for template literal

swc_ecma_parser:
 - fix lexer tests
 - handle template literal correctly
template literals now have cooked field


swc_ecma_codegen:
 - escape newline character and backslash ('\')
2018-11-25 11:31:48 +09:00
강동윤
8524d93e9a spdy -> speedy & black box for benchmark 2018-11-23 19:52:46 +09:00
강동윤
7c58b89571
Scope analysis via ident hygiene (#74)
testing:
 - preserve context of the span in `::testing::DropSpan`

swc_ecma_codegen:
 - disable get_text_of_node to avoid deoptimization

swc_ecma_transforms:
 - allow using this inside arrow expression
 - implement es2015::block_scoping with hygiene ident
2018-11-23 19:22:07 +09:00
강동윤
d3e14b6533
Parser & transformers (#71)
swc_ecma_transforms:
 - implement es2015::arrow (without this support)
 - implement basical scope analysis
 - implement es2015::function_name
 - new.target is supported
 - implement untagged template literals

swc_ecma_parser
 - make test to use load_file()
 - fix eof handling
 - bump version
2018-11-21 18:59:17 +09:00
강동윤
3638dbc42c
Groundwork for linter (#73) 2018-11-20 18:32:53 +09:00
강동윤
dc8e178088 fix parser tests 2018-11-19 19:58:35 +09:00
강동윤
c816d699ca
Improve ast (#70)
* Update ast (bool -> Option<Span>)

* fixup! Update ast (bool -> Option<Span>)
2018-11-19 15:52:06 +09:00
강동윤
cd51cb1731
Make procmacro2_semver_exempt optional (#67)
* Reduce compile time of tests.

* Make procmacro2_semver_exempt optional

* Bump versions
2018-11-18 19:57:35 +09:00
강동윤
1d0c78de6c
More works (#66)
ecma_transforms:
 - implement es2015::instanceof
 - implement es2015::typeof_symbol
 - implement inline_globals pass

ecma_parser:
 - `PResult<T>` is now `Result<T, ()>` and `Err(())` means that an error is emitted.
 - add docs
2018-11-18 14:00:07 +09:00
강동윤
8e0e9ca4c7 Make it thread safe 2018-11-17 17:02:34 +09:00
강동윤
b3a9d1a264
Cleanup (#64)
- rename packages to be consistent
 - `swc_macros` is removed. Now macros are imported with `extern crate macro_name` instead of `extern crate swc_macros`.
 - manage atoms with words.txt file
2018-11-17 16:38:23 +09:00
강동윤
fb08c18f7e
Support es2019 (#63)
ast:
 - Update ast to match es2019 spec

parser:
 - implement es2019 parser
 - ignore an old test

codegen:
 - fix

testing:
 - better output while testing (when failed)

transforms:
 - fix
2018-11-17 12:30:49 +09:00
강동윤
63ee25f0c5
Cleanup (#62)
- do not reexport swc crates

 - Add benchmark for parser

 135ns/op on my macbook pro
 
 - remove unused script
 
 - Update README.md
    - Make features section complete
2018-11-17 10:02:40 +09:00
강동윤
f8ea0bdfea fix
It's not rust code..
2018-11-16 20:26:04 +09:00
강동윤
309a9de0fd
Fix tests & upgrade deps (#60)
common:
 - upgrade rustc-ap crates to 297
 - swc_common does not reexport sourcemap anymore
 - update rustfmt to 0.99.6

simplifier:
 - make some tests success when source code is equavalent
 - implement fixer to fix ast broken by simplifier
- implement bit shift operators
- fix str.length
- ignore some tests


compat:
 - fix `**=`
 - fix es3::prop_lits
2018-11-16 20:09:17 +09:00
강동윤
4f1dc24e40
Update deps (#59)
* constructor codegen

* Update string_cache to 0.7

* make swc_common not depend on sourcemap

* Remove unused dependencies

* update either to 1.5.0

* update rustc-ap crates to 297

* remove unused dependency (fnv)
2018-11-16 11:56:04 +09:00
강동윤
7b56b0bc74
Improve codegen (#57)
* travis: make it faster

* better codegen

* Move enable_comments field to config
2018-11-15 21:43:04 +09:00
강동윤
6234fd7a21
parse "constructor"() as constructor (#56) 2018-11-15 21:29:47 +09:00
강동윤
fae7bfc2c7
Chores (#54)
- improve readme
 - fix lints
 - Enable lto
 - better codegen (newline after stmts)
 - add some docs

 - implement `**=` transformer

 - use `quote_ident!`
 - use `.as_arg()` instead of constructing ExprOrSpread
 - use `as_callee()`
 - inject helpers

 - fix imports

 - split libswc

 - don't mark! useless span
2018-11-15 13:29:44 +09:00
강동윤
5cf15cb40f
Fix tests by updating references (#53) 2018-11-14 21:36:37 +09:00
강동윤
9a5de4beb6
More transcompilers (#49)
transforms:
 - implement String.length simplifier
 - implement more arithmetic operations
 - new Date() is side-effect free
 - implement left.rhs * right
 - optimize `SeqExpr` while creation
 
 - implement es3 - member expression literals pass
 - implement es2015 - classes pass

codegen: 
 - handle infinity correctly
 - disable comments for testing (it's buggy)

ast:
 - add methods about reserved words
2018-11-14 19:40:46 +09:00
강동윤
9d7af34aab
Initial release (#45)
common:
 - rename `Folder` to `Fold`
 - folder.then()
 - impl Fold for Box<F>
 - impl Fold<T> for &mut F where F: Fold<T>

transforms:
 - make Simplifier private
 - organize compat

codegen:
 - use `Mark` to avoid deoptimization

swc:
 - upgrade rayon and use global thread pool instead
2018-11-10 17:44:35 +09:00
강동윤
eb2a2a7f15
Fix tests and lints (#44)
- Temporarilly ignored comment codegen tests.
 - Split Simplify into SimplifyExpr and SimplifyStmt
 - fix lints
2018-11-05 13:12:52 +09:00
강동윤
e12dcf0452
Compiler baseline
- Fix binary
 - Add base for transformers

This will be last large squash.
2018-11-03 16:56:43 +09:00
강동윤
f9be576e02
Ecmascript codegen (#40)
Comment is not fully supported yet
2018-10-25 13:17:05 +09:00
강동윤
0a5f3f4ab5
rustup to 2018-08-29\ (#39)
- libswc is broken
2018-09-16 20:25:41 +09:00
강동윤
5d5f861b9d Update dependencies
- rustc toolchain to "nightly-2018-05-30"
 - rustfmt to 0.8.6
 - rustc-ap-* to 150
 - syn to 0.14
 - proc-macro2 to 0.4
 - quote to 0.6
2018-06-02 18:01:00 +09:00
강동윤
79f3660f0f
Downgrade rust toolchain to 2018-02-01 (#37) 2018-03-09 16:56:43 +09:00
강동윤
4d5efb4a9b Fix test262-parser-tests 2018-03-08 11:17:41 +09:00
강동윤
442302553d Fix library tests for parser 2018-03-08 11:04:25 +09:00
강동윤
57944ab70e Update parser to new ast.
Tests are not updated yet.
2018-03-07 17:14:16 +09:00
강동윤
6141206963 Use spanned, interned string instead of raw string. 2018-03-07 16:50:25 +09:00
강동윤
7908aaa6c1 Some more refinements for ast.
* All fields are public.
 * Enabled some lints.
2018-03-07 14:05:09 +09:00
강동윤
f11434ee3c [WIP] Update parser 2018-03-06 22:34:42 +09:00
강동윤
160f5dc367 Add RestPat 2018-03-06 15:44:28 +09:00
강동윤
00bcd8f9af Don't use #[ast_node] for temporary for-head 2018-03-06 15:07:52 +09:00
강동윤
077e0c551f implement #[span] 2018-03-04 15:17:52 +09:00
강동윤
e1764f907b [WIP] Make ast nodes contain span
* `struct Expr` + `enum ExprKind` -> `enum Expr`

`Expr` / `ExprKind` approach does not work well with recursive
 processing based on the type system because we can't access common
 fields like span while processing child node like `MemberExpr`.

As ast processing is inherently recursive, we should use a
 recursive-friendly approach.

 * `#[derive(FromVariants)]`
It creates lots of `From<T>` to help using ast enums as a real sum type.

 * `#[derive(Spanned)]`

Inspired by https://docs.rs/syn/0.12.13/syn/spanned/trait.Spanned.html

It does not handle attributes yet.

 * Parser is not updated yet.
2018-03-03 19:37:01 +09:00
강동윤
171abda3c0 Implement #[derive(StringEnum)] 2018-03-02 14:50:50 +09:00
강동윤
10f83f3f02
Fix rls (again) (#33)
* Don't use `#[parser]` in lexer

* Don't use `#[parser]` in parser/util.rs

* Pin rust toolchain to nightly-2018-02-28
2018-02-28 14:35:52 +09:00
강동윤
67daa4c4e4
Fix a test about float parser (#32)
See https://github.com/rust-lang/rust/pull/48235
2018-02-27 15:31:50 +09:00
강동윤
4a30fb3436
Testing framework (#31)
- Make rls happy.
  - Some minor parser error improvements.
  - Add reference files for ecmascript parser errors.
  - Improve error message of import/export used outside of a module
2018-02-27 13:21:57 +09:00
강동윤
fa40c8ddf3 Make rls work
rust-analysis chokes with `Option<Box<Expr>>` style fields.
Rls only shows a warning on the crate with that fields, but ICEs on
dependent crates.
This can be workarounded by using `Option<(Box<Expr>)>`.

Also, using multiple glob imports is bad for rls.
So this commit deglobs them.
2018-02-03 20:00:03 +09:00
강동윤
056a11dd06 chores: cleanup for docs; no email from travis 2018-01-27 15:14:53 +09:00
강동윤
59f11a83d1 fixup! fix tests 2018-01-27 13:42:04 +09:00
강동윤
92c7defc2e fix tests 2018-01-27 11:31:45 +09:00
강동윤
5602c376e5 Implement error reporting for ecmascript parser
Passes all test262-identity tests and all fail tests.
2018-01-26 21:53:30 +09:00
강동윤
9b2a5880bb Use FileMap as an input. 2018-01-23 21:38:48 +09:00
강동윤
0a2473fe1c Improve error reporting of ecmascript parser
And drop nll because it's currently too slow.
2018-01-22 21:47:16 +09:00
강동윤
4d52cb49d4 Implement error reporting.
* Use syntax_pos and rustc_error.
 * Use syntax_pos::Span
2018-01-21 17:47:37 +09:00
강동윤
9c646596c5 Fix ecmascript parser.
* Make span inclusive-exclusive.
 * Fix array parsing.
2018-01-17 14:06:05 +09:00
강동윤
d6e61f9638 Make expression and statement consistent. Fixes #19 2018-01-16 11:35:05 +09:00
강동윤
06731dfcb5 Cleanup and documentations for swc_common.
* Remove CanIUse trait, which will be reimpplemented in future
 using Visitor.

 * Remove some other unused stuffs.

 * Change public path of swc_common::fold::* to swc_common::*.
2018-01-15 10:33:18 +09:00
강동윤
fd5b4d0dc0 Revert "Merge remote-tracking branch 'refs/remotes/origin/simplifier'"
This reverts commit 43fcbcbef2, reversing
changes made to 15fde7b5ff.
2018-01-14 14:00:01 +09:00
강동윤
b778f0c398 Rebase 2018-01-14 13:37:32 +09:00
강동윤
5a1c844549 [WIP] simplifier 2018-01-14 13:33:09 +09:00
강동윤
015ccb07f4 [WIP] Working for simplfier 2018-01-14 13:30:50 +09:00
강동윤
15fde7b5ff add op! macro 2018-01-14 13:29:57 +09:00
강동윤
3b02b27d62
groundwork for docs
Ignore two tests. See #8.

Add code coverage and travis to readme.
2018-01-13 20:42:52 +09:00
강동윤
58bc3b4ade [WIP] Working for simplfier 2018-01-13 19:13:32 +09:00
강동윤
4a9d66a0f3 update test262.rs 2018-01-13 19:06:50 +09:00
강동윤
e949c40517
ECMAScript parser (#1)
- Parser and lexer for lastest ecma spec https://tc39.github.io/ecma262

  - Lexer is currently very inefficient

 - Use https://github.com/tc39/test262-parser-tests/ for testing.

 - Implement proc-macro based ast folder and assert_eq_ignore_span! based on it.

 - Some utilities for proc macro at /macros/common
2018-01-12 16:53:06 +09:00