Skip to content

Add tokens for signed/unsigned 128bit integer values.#4566

Merged
yebblies merged 1 commit intodlang:masterfrom
redstar:centliteral
Apr 6, 2015
Merged

Add tokens for signed/unsigned 128bit integer values.#4566
yebblies merged 1 commit intodlang:masterfrom
redstar:centliteral

Conversation

@redstar
Copy link
Contributor

@redstar redstar commented Apr 6, 2015

Add the tokens to the token list and adds them to the parser where needed.
Does not add a lexer for these values - they are unused.

See ldc-developers/ldc#891 for the use case.

Add the tokens to the token list and adds them to the parser where needed.
Does not add a lexer for these values - they are unused.

See ldc-developers/ldc#891 for the use case.
@yebblies
Copy link
Contributor

yebblies commented Apr 6, 2015

Do you know if we can just have a single token type for integer literals? Or possibly just a signed and an unsigned?

@yebblies
Copy link
Contributor

yebblies commented Apr 6, 2015

What's the plan for parser support and the rest of frontend integration? Something like complex_t?

@redstar
Copy link
Contributor Author

redstar commented Apr 6, 2015

Depending on the value of the literal and the postfix flags (U, L) the lexer decides about the token type. The parser uses this information to choose the type passed to IntegerExp. I fear that it is not easy to get rid of the multiple tokens.

@yebblies
Copy link
Contributor

yebblies commented Apr 6, 2015

Oh yeah, I forgot about the postfixes. I guess it could be done like string literals, with flags for those things.

@yebblies
Copy link
Contributor

yebblies commented Apr 6, 2015

Auto-merge toggled on

yebblies added a commit that referenced this pull request Apr 6, 2015
Add tokens for signed/unsigned 128bit integer values.
@yebblies yebblies merged commit 7f82e0f into dlang:master Apr 6, 2015
@redstar
Copy link
Contributor Author

redstar commented Apr 6, 2015

My plan is to integrate the support in the frontend. My ldc pull mostly changes frontend code.
I have no plans for the dmd backend...

@yebblies
Copy link
Contributor

yebblies commented Apr 6, 2015

Yes, I'm only asking about the frontend. ctfe will need 128-bit integer support, like complex_t is currently used (and longdouble).

@ibuclaw
Copy link
Member

ibuclaw commented Apr 6, 2015

I'd wait until ddmd to land first before 128bit CTFE support. Better to leverage std.bigint rather than invent a new synthetic type for N-bit integer support.

@yebblies
Copy link
Contributor

yebblies commented Apr 6, 2015

Heh we'll see. 128-bit ints are a lot simpler than full bigint, and the complications using phobos brings.

@redstar
Copy link
Contributor Author

redstar commented Apr 6, 2015

I currently take advantage of GCC's __int128 but this is no general solution.

@redstar redstar deleted the centliteral branch April 6, 2015 15:23
@ibuclaw
Copy link
Member

ibuclaw commented Apr 7, 2015

@yebblies, you have two choices really.

  1. Have a struct doubleInt { ulong, ulong } type with all necessary overload operators to interact with normal integers (the type itself just encodes the low and high parts of 128bit types).
  2. Use bigint and get the same thing but with N-bit precision.

The same should really be done with real/double/float also. (OT, but I found that when talking to developers, they care more about consistent results in CTFE, not accurate when it comes to floating point).

@yebblies
Copy link
Contributor

yebblies commented Apr 7, 2015

Choice 1 sounds sufficient and preferable!

One of the big annoyances is going to be that D doesn't have implicit struct construction, so there are 1000s of places in the frontend that will need an explicit constructor call.

@ibuclaw
Copy link
Member

ibuclaw commented Apr 7, 2015

We do the same with ldouble(0) - it's expected. :)

@yebblies
Copy link
Contributor

yebblies commented Apr 7, 2015

I know, it's just annoying. :(

@ibuclaw
Copy link
Member

ibuclaw commented Apr 8, 2015

Choice 1 sounds sufficient and preferable!

Maybe we should start writing one and see? I've started one, now fill in the gaps. ;)

http://dpaste.dzfl.pl/909ccfd0de17

@yebblies
Copy link
Contributor

yebblies commented Apr 8, 2015

@ibuclaw
Copy link
Member

ibuclaw commented Apr 8, 2015

It's a bit incomplete, no?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants