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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type guided '&' translation #683

Open
wants to merge 10 commits into
base: pharo-12
Choose a base branch
from

Conversation

ivojawer
Copy link
Collaborator

@ivojawer ivojawer commented Aug 23, 2023

closes #663

Generates CAST for the & send node (check CCodeGenerator >> generateCASTInferredAnd: aTSendNode) depending on the type of the receiver and argument

  • Throw an error when types mismatch
  • Boolean -> translates to &&
  • Anything else -> translates to &

A TType object was implemented to replace some types, yet most operations are still string-based 馃槩

@ivojawer ivojawer changed the title WIP: Type guided '&' translation Type guided '&' translation Aug 24, 2023
| receiver result |

receiver := 1000.
result := receiver & false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if the boolean is an argument?

methodWithAndIntegerReceiverAndBooleanArgument: arg [

	| receiver result |

	receiver := 1000.
	result := receiver & arg

and all variantas :)

  • boolean & boolean
  • boolean & int
  • int & boolean
  • int & int

Copy link
Collaborator Author

@ivojawer ivojawer Aug 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cases where both (arg and receiver) are boolean/int are covered with methodWithAndBooleanReceiver and methodWithAndIntegerReceiver. Maybe the name should reference the argument 馃槄

The other cases I considered them all the same test case (covered by this method), as they fall under the "if they are different types then throw an error" logic.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but my point is that those tests are on literal booleans/integers!!!
What if the receiver are the result of a more complex expression, say a variable? Do we need a type annotation for booleans?

@PalumboN PalumboN added the slang label Dec 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants