Commit Graph
3903 Commits
Author SHA1 Message Date
Thomas Weber e8d1e449a9 execute: Optimize listIndex 2020-09-09 22:03:56 -05:00
Thomas Weber 80e0bccabc js: Use bitwise | 0 instead of Math.floor in list.get optimization
This is a lot more significant than I imagined it would be.
2020-09-09 22:03:24 -05:00
Thomas Weber 94f09e10b2 js+execute: Remove listGetFast
The ?? operator is used instead.
Older browsers now simply won't get this optimization.
2020-09-09 22:03:24 -05:00
Thomas Weber 36ee6f65de js: Optimize op.less when right side is always a number 2020-09-09 21:52:35 -05:00
Thomas Weber 3ed2fffa0b js: Optimize op.equals when comparing against a constant 0 2020-09-09 21:52:28 -05:00
Thomas Weber e5fa43b452 js: Improve sanitize 2020-09-09 14:42:31 -05:00
Thomas Weber eebd40fec4 Add Input.asNumberOrNaN
Might be used later
2020-09-09 14:29:50 -05:00
Thomas Weber f190934150 Merge branch 'develop' of https://github.com/llk/scratch-vm into develop 2020-09-03 15:13:06 -05:00
DD Liu 7c652246df Merge pull request #2356 from adroitwhiz/cast-to-black
Cast malformed color hex strings to RGBA 0,0,0,255 instead of null
2020-09-03 15:52:52 -04:00
Thomas Weber 7b739fc7f9 js: Nuke VariableInput and Frame 2020-08-31 21:20:59 -05:00
Thomas Weber a4f096ae8d js: remove inheritValues (#15)
The caching of VariableInputs was causing one stack to incorrectly affect another stack.
The fix is to remove inheritValues entirely until a better method of doing this can be found.
A third phase of compilation is the most likely thing.
2020-08-31 19:40:20 -05:00
Thomas Weber 25fc927522 Fix code style 2020-08-31 15:26:00 -05:00
Thomas Weber 37c313b3a1 Use new Function instead of eval when testing for nullish coalescing operator 2020-08-31 15:25:54 -05:00
Thomas Weber f999252917 execute: Cleanup some code 2020-08-31 15:23:19 -05:00
Thomas Weber c50aeaf740 Revert "js: Remove type from VariableInput"
This reverts commit 8f66924fe9.
2020-08-30 16:37:25 -05:00
Thomas Weber 8f66924fe9 js: Remove type from VariableInput 2020-08-30 16:25:14 -05:00
Thomas Weber 9e9b414620 js: Fix VariableInput infinite recursion 2020-08-30 16:09:56 -05:00
Thomas Weber c4bb8fabba js: Use Object.create(null) for variable input cache
This should fix some potential problems when a variable has an ID like toString
2020-08-30 12:48:28 -05:00
Thomas Weber 1ffdc1a2a4 js: Improve variable type analysis
Redundant type casts are now removed.
2020-08-30 12:39:59 -05:00
Thomas Weber 2d7579d6b2 js: Allow the new frame to inherit values from the old frame, if enabled. 2020-08-30 12:39:10 -05:00
Thomas Weber 38f325e73f js: Store the last value a variable was set to for use in analysis 2020-08-30 12:25:23 -05:00
Thomas Weber 14c04ad947 js: Cleanup descendVariable 2020-08-30 12:21:38 -05:00
Thomas Weber 559280f2d5 js: Add VariableInput
This adds a new type of Input for variables.
This input is cached in the current frame.
2020-08-30 12:21:05 -05:00
Thomas Weber 63a755c1f8 ast: remove var.change
var.change is replaced with a var.set
2020-08-30 11:58:03 -05:00
Thomas Weber 2b1b665952 js: Implement basic stack frame tracking 2020-08-30 11:53:39 -05:00
Thomas Weber 8906347ed6 Refactor script compiling
This moves most of JSCompiler into compile, where it should be anyways.
This will make more sense in the future if there is ever more than 1 code generator (asm.js? wasm? glsl? who knows)
2020-08-29 23:01:53 -05:00
Thomas Weber c980b780ed js: Add isConstantInput() helper 2020-08-29 22:41:15 -05:00
Thomas Weber a39701297a js: replace listGetFast with the nullish coalescing operator when supported 2020-08-29 21:06:53 -05:00
Thomas Weber fcd3f35995 js: Remove unused isAlwaysNumberOrNaN 2020-08-29 20:52:47 -05:00
Thomas Weber 1240c31b93 Merge branch 'optimize' into develop 2020-08-29 14:29:50 -05:00
Thomas Weber 2e79194da2 js: Remove some unsafe op.greater, op.less optimizations 2020-08-29 14:04:29 -05:00
Thomas Weber bf6cd9c977 js: Optimize op.greater and op.less similar to op.equals 2020-08-29 13:07:22 -05:00
Thomas Weber f4e97a9e3f js: We stores isAlwaysNumber in a variable, so let's use that instead of running it again 2020-08-29 12:42:26 -05:00
Thomas Weber 41d2084bbd js: Refactor non-zero constant checking out of op.equals 2020-08-29 12:40:59 -05:00
Thomas Weber 0e0a4ea664 js: Fix SafeConstantInput 2020-08-29 12:31:20 -05:00
Thomas Weber 615f113a51 js: tw.lastKeyPressed is final 2020-08-29 12:26:32 -05:00
Thomas Weber 9ee130ee50 js: Optimize op.equals 2020-08-29 12:19:06 -05:00
Thomas Weber 38f5ac8110 js: Introduce SafeConstantInput
It's like ConstantInput, but it won't try to automatically convert your strings to numbers.
2020-08-29 12:09:25 -05:00
Thomas Weber 12837c8cfc ast: Make comment parser more relaxed
- allow tw comment to be on not the first line
 - don't break when newlines are found
2020-08-29 11:36:44 -05:00
Thomas Weber c791dad0e7 ast+js: Compile sensing_dayssince2000
This block is commonly used to get exact timing in Scratch, so it is worthwhile to compile.
2020-08-29 01:29:07 -05:00
Thomas Weber 54213ae4e0 ast: Cleanup Tree typedef 2020-08-29 01:19:01 -05:00
Thomas Weber 378e4f8206 js: trim trailing whitespace 2020-08-29 01:16:02 -05:00
Thomas Weber 87258bf44d Remove misleading comment
It was incorrect.
2020-08-29 00:54:38 -05:00
Thomas Weber 57097d7733 Merge branch 'develop' into number-optimizations 2020-08-29 00:24:33 -05:00
Thomas Weber 66f610b10c ast: Fix scripts opting into stuck checking (#10) 2020-08-28 23:53:14 -05:00
Thomas Weber c2ea3f4efb ast+js: Allow scripts to opt into stuck checking (#10) 2020-08-28 23:35:44 -05:00
Thomas Weber 5434b0a252 ast: Consider procedures_definition a hat 2020-08-28 23:35:09 -05:00
Thomas Weber 82c62ba782 ast: remove unused variable bodyStart 2020-08-28 23:14:13 -05:00
Thomas Weber 12ce7be648 ast: Start parsing procedures from the definition, not the first child
This fixes comments like "tw nocompile"
2020-08-28 23:13:13 -05:00
Thomas Weber bd9de75762 js: Only evaluate opcode function once in compatibility layer 2020-08-28 21:21:33 -05:00