-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
381 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
de.peeeq.wurstscript/src/main/java/de/peeeq/wurstscript/intermediatelang/ILconstObject.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package de.peeeq.wurstscript.intermediatelang; | ||
|
||
import com.google.common.collect.HashBasedTable; | ||
import com.google.common.collect.Table; | ||
import de.peeeq.wurstscript.ast.Element; | ||
import de.peeeq.wurstscript.jassIm.ImClass; | ||
import de.peeeq.wurstscript.jassIm.ImClassType; | ||
import de.peeeq.wurstscript.jassIm.ImVar; | ||
|
||
import java.util.*; | ||
import java.util.stream.Collectors; | ||
|
||
public class ILconstObject extends ILconstAbstract { | ||
private final ImClassType classType; | ||
private final int objectId; | ||
private final Table<ImVar, List<Integer>, ILconst> attributes = HashBasedTable.create(); | ||
private boolean destroyed = false; | ||
private final Element trace; | ||
|
||
public ILconstObject(ImClassType classType, int objectId, Element trace) { | ||
this.classType = classType; | ||
this.objectId = objectId; | ||
this.trace = trace; | ||
} | ||
|
||
public int getObjectId() { | ||
return objectId; | ||
} | ||
|
||
@Override | ||
public String print() { | ||
return classType + "_" + hashCode(); | ||
} | ||
|
||
|
||
|
||
@Override | ||
public boolean isEqualTo(ILconst other) { | ||
return other == this; | ||
} | ||
|
||
public void set(ImVar attr, List<Integer> indexes, ILconst value) { | ||
attributes.put(attr, indexes, value); | ||
} | ||
|
||
public Optional<ILconst> get(ImVar attr, List<Integer> indexes) { | ||
return Optional.ofNullable(attributes.get(attr, indexes)); | ||
} | ||
|
||
|
||
public boolean isDestroyed() { | ||
return destroyed; | ||
} | ||
|
||
public void destroy() { | ||
destroyed = true; | ||
} | ||
|
||
public ImClass getImClass() { | ||
return classType.getClassDef(); | ||
} | ||
|
||
public Element getTrace() { | ||
return trace; | ||
} | ||
|
||
public ImClassType getType() { | ||
return classType; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return objectId; | ||
} | ||
|
||
public Table<ImVar, List<Integer>, ILconst> getAttributes() { | ||
return attributes; | ||
} | ||
} |
Oops, something went wrong.