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

- changed Queue in Validator class to carry unique values in "validated" variable #25

Conversation

adrien2-public
Copy link

I have changed Queue in Validator class to only carry unique values in "validated" variable.

Given the need to compare values in the validated queue (to check for duplicates), it seems more reasonable to override the offer method than it would be to create a new class that will implement a UniqueElements queue.

We are provided with the ability to save unique Statements in a queue, order is kept intact, and we do not depend on another class.

The Statements class already has an overridden "equals" method (in which comparison is made by variables in the class, rather than Object Identifier) which fits well into our "contains" comparison.

@MrMystery10-del
Copy link
Owner

I believe you may have misunderstood the problem. It's not simply a matter of removing duplicates. Let me provide an example: let's say you load variable "a," add a value to it, then load variable "b" and add a value to that. However, you want to load "a" again to add another value, but you can't because "load a" is considered a anymore duplicate.

This is a not validated for duplicates code:

dir global
type int
op +
var variable
load variable
set 0
var variable2
load variable2
set 0
load variable2
add 10

And it should be converted to:

dir global
type int
op +
var variable
load variable
set 0
var variable2
load variable2
set 0
add 10

It removed the last load because variable2 were already loaded.
Also you need to keep in mind loops, for example:

dir global
type int
op +
var variable
load variable
set 0
block
con true
skip
load variable
add 10
jump
end

Can be converted to:

dir global
type int
op +
var variable
load variable
set 0
block
con true
skip
add 10
jump
end

But when you have a while loop which loads many variables:

dir global
type int
op +
var variable
load variable
set 0
var variable2
load variable2
set 0
block
con true
skip
load variable2
add 10
load variable
add 10
jump
end

You cant just remove the load even if it is already loaded because the while loop jumps back and then a false variable will be loaded

@MrMystery10-del MrMystery10-del added invalid This doesn't seem right compiler Compiler topic and removed mappings labels May 4, 2023
@adrien2-public
Copy link
Author

Ok I see, I don't think i understand it well enough to be able to complete, is it possible to remove me from being an assignee on the issue ?
Thanks

@MrMystery10-del
Copy link
Owner

sure, removed u

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler Compiler topic invalid This doesn't seem right
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants