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 runtime.Enum #637

Merged
merged 2 commits into from
Oct 13, 2022
Merged

Add runtime.Enum #637

merged 2 commits into from
Oct 13, 2022

Conversation

UrbanskiDawid
Copy link
Collaborator

this is an implementation of runtime.Enum required for C.1.4 Integer to enumerated int2enum

@UrbanskiDawid
Copy link
Collaborator Author

UrbanskiDawid commented Sep 29, 2022

@WypustekMichal this is for int2enum please use it to implement your function

5nord
5nord previously approved these changes Sep 30, 2022
interpreter/interpreter_test.go Outdated Show resolved Hide resolved
@UrbanskiDawid
Copy link
Collaborator Author

@5nord updated 4357ae7

support for ranges
support for negative values
old Enum is now EnumType
new Enum contains:

  • reference to EnumType
>> type enumerated ET {red(-3), green, blue(+1)};
>> ET
<< ET{red(-3), green(-2), blue(1)}
  • selected key
>> var ET e := red;
>> e
<< ET::red

controversial chantes:

  1. Enum remembers reference to 'type enumerated' (EnumType)
  2. adding 'type enumerated' (EnumType) in interpreter now add 'frozen' Enums to env for each enum key.

Copy link
Member

@5nord 5nord left a comment

Choose a reason for hiding this comment

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

It's great to see that with only moderate change you model something challenging as TTCN-3 enumeration semantics ☺️

Some details should be worked out. For example: Can we already implement a mechanism to assign the correct enum-type?

ntt -i
ntt dev (none, unknown)
>> type enumerated U { E }
>> type enumerated V { E }
>> var U e := E
>> e
V::E

Also, I like the syntax ::, but it's non-standard. I think in TTCN-3 we should write V.E instead (we need to check this though).

ttcn3/ast/utils.go Outdated Show resolved Hide resolved
runtime/object.go Outdated Show resolved Hide resolved
runtime/object.go Outdated Show resolved Hide resolved
runtime/object.go Show resolved Hide resolved
runtime/object.go Outdated Show resolved Hide resolved
runtime/object.go Show resolved Hide resolved
runtime/object.go Outdated Show resolved Hide resolved
@UrbanskiDawid
Copy link
Collaborator Author

It's great to see that with only moderate change you model something challenging as TTCN-3 enumeration semantics ☺️

Some details should be worked out. For example: Can we already implement a mechanism to assign the correct enum-type?

ntt -i
ntt dev (none, unknown)
>> type enumerated U { E }
>> type enumerated V { E }
>> var U e := E
>> e
V::E

Also, I like the syntax ::, but it's non-standard. I think in TTCN-3 we should write V.E instead (we need to check this though).

done

Copy link
Member

@5nord 5nord left a comment

Choose a reason for hiding this comment

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

The type is not right, do you maybe know why?

ntt -i
ntt dev (none, unknown)
>> type enumerated U { E }
>> type enumerated V { E }
>> var U e := E
>> e
V.E
``

@UrbanskiDawid
Copy link
Collaborator Author

type enumerated U { E }

yes
there are two issues:

  1. 'U.E' is overridden by 'V.E' - I have update this, now this will fail to create enum with same elements
  2. 'e' is assigned without any type checking, it's literally setting 'E' as 'e' in ENV .

@5nord 5nord merged commit 54ecbed into nokia:master Oct 13, 2022
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.

2 participants