goropikari / golox Goto Github PK
View Code? Open in Web Editor NEWGo implementation of Lox
License: MIT License
Go implementation of Lox
License: MIT License
When running a script like:
// This benchmark stresses method invocation by batches
class Toggle {
init(startState) {
this.state = startState;
}
value() { return this.state; }
activate() {
this.state = !this.state;
return this;
}
}
var start = clock();
var val = true;
var toggle = Toggle(val);
var batch = 0;
while (clock() - start < 10) {
for (var i = 0; i < 10000; i = i + 1) {
val = toggle.activate().value();
}
batch = batch + 1;
}
Golox encounters a golang runtime error and panics with: panic: runtime error: hash of unhashable type ast.Call
.
The ast.Call
expression contains a slice of arguments. Golang does not allow the hashing of objects that contain slices and this is what I believe to be the cause of the bug.
The required hashing exists in VisitAssignExpr
. The hash key is currently the interface type Expression so that different kinds of expressions can be hashed locally. Currently all of the expression nodes are passed by value so a possible solution could be to start passing nodes by reference instead of value. Alternatively, we could assign a new function to each node that provides a string for Golang to consistently hash.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.