1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-09-27 21:57:28 +00:00

Minor refactoring.

This commit is contained in:
jespergravgaard 2019-11-24 11:19:57 +01:00
parent 59ab4e0eb1
commit 1883da7a86
3 changed files with 11 additions and 10 deletions

View File

@ -57,9 +57,6 @@ public class Variable implements Symbol {
/** Specifies the register the variable must be put into during execution. [Only variables] */
private Registers.Register declaredRegister;
/** Non-null if the variable is an array. */
private ArraySpec arraySpec;
/** Specifies that the variable is declared as const */
private boolean declaredConst;
@ -75,7 +72,7 @@ public class Variable implements Symbol {
/** Specifies that the variable must live in a register if possible (CPU register or ZP-address). */
private boolean declaredAsRegister;
/** The memory area where the variable lives (if stored in memory). [Only variables] */
/** The memory area where the variable lives (if stored in memory). [Only variables and arrays] */
private MemoryArea memoryArea;
/** Comments preceding the procedure in the source code. [ALL] */
@ -87,6 +84,9 @@ public class Variable implements Symbol {
/** The constant value if the variable is a constant. Null otherwise. [Only constants] */
private ConstantValue constantValue;
/** Non-null if the variable is an array. [Only constants that are arrays]*/
private ArraySpec arraySpec;
/** The number of the next version (only used for PHI masters) [Only PHI masters] */
private Integer nextPhiVersionNumber;
@ -157,7 +157,7 @@ public class Variable implements Symbol {
* @param phiMaster The PHI master variable.
* @param version The version number
*/
public Variable(Variable phiMaster, int version) {
private Variable(Variable phiMaster, int version) {
this(phiMaster.getName() + "#" + version, Kind.PHI_VERSION, phiMaster.getType(), phiMaster.getScope(), phiMaster.getMemoryArea(), phiMaster.getDataSegment());
this.setArraySpec(phiMaster.getArraySpec());
this.setDeclaredAlignment(phiMaster.getDeclaredAlignment());

View File

@ -48,13 +48,13 @@ public class ConstantSymbolPointer implements ConstantValue {
if(variable.isKindPhiMaster()) {
Collection<Variable> versions = variable.getScope().getVersions(variable);
for(Variable version : versions) {
if(variable.isVariable())
if(variable.isVariable()) {
variable = version;
break;
}
}
}
Registers.Register allocation = variable.getAllocation();
if(allocation != null && Registers.RegisterType.ZP_MEM.equals(allocation.getType())) {
int zp = ((Registers.RegisterZpMem) allocation).getZp();
@ -64,7 +64,7 @@ public class ConstantSymbolPointer implements ConstantValue {
}
}
}
// WE cannot calculate a literal value
// We cannot calculate a literal value
throw new ConstantNotLiteral("Cannot calculate literal var pointer");
}

View File

@ -77,9 +77,10 @@ public class PassNStructAddressOfRewriting extends Pass2SsaOptimization {
if(variable.isKindPhiMaster()) {
Collection<Variable> versions = variable.getScope().getVersions(variable);
for(Variable version : versions) {
if(variable.isVariable())
if(variable.isVariable()) {
variable = version;
break;
break;
}
}
}