mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-12-24 04:31:02 +00:00
Renamed fragment files to match windows
This commit is contained in:
parent
f8aa837eda
commit
91b455e042
@ -10,16 +10,24 @@ import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/** Code Generation Fragment that can handle loading of fragment file and binding of values / registers */
|
||||
/**
|
||||
* Code Generation Fragment that can handle loading of fragment file and binding of values / registers
|
||||
*/
|
||||
public class AsmFragment {
|
||||
|
||||
/** The symbol table. */
|
||||
/**
|
||||
* The symbol table.
|
||||
*/
|
||||
private SymbolTable symbols;
|
||||
|
||||
/** Binding of named values in the fragment to values (constants, variables, ...) .*/
|
||||
/**
|
||||
* Binding of named values in the fragment to values (constants, variables, ...) .
|
||||
*/
|
||||
private Map<String, Value> bindings;
|
||||
|
||||
/** The string signature/name of the asm fragment. */
|
||||
/**
|
||||
* The string signature/name of the asm fragment.
|
||||
*/
|
||||
private String signature;
|
||||
|
||||
public AsmFragment(StatementConditionalJump conditionalJump, SymbolTable symbols) {
|
||||
@ -30,14 +38,14 @@ public class AsmFragment {
|
||||
signature.append(bind(conditionalJump.getRValue1()));
|
||||
}
|
||||
if (conditionalJump.getOperator() != null) {
|
||||
signature.append(conditionalJump.getOperator().getOperator());
|
||||
signature.append(getOperatorFragmentName(conditionalJump.getOperator()));
|
||||
}
|
||||
if (conditionalJump.getRValue2() instanceof ConstantInteger && ((ConstantInteger) conditionalJump.getRValue2()).getNumber() == 0) {
|
||||
signature.append("0");
|
||||
} else {
|
||||
signature.append(bind(conditionalJump.getRValue2()));
|
||||
}
|
||||
signature.append("?");
|
||||
signature.append("_then_");
|
||||
signature.append(bind(conditionalJump.getDestination()));
|
||||
setSignature(signature.toString());
|
||||
}
|
||||
@ -62,7 +70,7 @@ public class AsmFragment {
|
||||
signature.append(bind(rValue1));
|
||||
}
|
||||
if (operator != null) {
|
||||
signature.append(operator.getOperator());
|
||||
signature.append(getOperatorFragmentName(operator));
|
||||
}
|
||||
if (
|
||||
rValue2 instanceof ConstantInteger &&
|
||||
@ -76,6 +84,33 @@ public class AsmFragment {
|
||||
return signature.toString();
|
||||
}
|
||||
|
||||
private static String getOperatorFragmentName(Operator operator) {
|
||||
String op = operator.getOperator();
|
||||
switch (op) {
|
||||
case "+":
|
||||
return "_plus_";
|
||||
case "-":
|
||||
return "_minus_";
|
||||
case "==":
|
||||
return "_eq_";
|
||||
case "<>":
|
||||
case "!=":
|
||||
return "_neq_";
|
||||
case "<":
|
||||
return "_lt_";
|
||||
case ">":
|
||||
return "_gt_";
|
||||
case "<=":
|
||||
case "=<":
|
||||
return "_le_";
|
||||
case ">=":
|
||||
case "=>":
|
||||
return "_ge_";
|
||||
default:
|
||||
return op;
|
||||
}
|
||||
}
|
||||
|
||||
public Value getBinding(String name) {
|
||||
return bindings.get(name);
|
||||
}
|
||||
@ -88,20 +123,29 @@ public class AsmFragment {
|
||||
this.signature = signature;
|
||||
}
|
||||
|
||||
/** Zero page byte register name indexing. */
|
||||
/**
|
||||
* Zero page byte register name indexing.
|
||||
*/
|
||||
private int nextZpByteIdx = 1;
|
||||
|
||||
/** Zero page bool register name indexing. */
|
||||
/**
|
||||
* Zero page bool register name indexing.
|
||||
*/
|
||||
private int nextZpBoolIdx = 1;
|
||||
|
||||
/** Constant byte indexing. */
|
||||
/**
|
||||
* Constant byte indexing.
|
||||
*/
|
||||
private int nextConstByteIdx = 1;
|
||||
|
||||
/** Label indexing. */
|
||||
/**
|
||||
* Label indexing.
|
||||
*/
|
||||
private int nextLabelIdx = 1;
|
||||
|
||||
/**
|
||||
* Add bindings of a value.
|
||||
*
|
||||
* @param value The value to bind.
|
||||
* @return The bound name of the value. If the value has already been bound the existing bound name is returned.
|
||||
*/
|
||||
@ -217,5 +261,4 @@ public class AsmFragment {
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -1 +0,0 @@
|
||||
// x=x
|
Loading…
Reference in New Issue
Block a user