MCPcopy Create free account
hub / github.com/witheve/Eve / assignGroups

Method assignGroups

src/runtime/builder.ts:104–153  ·  view source on GitHub ↗
(block)

Source from the content-addressed store, hash-verified

102 }
103
104 assignGroups(block) {
105 let finished = false;
106 while(!finished) {
107 finished = true;
108 for(let equality of block.equalities) {
109 if(equality === undefined) continue;
110 let [left, right] = equality;
111
112 if(left.type === "constant" && right.type === "constant") {
113 // these must be equal, otherwise this query doesn't make any sense
114 if(left.value !== right.value) {
115 this.errors.push(errors.incompatabileConstantEquality(block, left, right));
116 }
117 } else if(left.type === "constant") {
118 let rightGroup = this.getGroup(right);
119 let rightValue = this.groupToValue[rightGroup];
120 // if this is a variable, it came from a parent context and we can't just overwrite it in this case,
121 // the builder handles this case for us by adding explicit equality checks into the scans
122 if(!join.isVariable(rightValue)) {
123 if(rightValue !== undefined && left.value !== rightValue) {
124 this.errors.push(errors.incompatabileVariableToConstantEquality(block, right, rightValue, left));
125 }
126 this.groupToValue[rightGroup] = left.value;
127 }
128 } else if(right.type === "constant") {
129 let leftGroup = this.getGroup(left);
130 let leftValue = this.groupToValue[leftGroup];
131 // if this is a variable, it came from a parent context and we can't just overwrite it in this case,
132 // the builder handles this case for us by adding explicit equality checks into the scans
133 if(!join.isVariable(leftValue)) {
134 if(leftValue !== undefined && leftValue !== right.value) {
135 this.errors.push(errors.incompatabileVariableToConstantEquality(block, left, leftValue, right));
136 }
137 this.groupToValue[leftGroup] = right.value;
138 }
139 } else {
140 let leftGroup = this.getGroup(left);
141 let rightGroup = this.getGroup(right, leftGroup);
142 if(leftGroup !== rightGroup) {
143 if(leftGroup < rightGroup) {
144 this.setGroup(right, leftGroup);
145 } else {
146 this.setGroup(left, rightGroup);
147 }
148 finished = false;
149 }
150 }
151 }
152 }
153 }
154
155 assignRuntimeVariables(block) {
156 let registerToVars = this.registerToVars;

Callers 1

constructorMethod · 0.95

Calls 2

getGroupMethod · 0.95
setGroupMethod · 0.95

Tested by

no test coverage detected