Comments (3)
This works now. It's a bit stupid because we construct arrays when printing, but we can fix that later.
from genjvm.
This is the current implementation of Enum.toString
:
public function toString() {
var baseName = Type.getEnumConstructs(Type.getEnum(cast this))[_hx_index];
var parameters = Type.enumParameters(cast this);
if (parameters.length == 0) {
return baseName;
}
return '$baseName(${@:privateAccess parameters.join(", ")})';
}
This is obviously not efficient because Type.enumParameters
does dynamic lookup on the enum fields. The alternative would be to have a custom toString
on every enum constructor class, but there can be lots of those and I'm worried about spamming the method storage area.
from genjvm.
I'll go ahead and "this is fine" here because I don't care much about printing performance. If this proves to be an issue in some situation we can always improve on it later.
from genjvm.
Related Issues (20)
- Stack overflow on recursive signatures HOT 6
- StringBuf.add vs. Int HOT 2
- Invalid boxed primitve comparison HOT 8
- Assertion on nested native arrays
- [quest] Haxe unit test compilation HOT 2
- Missing super call on field-init-generated constructor HOT 1
- Last `case` does not need a goto
- API patches (like String methods) HOT 2
- javac synchronized equivalent HOT 4
- Interfaces vs. type parameters HOT 4
- haxe.CallStack HOT 3
- Emojis HOT 1
- [quest] Haxe unit test verification endgame HOT 1
- `@:strict`
- enums again HOT 2
- switch on string HOT 1
- Boolop generation isn't ideal HOT 1
- Method name clashes HOT 2
- Box-variance HOT 2
- haxe-checkstyle failures HOT 7
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 genjvm.