Skip to content

Commit

Permalink
fix: Hide some operand types.
Browse files Browse the repository at this point in the history
  • Loading branch information
teletha committed Mar 15, 2023
1 parent 049b36f commit fa2db31
Show file tree
Hide file tree
Showing 14 changed files with 31 additions and 50 deletions.
4 changes: 1 addition & 3 deletions src/main/java/reincarnation/OperandArray.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,8 @@
* mv.visitLdcInsn("third");
* mv.visitInsn(AASTORE); // Assign third value
*</pre>
*
* @version 2018/10/05 19:36:39
*/
public class OperandArray extends Operand {
class OperandArray extends Operand {

/** The array dimension size. */
private final int dimension;
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/reincarnation/OperandArrayAccess.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@

import reincarnation.coder.Coder;

/**
* @version 2018/10/14 10:25:56
*/
class OperandArrayAccess extends Operand {

/** The array value. */
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/reincarnation/OperandAssign.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/**
* Binary operation expression.
*/
public class OperandAssign extends Operand {
class OperandAssign extends Operand {

/** The left value. */
private final Operand left;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/reincarnation/OperandBinary.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/**
* Binary operation expression.
*/
public class OperandBinary extends Operand {
class OperandBinary extends Operand {

/** The left value. */
final Operand left;
Expand All @@ -37,7 +37,7 @@ public class OperandBinary extends Operand {
* @param operator A operator.
* @param right A right value.
*/
public OperandBinary(Operand left, BinaryOperator operator, Operand right) {
OperandBinary(Operand left, BinaryOperator operator, Operand right) {
this.left = Objects.requireNonNull(left);
this.right = Objects.requireNonNull(right);
this.operator = Objects.requireNonNull(operator);
Expand Down
5 changes: 1 addition & 4 deletions src/main/java/reincarnation/OperandClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@

import reincarnation.coder.Coder;

/**
* @version 2018/10/14 2:00:50
*/
public class OperandClass extends Operand {
class OperandClass extends Operand {

/** The actual value. */
private final Class value;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/reincarnation/OperandFieldAccess.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import reincarnation.coder.Coder;
import reincarnation.operator.AccessMode;

public class OperandFieldAccess extends Operand {
class OperandFieldAccess extends Operand {

/** The field. */
private final Field field;
Expand All @@ -36,7 +36,7 @@ public class OperandFieldAccess extends Operand {
* @param ownerType A field owner.
* @param name A field name.
*/
public OperandFieldAccess(Class ownerType, String name, Operand context) {
OperandFieldAccess(Class ownerType, String name, Operand context) {
this.field = find(ownerType, name);
this.context = Objects.requireNonNull(context);

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/reincarnation/OperandInstanceOf.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import reincarnation.coder.Coder;
import reincarnation.operator.BinaryOperator;

public class OperandInstanceOf extends Operand {
class OperandInstanceOf extends Operand {

/** The value. */
final Operand value;
Expand All @@ -31,7 +31,7 @@ public class OperandInstanceOf extends Operand {
* @param value A value to check.
* @param type A type to check.
*/
public OperandInstanceOf(Operand value, Class type) {
OperandInstanceOf(Operand value, Class type) {
this.value = value;
this.type = type;
fix(boolean.class);
Expand All @@ -43,7 +43,7 @@ public OperandInstanceOf(Operand value, Class type) {
* @param op
* @return
*/
public OperandInstanceOf withCast(Operand op) {
OperandInstanceOf withCast(Operand op) {
this.cast = op;

return this;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/reincarnation/OperandMethodCall.java
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ public void writeStatement(Code code) {
* {@inheritDoc}
*/
@Override
public void writeMethodCall(Method method, Code context, List<? extends Code> parameters, AccessMode mode) {
public void writeMethodCall(Method method, Code context, List<Code> parameters, AccessMode mode) {
LinkedList<Code> copy = new LinkedList(params);
Code delegate = context;

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/reincarnation/OperandReturn.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import kiss.Variable;
import reincarnation.coder.Coder;

public class OperandReturn extends Operand {
class OperandReturn extends Operand {

/** The empty return for reuse. */
public static final OperandReturn Empty = new OperandReturn(null);
Expand Down
5 changes: 1 addition & 4 deletions src/main/java/reincarnation/OperandTernary.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@

import reincarnation.coder.Coder;

/**
* @version 2018/11/06 14:17:11
*/
public class OperandTernary extends OperandCondition {
class OperandTernary extends OperandCondition {

/** The codition. */
private Operand condition;
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/reincarnation/OperandUnary.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@

/**
* Binary operation expression.
*
* @version 2018/10/13 18:47:44
*/
public class OperandUnary extends Operand {
class OperandUnary extends Operand {

/** The value. */
public final Operand value;
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/reincarnation/coder/Coder.java
Original file line number Diff line number Diff line change
Expand Up @@ -532,23 +532,23 @@ public final void writeEnclose(Code code) {
* @param constructor A constructor info.
* @param params A list of parameter objects.
*/
public abstract void writeConstructorCall(Constructor constructor, List<? extends Code> params);
public abstract void writeConstructorCall(Constructor constructor, List<Code> params);

/**
* Constructor call expression.
*
* @param constructor A constructor info.
* @param params A list of parameter objects.
*/
public abstract void writeSuperConstructorCall(Constructor constructor, List<? extends Code> params);
public abstract void writeSuperConstructorCall(Constructor constructor, List<Code> params);

/**
* Constructor call expression.
*
* @param constructor A constructor info.
* @param params A list of parameter objects.
*/
public abstract void writeThisConstructorCall(Constructor constructor, List<? extends Code> params);
public abstract void writeThisConstructorCall(Constructor constructor, List<Code> params);

/**
* Method call expression.
Expand All @@ -558,7 +558,7 @@ public final void writeEnclose(Code code) {
* @param params A list of parameter objects.
* @param mode An access mode.
*/
public abstract void writeMethodCall(Method method, Code context, List<? extends Code> params, AccessMode mode);
public abstract void writeMethodCall(Method method, Code context, List<Code> params, AccessMode mode);

/**
* Method reference.
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/reincarnation/coder/DelegatableCoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -325,31 +325,31 @@ public void writeAccessArrayLength(Code array) {
* {@inheritDoc}
*/
@Override
public void writeConstructorCall(Constructor constructor, List<? extends Code> params) {
public void writeConstructorCall(Constructor constructor, List<Code> params) {
coder.writeConstructorCall(constructor, params);
}

/**
* {@inheritDoc}
*/
@Override
public void writeSuperConstructorCall(Constructor constructor, List<? extends Code> params) {
public void writeSuperConstructorCall(Constructor constructor, List<Code> params) {
coder.writeSuperConstructorCall(constructor, params);
}

/**
* {@inheritDoc}
*/
@Override
public void writeThisConstructorCall(Constructor constructor, List<? extends Code> params) {
public void writeThisConstructorCall(Constructor constructor, List<Code> params) {
coder.writeThisConstructorCall(constructor, params);
}

/**
* {@inheritDoc}
*/
@Override
public void writeMethodCall(Method method, Code context, List<? extends Code> params, AccessMode mode) {
public void writeMethodCall(Method method, Code context, List<Code> params, AccessMode mode) {
coder.writeMethodCall(method, context, params, mode);
}

Expand Down
24 changes: 9 additions & 15 deletions src/main/java/reincarnation/coder/java/JavaCoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import kiss.Ⅱ;
import kiss.Ⅲ;
import reincarnation.Operand;
import reincarnation.OperandArray;
import reincarnation.OperandUtil;
import reincarnation.Reincarnation;
import reincarnation.coder.Code;
Expand Down Expand Up @@ -681,15 +680,15 @@ public void writeAccessArrayLength(Code array) {
* {@inheritDoc}
*/
@Override
public void writeConstructorCall(Constructor constructor, List<? extends Code> params) {
public void writeConstructorCall(Constructor constructor, List<Code> params) {
write("new", space, name(constructor.getDeclaringClass()), buildParameter(constructor, params));
}

/**
* {@inheritDoc}
*/
@Override
public void writeSuperConstructorCall(Constructor constructor, List<? extends Code> params) {
public void writeSuperConstructorCall(Constructor constructor, List<Code> params) {
if (params.isEmpty() || constructor.getDeclaringClass() == Enum.class) {
revert();
} else {
Expand All @@ -701,7 +700,7 @@ public void writeSuperConstructorCall(Constructor constructor, List<? extends Co
* {@inheritDoc}
*/
@Override
public void writeThisConstructorCall(Constructor constructor, List<? extends Code> params) {
public void writeThisConstructorCall(Constructor constructor, List<Code> params) {
if (constructor.getDeclaringClass().isEnum()) {
write("this", buildParameter(constructor, params, 2));
} else {
Expand All @@ -713,7 +712,7 @@ public void writeThisConstructorCall(Constructor constructor, List<? extends Cod
* {@inheritDoc}
*/
@Override
public void writeMethodCall(Method method, Code context, List<? extends Code> params, AccessMode mode) {
public void writeMethodCall(Method method, Code context, List<Code> params, AccessMode mode) {
if (method.isSynthetic()) {
write(context, ".", method.getName(), buildParameter(method, params));
} else {
Expand All @@ -740,7 +739,7 @@ public void writeMethodCall(Method method, Code context, List<? extends Code> pa
* @param params
* @return
*/
private Join buildParameter(Executable executable, List<? extends Code> params) {
private Join buildParameter(Executable executable, List<Code> params) {
return buildParameter(executable, params, 0);
}

Expand All @@ -751,18 +750,13 @@ private Join buildParameter(Executable executable, List<? extends Code> params)
* @param params
* @return
*/
private Join buildParameter(Executable executable, List<? extends Code> params, int start) {
private Join buildParameter(Executable executable, List<Code> params, int start) {
Join concat = new Join().prefix("(").suffix(")").separator("," + space);
Parameter[] parameters = executable.getParameters();
if (executable.isVarArgs()) {
int index = params.size() - 1;
Code code = params.get(index);
if (code instanceof OperandArray) {
params.remove(index);
params.addAll(index, code.children().skip(1).toList());
}
params.remove(params.size() - 1).children().skip(1).to(c -> params.add((Code) c));
}

Parameter[] parameters = executable.getParameters();
for (int i = start; i < params.size(); i++) {
Code param = params.get(i);

Expand Down Expand Up @@ -1392,7 +1386,7 @@ public void writeAssignOperation(Code left, AssignOperator operator, Code right)
* {@inheritDoc}
*/
@Override
public void writeConstructorCall(Constructor constructor, List<? extends Code> params) {
public void writeConstructorCall(Constructor constructor, List<Code> params) {
if (whileInitializing()) {
Class owner = constructor.getDeclaringClass();
if (current.v.isAssignableFrom(owner) && 2 <= params.size()) {
Expand Down

0 comments on commit fa2db31

Please sign in to comment.