Comments (3)
I already thought about this some time ago, but for some reason (that I don't remember ATM), it wasn't that easy to implement in this context. So I decided against it. When I find the time, I might take a look at it again...
from basicv2.
Thinking about it, I remember my actual problem with it. This logic applies to AND and OR when they are boolean operators. But in BASIC V2, what they actually are, are bitwise AND and OR operators. That means, that
if x=5 and y=12 then...
can easily be optimized to
if x=5 then if y=12 then...
(which is the same as you've suggested, but in BASIC source code)
but something like
if a and 8 then...
can't. Or more complex:
if (b>2)*-8 and 2*b then ...
can't either. Right now, I'm lacking a clever idea how to separate these cases correctly without going overboard with it...hmm...
from basicv2.
thinking about it... when evaluating the AST, your expression nodes might also include a isBoolean
property that bubbles up to the root, e.g.
b<2 => return { ..., isBoolean: true }
b * 4 => return { ..., isBoolean: false }
expr1 AND expr2 => return { ..., isBoolean: expr1.isBoolean AND expr2.isBoolean }
expr1 OR expr2 => return { ..., isBoolean: expr1.isBoolean AND expr2.isBoolean }
then you can check the root node of your IF
expression and if it's isBoolean
you can apply short circuit optimization. Something like this.
from basicv2.
Related Issues (20)
- IndexOutOfBoundsException thrown in Integer Pass 1 HOT 2
- Interpreter: if condition wrong evaluation HOT 5
- Interpreter: Enhance compatibility for Robins new favourite C64 One-Liner HOT 8
- BasicShell: no INPUT for numeric variable possible HOT 2
- Is PI supported ? HOT 11
- Console Support: add control codes for lower/upper case HOT 8
- BasicShell: Wrong output when PRINT with comma HOT 5
- Console: Wrong output when PRINT with comma HOT 2
- INPUT#/PRINT# problems when using for keyboard/screen HOT 1
- INPUT BUG: Workaround with SHIFT+SPACE and Controlcodes for Cursor movement doesn't work HOT 5
- Loading PRG files works only with compiler HOT 6
- GUI has two different sizes HOT 10
- BasicShell: no run with linenumber HOT 5
- Error compiling: Failed to run optimizer! HOT 3
- TAB function/keyword outside of output functions is being recognized. (C64 BASIC difference) HOT 5
- Any suggestions for debugging a '?illegal quantity error in 0' error? HOT 9
- Add linenumer if there is a SYNTAX ERROR HOT 5
- C64 crashes with blue screen HOT 11
- Code with integers is slower than with real variables HOT 7
- Support keyword abbreviations HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from basicv2.