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

Improve implementation of literal values #96

Open
ShivamSarodia opened this issue Apr 23, 2018 · 2 comments
Open

Improve implementation of literal values #96

ShivamSarodia opened this issue Apr 23, 2018 · 2 comments

Comments

@ShivamSarodia
Copy link
Owner

Today, ILValues have a literal_val attribute that stores None if the ILValue does not have a known compile-time integer literal value, or the integer value as a Python number if it does.

A better implementation of literal values would involve a LiteralValue class, from which IntegerLiteralValue, StringLiteralValue, etc. would inherit. Then, the literal_val attribute of an IL value that has a fixed value known at compile time would be an instance of a subclass of LiteralValue.

@ShivamSarodia
Copy link
Owner Author

@christian-stephen is taking a look at this issue :)

@ShivamSarodia
Copy link
Owner Author

ShivamSarodia commented May 22, 2018

#98 did most of this, but there are still some potential improvements to explore. Specifically, it may be interesting to explore adding a raw() function to the _Literal object. Then, we write something like literal.raw() to get a raw representation of the literal value that can be directly inserted into ASM code.

Also, the code in #98 assumes that the type of the literal for an IL value will be compatible with the type of the IL value itself; that is, an IL value of integral type will have a literal_val of only integral type. While this works for now, I'm not sure it's a fair assumption going forwards. To protect for this, we can add a test for int array[5]; array[(int)"hello"]

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

1 participant