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

Does it support bitwise operations #206

Closed
ygl-rg opened this issue Dec 11, 2021 · 2 comments · Fixed by #208
Closed

Does it support bitwise operations #206

ygl-rg opened this issue Dec 11, 2021 · 2 comments · Fixed by #208

Comments

@ygl-rg
Copy link

ygl-rg commented Dec 11, 2021

Hi

I like this prj and want to use it for our iot applications

Our user cases involve bitwise operations which I am not sure are supported or not.

Regards

Ygl

@metoule
Copy link
Contributor

metoule commented Dec 11, 2021

Relevant C# documentation: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/bitwise-and-shift-operators

It seems that they're not:

var target = new Interpreter();
var x = 0b_1100_1001_0000_0000_0000_0000_0001_0001;
target.SetVariable("x", x);

// operators not implemented
Assert.Equal(~x, target.Eval<uint>("~x"));
Assert.Equal(x >> 4, target.Eval<uint>("x >> 4"));
Assert.Equal(x << 4, target.Eval<uint>("x << 4"));

// failure to resolve the operator
Assert.Equal(x & 4, target.Eval<uint>("x & 4"));
Assert.Equal(x | 4, target.Eval<uint>("x | 4"));
Assert.Equal(x ^ 4, target.Eval<uint>("x ^ 4"));

@metoule
Copy link
Contributor

metoule commented Dec 11, 2021

@ygl-rg do you have some example of the kind of operations you're likely to encounter?

@metoule metoule self-assigned this Dec 11, 2021
metoule added a commit to metoule/DynamicExpresso that referenced this issue Dec 11, 2021
Added support of the shift operators (>> and <<).
Fix dynamicexpresso#206
metoule added a commit that referenced this issue Dec 13, 2021
Added support of the unary bitwise complement operator (~).
Added support of the shift operators (>> and <<).
Fix #206
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants