mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-12-18 08:30:18 +00:00
Dropped JSON serialization. Added KickAss JAR.
This commit is contained in:
parent
6b43d797f5
commit
52dd6035a0
13
.idea/libraries/Maven__cml_kickass_kickassembler_4_19.xml
generated
Normal file
13
.idea/libraries/Maven__cml_kickass_kickassembler_4_19.xml
generated
Normal file
@ -0,0 +1,13 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Maven: cml.kickass:kickassembler:4.19">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/cml/kickass/kickassembler/4.19/kickassembler-4.19.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/cml/kickass/kickassembler/4.19/kickassembler-4.19-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/cml/kickass/kickassembler/4.19/kickassembler-4.19-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
@ -1,13 +0,0 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.8.0">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/fasterxml/jackson/core/jackson-annotations/2.8.0/jackson-annotations-2.8.0.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/fasterxml/jackson/core/jackson-annotations/2.8.0/jackson-annotations-2.8.0-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/fasterxml/jackson/core/jackson-annotations/2.8.0/jackson-annotations-2.8.0-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
@ -1,13 +0,0 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Maven: com.fasterxml.jackson.core:jackson-core:2.8.9">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/fasterxml/jackson/core/jackson-core/2.8.9/jackson-core-2.8.9.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/fasterxml/jackson/core/jackson-core/2.8.9/jackson-core-2.8.9-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/fasterxml/jackson/core/jackson-core/2.8.9/jackson-core-2.8.9-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
@ -1,13 +0,0 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Maven: com.fasterxml.jackson.core:jackson-databind:2.8.9">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/fasterxml/jackson/core/jackson-databind/2.8.9/jackson-databind-2.8.9.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/fasterxml/jackson/core/jackson-databind/2.8.9/jackson-databind-2.8.9-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/fasterxml/jackson/core/jackson-databind/2.8.9/jackson-databind-2.8.9-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
@ -20,8 +20,6 @@
|
||||
<orderEntry type="library" name="Maven: com.ibm.icu:icu4j:58.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: junit:junit:4.12" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.8.9" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.8.9" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.8.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: cml.kickass:kickassembler:4.19" level="project" />
|
||||
</component>
|
||||
</module>
|
11
pom.xml
11
pom.xml
@ -24,14 +24,9 @@
|
||||
<version>4.12</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-core</artifactId>
|
||||
<version>2.8.9</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>2.8.9</version>
|
||||
<groupId>cml.kickass</groupId>
|
||||
<artifactId>kickassembler</artifactId>
|
||||
<version>4.19</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
|
@ -1,7 +1,5 @@
|
||||
package dk.camelot64.kickc.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/** SSA form constant integer value */
|
||||
@ -17,7 +15,6 @@ public class ConstantInteger implements ConstantValue {
|
||||
return number;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public SymbolType getType(ProgramScope scope) {
|
||||
return getType();
|
||||
}
|
||||
|
@ -1,9 +1,5 @@
|
||||
package dk.camelot64.kickc.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@ -42,14 +38,13 @@ public class ControlFlowBlock {
|
||||
this.conditionalSuccessor = null;
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public ControlFlowBlock(
|
||||
@JsonProperty("label") LabelRef label,
|
||||
@JsonProperty("scope") ScopeRef scope,
|
||||
@JsonProperty("statements") List<Statement> statements,
|
||||
@JsonProperty("defaultSuccessor") LabelRef defaultSuccessor,
|
||||
@JsonProperty("conditionalSuccessor") LabelRef conditionalSuccessor,
|
||||
@JsonProperty("callSuccessor") LabelRef callSuccessor) {
|
||||
LabelRef label,
|
||||
ScopeRef scope,
|
||||
List<Statement> statements,
|
||||
LabelRef defaultSuccessor,
|
||||
LabelRef conditionalSuccessor,
|
||||
LabelRef callSuccessor) {
|
||||
this.label = label;
|
||||
this.scope = scope;
|
||||
this.statements = statements;
|
||||
@ -75,7 +70,7 @@ public class ControlFlowBlock {
|
||||
* <p>
|
||||
* Fails if there is no call statement
|
||||
*
|
||||
* @param statement The statement to add.
|
||||
* @param newStatement The statement to add.
|
||||
*/
|
||||
public void addStatementBeforeCall(Statement newStatement) {
|
||||
ListIterator<Statement> listIterator = statements.listIterator();
|
||||
@ -198,7 +193,6 @@ public class ControlFlowBlock {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@JsonIgnore
|
||||
public StatementPhiBlock getPhiBlock() {
|
||||
StatementPhiBlock phiBlock = null;
|
||||
if(statements.size() > 0 && statements.get(0) instanceof StatementPhiBlock) {
|
||||
@ -226,7 +220,6 @@ public class ControlFlowBlock {
|
||||
*
|
||||
* @return All successors
|
||||
*/
|
||||
@JsonIgnore
|
||||
public Collection<LabelRef> getSuccessors() {
|
||||
List<LabelRef> successors = new ArrayList<>();
|
||||
if(defaultSuccessor != null) {
|
||||
|
@ -1,9 +1,5 @@
|
||||
package dk.camelot64.kickc.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
@ -25,11 +21,10 @@ public class ControlFlowGraph {
|
||||
this.firstBlockRef = firstBlockRef;
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public ControlFlowGraph(
|
||||
@JsonProperty("blocks") Map<LabelRef, ControlFlowBlock> blocks,
|
||||
@JsonProperty("firstBlockRef") LabelRef firstBlockRef,
|
||||
@JsonProperty("sequence") List<LabelRef> sequence) {
|
||||
Map<LabelRef, ControlFlowBlock> blocks,
|
||||
LabelRef firstBlockRef,
|
||||
List<LabelRef> sequence) {
|
||||
this.blocks = blocks;
|
||||
this.firstBlockRef = firstBlockRef;
|
||||
this.sequence = sequence;
|
||||
@ -43,12 +38,10 @@ public class ControlFlowGraph {
|
||||
blocks.put(block.getLabel(), block);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public ControlFlowBlock getFirstBlock() {
|
||||
return getBlock(firstBlockRef);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public Collection<ControlFlowBlock> getAllBlocks() {
|
||||
if(sequence != null) {
|
||||
ArrayList<ControlFlowBlock> blocks = new ArrayList<>();
|
||||
@ -162,7 +155,6 @@ public class ControlFlowGraph {
|
||||
this.sequence = sequence;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public ControlFlowBlock getMainBlock() {
|
||||
for(ControlFlowBlock block : getAllBlocks()) {
|
||||
LabelRef label = block.getLabel();
|
||||
|
@ -1,9 +1,5 @@
|
||||
package dk.camelot64.kickc.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/** A jump label */
|
||||
public class Label implements Symbol {
|
||||
|
||||
@ -21,10 +17,7 @@ public class Label implements Symbol {
|
||||
this.intermediate = intermediate;
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public Label(
|
||||
@JsonProperty("name") String name,
|
||||
@JsonProperty("intermediate") boolean intermediate) {
|
||||
public Label( String name, boolean intermediate) {
|
||||
this.name = name;
|
||||
this.scope = null;
|
||||
this.intermediate = intermediate;
|
||||
@ -63,7 +56,6 @@ public class Label implements Symbol {
|
||||
return intermediate;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public SymbolType getType() {
|
||||
return SymbolType.LABEL;
|
||||
}
|
||||
@ -101,7 +93,6 @@ public class Label implements Symbol {
|
||||
}
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public LabelRef getRef() {
|
||||
return new LabelRef(this);
|
||||
}
|
||||
|
@ -1,14 +1,9 @@
|
||||
package dk.camelot64.kickc.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/** A reference to a label */
|
||||
public class LabelRef extends SymbolRef {
|
||||
|
||||
@JsonCreator
|
||||
public LabelRef(
|
||||
@JsonProperty("fullName") String fullName) {
|
||||
public LabelRef(String fullName) {
|
||||
super(fullName);
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,5 @@
|
||||
package dk.camelot64.kickc.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@ -20,14 +16,13 @@ public class Procedure extends Scope {
|
||||
this.returnType = returnType;
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
private Procedure(
|
||||
@JsonProperty("name") String name,
|
||||
@JsonProperty("returntype") SymbolType returnType,
|
||||
@JsonProperty("parameterNames") List<String> parameterNames,
|
||||
@JsonProperty("symbols") HashMap<String, Symbol> symbols,
|
||||
@JsonProperty("intermediateVarCount") int intermediateVarCount,
|
||||
@JsonProperty("intermediateLabelCount") int intermediateLabelCount) {
|
||||
String name,
|
||||
SymbolType returnType,
|
||||
List<String> parameterNames,
|
||||
HashMap<String, Symbol> symbols,
|
||||
int intermediateVarCount,
|
||||
int intermediateLabelCount) {
|
||||
super(name, symbols, intermediateVarCount, intermediateLabelCount);
|
||||
this.returnType = returnType;
|
||||
this.parameterNames = parameterNames;
|
||||
@ -41,7 +36,6 @@ public class Procedure extends Scope {
|
||||
this.parameterNames = parameterNames;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public Label getLabel() {
|
||||
return new Label(getFullName(), getScope(), false);
|
||||
}
|
||||
@ -50,7 +44,6 @@ public class Procedure extends Scope {
|
||||
return returnType;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public List<Variable> getParameters() {
|
||||
ArrayList<Variable> parameters = new ArrayList<>();
|
||||
for(String name : parameterNames) {
|
||||
@ -108,7 +101,6 @@ public class Procedure extends Scope {
|
||||
return res.toString();
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public ProcedureRef getRef() {
|
||||
return new ProcedureRef(this.getFullName());
|
||||
}
|
||||
|
@ -1,14 +1,9 @@
|
||||
package dk.camelot64.kickc.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/** A reference to a procedure */
|
||||
public class ProcedureRef extends ScopeRef {
|
||||
|
||||
@JsonCreator
|
||||
public ProcedureRef(@JsonProperty("fullName") String fullName) {
|
||||
public ProcedureRef(String fullName) {
|
||||
super(fullName);
|
||||
}
|
||||
|
||||
@ -17,7 +12,6 @@ public class ProcedureRef extends ScopeRef {
|
||||
*
|
||||
* @return The label of the code block
|
||||
*/
|
||||
@JsonIgnore
|
||||
public LabelRef getLabelRef() {
|
||||
return new LabelRef(getFullName());
|
||||
}
|
||||
@ -27,7 +21,6 @@ public class ProcedureRef extends ScopeRef {
|
||||
*
|
||||
* @return The label of the code block
|
||||
*/
|
||||
@JsonIgnore
|
||||
public LabelRef getReturnBlock() {
|
||||
return new LabelRef(getFullName() + "::" + SymbolRef.PROCEXIT_BLOCK_NAME);
|
||||
}
|
||||
|
@ -1,9 +1,5 @@
|
||||
package dk.camelot64.kickc.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/** The program scope containing the symbols of a program */
|
||||
@ -14,12 +10,11 @@ public class ProgramScope extends Scope {
|
||||
super("", null);
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
private ProgramScope(
|
||||
@JsonProperty("name") String name,
|
||||
@JsonProperty("symbols") HashMap<String, Symbol> symbols,
|
||||
@JsonProperty("intermediateVarCount") int intermediateVarCount,
|
||||
@JsonProperty("intermediateLabelCount") int intermediateLabelCount) {
|
||||
String name,
|
||||
HashMap<String, Symbol> symbols,
|
||||
int intermediateVarCount,
|
||||
int intermediateLabelCount) {
|
||||
super(name, symbols, intermediateVarCount, intermediateLabelCount);
|
||||
}
|
||||
|
||||
@ -28,7 +23,6 @@ public class ProgramScope extends Scope {
|
||||
return new SymbolTypeProgram();
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getSymbolTableContents(Program program) {
|
||||
return toString(program, null);
|
||||
}
|
||||
|
@ -1,9 +1,5 @@
|
||||
package dk.camelot64.kickc.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
@ -15,7 +11,6 @@ public abstract class Scope implements Symbol {
|
||||
private HashMap<String, Symbol> symbols;
|
||||
private int intermediateVarCount = 0;
|
||||
private int intermediateLabelCount = 1;
|
||||
@JsonIgnore
|
||||
private Scope parentScope;
|
||||
|
||||
public Scope(String name, Scope parentScope) {
|
||||
@ -24,12 +19,11 @@ public abstract class Scope implements Symbol {
|
||||
this.symbols = new LinkedHashMap<>();
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public Scope(
|
||||
@JsonProperty("name") String name,
|
||||
@JsonProperty("symbols") HashMap<String, Symbol> symbols,
|
||||
@JsonProperty("intermediateVarCount") int intermediateVarCount,
|
||||
@JsonProperty("intermediateLabelCount") int intermediateLabelCount) {
|
||||
String name,
|
||||
HashMap<String, Symbol> symbols,
|
||||
int intermediateVarCount,
|
||||
int intermediateLabelCount) {
|
||||
this.name = name;
|
||||
this.symbols = symbols;
|
||||
this.intermediateVarCount = intermediateVarCount;
|
||||
@ -74,7 +68,6 @@ public abstract class Scope implements Symbol {
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonIgnore
|
||||
public Scope getScope() {
|
||||
return parentScope;
|
||||
}
|
||||
@ -85,11 +78,9 @@ public abstract class Scope implements Symbol {
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonIgnore
|
||||
public abstract SymbolType getType();
|
||||
|
||||
@Override
|
||||
@JsonIgnore
|
||||
public int getScopeDepth() {
|
||||
if(parentScope == null) {
|
||||
return 0;
|
||||
@ -190,7 +181,6 @@ public abstract class Scope implements Symbol {
|
||||
return getConstant(constantRef.getFullName());
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public Collection<Variable> getAllVariables(boolean includeSubScopes) {
|
||||
Collection<Variable> vars = new ArrayList<>();
|
||||
for(Symbol symbol : symbols.values()) {
|
||||
@ -227,7 +217,6 @@ public abstract class Scope implements Symbol {
|
||||
* @param includeSubScopes Include sub-scopes og sub-scopes
|
||||
* @return The scopes
|
||||
*/
|
||||
@JsonIgnore
|
||||
public Collection<Scope> getAllScopes(boolean includeSubScopes) {
|
||||
Collection<Scope> scopes = new ArrayList<>();
|
||||
for(Symbol symbol : symbols.values()) {
|
||||
@ -309,7 +298,6 @@ public abstract class Scope implements Symbol {
|
||||
return (Procedure) getSymbol(ref);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String toString(Program program, Class symbolClass) {
|
||||
VariableRegisterWeights registerWeights = program.getVariableRegisterWeights();
|
||||
StringBuilder res = new StringBuilder();
|
||||
@ -359,7 +347,6 @@ public abstract class Scope implements Symbol {
|
||||
return res.toString();
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public Collection<Symbol> getAllSymbols() {
|
||||
return symbols.values();
|
||||
}
|
||||
|
@ -1,17 +1,12 @@
|
||||
package dk.camelot64.kickc.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/** A reference to a scope */
|
||||
public class ScopeRef extends SymbolRef {
|
||||
|
||||
/** The ROOT scope of the program. */
|
||||
public static final ScopeRef ROOT = new ScopeRef("");
|
||||
|
||||
@JsonCreator
|
||||
public ScopeRef(
|
||||
@JsonProperty("fullName") String fullName) {
|
||||
public ScopeRef(String fullName) {
|
||||
super(fullName);
|
||||
}
|
||||
|
||||
|
@ -1,24 +1,10 @@
|
||||
package dk.camelot64.kickc.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonSubTypes;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||
|
||||
/**
|
||||
* Single Static Assignment Form Statement.
|
||||
* Intermediate form used for compiler optimization.
|
||||
*/
|
||||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "@type")
|
||||
@JsonSubTypes({
|
||||
@JsonSubTypes.Type(value = StatementAssignment.class, name = "assign"),
|
||||
@JsonSubTypes.Type(value = StatementPhiBlock.class, name = "phiblock"),
|
||||
@JsonSubTypes.Type(value = StatementConditionalJump.class, name = "cond"),
|
||||
@JsonSubTypes.Type(value = StatementJump.class, name = "jump"),
|
||||
@JsonSubTypes.Type(value = StatementLabel.class, name = "label"),
|
||||
@JsonSubTypes.Type(value = StatementCall.class, name = "call"),
|
||||
@JsonSubTypes.Type(value = StatementReturn.class, name = "return"),
|
||||
@JsonSubTypes.Type(value = StatementProcedureBegin.class, name = "procbegin"),
|
||||
@JsonSubTypes.Type(value = StatementProcedureEnd.class, name = "procend")
|
||||
})
|
||||
public interface Statement {
|
||||
|
||||
String toString(Program program, boolean aliveInfo);
|
||||
|
@ -1,9 +1,5 @@
|
||||
package dk.camelot64.kickc.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
|
||||
/**
|
||||
* Single Static Assignment Form Statement.
|
||||
* Intermediate form used for compiler optimization.
|
||||
@ -12,7 +8,6 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
* <br>
|
||||
* <i> lValue := rValue1 <operator> rValue2 </i>
|
||||
*/
|
||||
@JsonPropertyOrder({"lValue", "rValue1", "operator", "rValue2"})
|
||||
public class StatementAssignment extends StatementBase implements StatementLValue {
|
||||
|
||||
/** The variable being assigned a value by the statement. */
|
||||
@ -41,13 +36,12 @@ public class StatementAssignment extends StatementBase implements StatementLValu
|
||||
this(lValue.getRef(), rValue2);
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public StatementAssignment(
|
||||
@JsonProperty("lValue1") LValue lValue,
|
||||
@JsonProperty("rValue1") RValue rValue1,
|
||||
@JsonProperty("operator") Operator operator,
|
||||
@JsonProperty("rValue2") RValue rValue2,
|
||||
@JsonProperty("index") Integer index) {
|
||||
LValue lValue,
|
||||
RValue rValue1,
|
||||
Operator operator,
|
||||
RValue rValue2,
|
||||
Integer index) {
|
||||
super(index);
|
||||
this.lValue = lValue;
|
||||
this.rValue1 = rValue1;
|
||||
|
@ -1,9 +1,5 @@
|
||||
package dk.camelot64.kickc.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -30,22 +26,6 @@ public class StatementCall extends StatementBase implements StatementLValue {
|
||||
this.parametersByAssignment = false;
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
StatementCall(
|
||||
@JsonProperty("lValue") LValue lValue,
|
||||
@JsonProperty("procedureName") String procedureName,
|
||||
@JsonProperty("procedure") ProcedureRef procedure,
|
||||
@JsonProperty("parameters") List<RValue> parameters,
|
||||
@JsonProperty("parametersByAssignment") boolean parametersByAssignment,
|
||||
@JsonProperty("index") Integer index) {
|
||||
super(index);
|
||||
this.lValue = lValue;
|
||||
this.procedureName = procedureName;
|
||||
this.procedure = procedure;
|
||||
this.parameters = parameters;
|
||||
this.parametersByAssignment = parametersByAssignment;
|
||||
}
|
||||
|
||||
public LValue getlValue() {
|
||||
return lValue;
|
||||
}
|
||||
@ -74,7 +54,6 @@ public class StatementCall extends StatementBase implements StatementLValue {
|
||||
this.parameters = parameters;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public int getNumParameters() {
|
||||
return parameters.size();
|
||||
}
|
||||
|
@ -1,8 +1,5 @@
|
||||
package dk.camelot64.kickc.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* Intermediate Compiler Form Statement with a conditional jump.
|
||||
* Intermediate form used for compiler optimization.
|
||||
@ -34,13 +31,12 @@ public class StatementConditionalJump extends StatementBase {
|
||||
this(rValue1, operator, rValue2, destination, null);
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public StatementConditionalJump(
|
||||
@JsonProperty("rValue1") RValue rValue1,
|
||||
@JsonProperty("operator") Operator operator,
|
||||
@JsonProperty("rValue2") RValue rValue2,
|
||||
@JsonProperty("destination") LabelRef destination,
|
||||
@JsonProperty("index") Integer index) {
|
||||
RValue rValue1,
|
||||
Operator operator,
|
||||
RValue rValue2,
|
||||
LabelRef destination,
|
||||
Integer index) {
|
||||
super(index);
|
||||
this.rValue1 = rValue1;
|
||||
this.operator = operator;
|
||||
|
@ -1,9 +1,5 @@
|
||||
package dk.camelot64.kickc.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@ -19,10 +15,9 @@ public class StatementPhiBlock extends StatementBase {
|
||||
*/
|
||||
private List<PhiVariable> phiVariables;
|
||||
|
||||
@JsonCreator
|
||||
public StatementPhiBlock(
|
||||
@JsonProperty("phiVariables") List<PhiVariable> phiVariables,
|
||||
@JsonProperty("index") Integer index) {
|
||||
List<PhiVariable> phiVariables,
|
||||
Integer index) {
|
||||
super(index);
|
||||
this.phiVariables = phiVariables;
|
||||
}
|
||||
@ -37,7 +32,6 @@ public class StatementPhiBlock extends StatementBase {
|
||||
*
|
||||
* @return The variables defined
|
||||
*/
|
||||
@JsonIgnore
|
||||
public List<VariableRef> getVariables() {
|
||||
ArrayList<VariableRef> vars = new ArrayList<>();
|
||||
for(PhiVariable phiVariable : phiVariables) {
|
||||
@ -150,10 +144,9 @@ public class StatementPhiBlock extends StatementBase {
|
||||
this.values = new ArrayList<>();
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public PhiVariable(
|
||||
@JsonProperty("variable") VariableRef variable,
|
||||
@JsonProperty("values") List<PhiRValue> values) {
|
||||
VariableRef variable,
|
||||
List<PhiRValue> values) {
|
||||
this.variable = variable;
|
||||
this.values = values;
|
||||
}
|
||||
@ -209,7 +202,6 @@ public class StatementPhiBlock extends StatementBase {
|
||||
getPhirValue(predecessor).setrValue(rValue);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public boolean isEmpty() {
|
||||
return this.values.isEmpty();
|
||||
}
|
||||
@ -252,10 +244,9 @@ public class StatementPhiBlock extends StatementBase {
|
||||
this.predecessor = predecessor;
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public PhiRValue(
|
||||
@JsonProperty("predecessor") LabelRef predecessor,
|
||||
@JsonProperty("rValue") RValue rValue) {
|
||||
LabelRef predecessor,
|
||||
RValue rValue) {
|
||||
this.predecessor = predecessor;
|
||||
this.rValue = rValue;
|
||||
}
|
||||
|
@ -1,8 +1,5 @@
|
||||
package dk.camelot64.kickc.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* Return Statement inside procedure in Single Static Assignment Form.
|
||||
*/
|
||||
@ -18,14 +15,6 @@ public class StatementReturn extends StatementBase {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
StatementReturn(
|
||||
@JsonProperty("value") RValue value,
|
||||
@JsonProperty("index") Integer index) {
|
||||
super(index);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public RValue getValue() {
|
||||
return value;
|
||||
}
|
||||
|
@ -1,24 +1,18 @@
|
||||
package dk.camelot64.kickc.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
/** A Symbol (variable, jump label, etc.) */
|
||||
public interface Symbol extends Value {
|
||||
|
||||
@JsonIgnore
|
||||
String getLocalName();
|
||||
|
||||
@JsonIgnore
|
||||
String getFullName();
|
||||
|
||||
SymbolType getType();
|
||||
|
||||
@JsonIgnore
|
||||
Scope getScope();
|
||||
|
||||
void setScope(Scope scope);
|
||||
|
||||
@JsonIgnore
|
||||
int getScopeDepth();
|
||||
|
||||
SymbolRef getRef();
|
||||
|
@ -1,7 +1,5 @@
|
||||
package dk.camelot64.kickc.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
/** A reference to a symbol (variable, procedure or label) */
|
||||
public class SymbolRef implements Value {
|
||||
|
||||
@ -56,7 +54,6 @@ public class SymbolRef implements Value {
|
||||
}
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public int getScopeDepth() {
|
||||
int depth = 0;
|
||||
char[] chars = fullName.toCharArray();
|
||||
@ -66,12 +63,10 @@ public class SymbolRef implements Value {
|
||||
return depth / 2;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public boolean isVersion() {
|
||||
return fullName.contains("#");
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public boolean isIntermediate() {
|
||||
if(
|
||||
fullName.contains(BEGIN_BLOCK_NAME) ||
|
||||
@ -79,12 +74,10 @@ public class SymbolRef implements Value {
|
||||
return fullName.contains("$") || fullName.contains("@");
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public boolean isProcExit() {
|
||||
return fullName.endsWith(PROCEXIT_BLOCK_NAME);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getLocalName() {
|
||||
int lastScopeIdx = fullName.lastIndexOf("::");
|
||||
if(lastScopeIdx == -1) {
|
||||
@ -94,7 +87,6 @@ public class SymbolRef implements Value {
|
||||
}
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getScopeNames() {
|
||||
int lastScopeIdx = fullName.lastIndexOf("::");
|
||||
if(lastScopeIdx == -1) {
|
||||
|
@ -1,17 +1,12 @@
|
||||
package dk.camelot64.kickc.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/** A pointer */
|
||||
public class SymbolTypePointer implements SymbolType {
|
||||
|
||||
private SymbolType elementType;
|
||||
|
||||
@JsonCreator
|
||||
public SymbolTypePointer(
|
||||
@JsonProperty("elementType") SymbolType elementType) {
|
||||
SymbolType elementType) {
|
||||
this.elementType = elementType;
|
||||
}
|
||||
|
||||
@ -24,7 +19,6 @@ public class SymbolTypePointer implements SymbolType {
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonIgnore
|
||||
public String getTypeName() {
|
||||
return elementType.getTypeName() + "*";
|
||||
}
|
||||
|
@ -1,17 +1,11 @@
|
||||
package dk.camelot64.kickc.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/** A function returning another type */
|
||||
public class SymbolTypeProcedure implements SymbolType {
|
||||
|
||||
private SymbolType returnType;
|
||||
|
||||
@JsonCreator
|
||||
public SymbolTypeProcedure(
|
||||
@JsonProperty("returnType") SymbolType returnType) {
|
||||
public SymbolTypeProcedure(SymbolType returnType) {
|
||||
this.returnType = returnType;
|
||||
}
|
||||
|
||||
@ -20,7 +14,6 @@ public class SymbolTypeProcedure implements SymbolType {
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonIgnore
|
||||
public String getTypeName() {
|
||||
return returnType.getTypeName() + "()";
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
package dk.camelot64.kickc.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
/** A program */
|
||||
public class SymbolTypeProgram implements SymbolType {
|
||||
|
||||
@ -10,7 +8,6 @@ public class SymbolTypeProgram implements SymbolType {
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonIgnore
|
||||
public String getTypeName() {
|
||||
return "PROGRAM";
|
||||
}
|
||||
|
@ -1,29 +1,6 @@
|
||||
package dk.camelot64.kickc.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonSubTypes;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||
|
||||
/** Any value (variable, constant, label) */
|
||||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "@type")
|
||||
@JsonSubTypes({
|
||||
@JsonSubTypes.Type(value = ConstantBool.class, name = "boolean"),
|
||||
@JsonSubTypes.Type(value = ConstantInteger.class, name = "integer"),
|
||||
@JsonSubTypes.Type(value = ConstantDouble.class, name = "double"),
|
||||
@JsonSubTypes.Type(value = ConstantString.class, name = "string"),
|
||||
@JsonSubTypes.Type(value = VariableUnversioned.class, name = "variable_unversioned"),
|
||||
@JsonSubTypes.Type(value = VariableVersion.class, name = "variable_versioned"),
|
||||
@JsonSubTypes.Type(value = VariableIntermediate.class, name = "variable_intermediate"),
|
||||
@JsonSubTypes.Type(value = Label.class, name = "label"),
|
||||
@JsonSubTypes.Type(value = VariableRef.class, name = "varref"),
|
||||
@JsonSubTypes.Type(value = LabelRef.class, name = "labelref"),
|
||||
@JsonSubTypes.Type(value = ProcedureRef.class, name = "procref"),
|
||||
@JsonSubTypes.Type(value = PointerDereferenceIndexed.class, name = "pointer_indexed"),
|
||||
@JsonSubTypes.Type(value = PointerDereferenceSimple.class, name = "pointer_simple"),
|
||||
@JsonSubTypes.Type(value = ProgramScope.class, name = "program"),
|
||||
@JsonSubTypes.Type(value = Procedure.class, name = "procedure")
|
||||
})
|
||||
public interface Value {
|
||||
|
||||
String toString(Program program);
|
||||
|
||||
}
|
||||
|
@ -1,39 +0,0 @@
|
||||
package dk.camelot64.kickc.model.jackson;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.PropertyAccessor;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.Module;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.module.SimpleModule;
|
||||
|
||||
/** Factory for Jackson JSON serialization of the KickC ICL */
|
||||
public class IclJacksonFactory {
|
||||
|
||||
private static ObjectMapper mapper;
|
||||
private static Module module;
|
||||
|
||||
static {
|
||||
mapper = new ObjectMapper();
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true);
|
||||
mapper.setSerializationInclusion(JsonInclude.Include.ALWAYS);
|
||||
mapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
|
||||
SimpleModule jsonModule = new SimpleModule("KickC ICL Types");
|
||||
module = jsonModule;
|
||||
mapper.registerModule(jsonModule);
|
||||
}
|
||||
|
||||
|
||||
/** Get an ObjectMapper usable for serializing/deserializing KickC ICL to/from JSON */
|
||||
public static ObjectMapper getMapper() {
|
||||
return mapper;
|
||||
}
|
||||
|
||||
|
||||
/** Get a Jackson Module usable for serializing/deserializing KickC ICL to/from JSON */
|
||||
public static Module getModule() {
|
||||
return module;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user