gsdlab / clafer

Clafer is a lightweight modeling language
http://clafer.org
MIT License
45 stars 13 forks source link

Parent fix #37

Closed Luke-Michael-Brown closed 11 years ago

Luke-Michael-Brown commented 11 years ago

Changes how the compiler finds parents. Removes the parent map and adds an argument to IClafer.

See i255.

JLiangWaterloo commented 11 years ago

Everything looks fine. Luke, can you clarify what it means to be a parent of a PExp?

For example, here's the model:

A -> int ? [ this.ref = 3 ]

So the parent of the expression "this.ref = 3" should be "A". Is the parent of the subexpression "this.ref" also "A"?

mantkiew commented 11 years ago

We have just clarified it - the parent of a PExp can be only another PExp. Otherwise, the PExp is top-level and it is nested under IConstraint, ISuper, IReference, etc. Luke will fix that directly in develop.

We are making a compromise here - it would be an overkill to have every single IR element have a parent pointer. So, we're adding them only to the major ones (IClafer, IConstraint, IGoal, PExp) and for the rest, the functions will have to carry around the context (say, I am analyzing ISuper of clafer X, since there's no parent link from ISuper back to IClafer, then my function will have to carry IClafer for X around). We might consider adding parents everywhere later if we find it needed.

A consequence of this change is that we can now remove the SClafer infrastructure.

Jimmy, do you think we should have parents for every IR node? It's a huge change - maybe we should introduce them once there's a concrete need?

Luke-Michael-Brown commented 11 years ago

Me and Michael just had a talk about this I'm going to change it to PExp parent to Maybe PExp. So if the PExp's exp has a PExp that PExp will point to the orgianl PExp.

On Tue, Aug 20, 2013 at 10:29 AM, Jimmy Liang notifications@github.comwrote:

Everything looks fine. Luke, can you clarify what it means to be a parent of a PExp?

For example, here's the model:

A -> int ? [ this.ref = 3 ]

So the parent of the expression "this.ref = 3" should be "A". Is the parent of the subexpression "this.ref" also "A"?

— Reply to this email directly or view it on GitHubhttps://github.com/gsdlab/clafer/pull/37#issuecomment-22948794 .

mantkiew commented 11 years ago

Jimmy, for your model, the constraint is top-level, the parent of this.ref = 3 is the constraint (but we don't have a pointer for that in IR for now), the parent of both this.ref and 3 is the PExp for the whole this.ref = 3. So, PExps form a hierarchy and PExpParent will point to the parent PExp if nested or be Nothing if the PExp is top-level (e.g., directly in IConstraint or ISuper).

mantkiew commented 11 years ago

I clarified these issues in i255 on Bugbot.