Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support of other primitive data type #134

Open
zonyitoo opened this issue Mar 19, 2015 · 3 comments
Open

Add support of other primitive data type #134

zonyitoo opened this issue Mar 19, 2015 · 3 comments

Comments

@zonyitoo
Copy link

Currently F2J only support decimal integers. Maybe we could also have other primitive numeric types in Java (Byte, Short, Long, Float, Double).

Also, the following should be supported

42L // or 42l
4.2
4.2F // or 4.2f
0x2a // or 0x2A
052 // Octal
0b101010 // Binary

For enhancement, the following could also support ;)

42_000_000_000_0000
0b1010_1001_0110_100
0x42_deadbeef_abc
@linusyang
Copy link
Contributor

@zonyitoo To support other primitive types, the front-end, backend and type-checker all need to be modified. Maybe sub-typing is also required to express the relationship between numbers. But I think @tomtau is now reconstructing and polishing the backend. Maybe we can work on this function after merging the new backend?

By the way, If you really need to use floating point numbers, I have made a patch (linusyang/fcore@c22894c) for supporting basic floating point operations for only naïve compiling method. Expressions like java.lang.Math.sin(1.0) or 2.0E-1f + 3.0f * 4.0f are allowed in that fork (No support for unary operation or type casting).

@bixuanzju
Copy link
Contributor

@linusyang Cool!

@zonyitoo
Copy link
Author

@linusyang It's not that urgent. Since I am writing a parser for F2J, if F2J doesn't support floating point number, then I won't support floating point number either. (Maybe the problem is how to distinguish between 1.2 and 1.toString()?)

I think merging the new backend may be more useful to me, because when the lines of code reach 2000+, the name of *.class files may be too long (as I said on Slack).

Also, if you are refactoring the backend, please consider to support module system with @EmmaBYPeng . I think they are related.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants