Skip to content

Commit

Permalink
Code cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
khatchad committed Feb 23, 2024
1 parent 670db5b commit 485546e
Showing 1 changed file with 13 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,14 @@ public PytesttEntrypoint(MethodReference method, IClassHierarchy cha) {
*/
@Override
public SSAAbstractInvokeInstruction addCall(AbstractRootMethod m) {
int paramValues[];
paramValues = new int[getNumberOfParameters()];
int paramValues[] = new int[getNumberOfParameters()];

for (int j = 0; j < paramValues.length; j++) {
AstInstructionFactory insts = PythonLanguage.Python.instructionFactory();

if (j == 0 && getMethod().getDeclaringClass().getName().toString().contains("/")) {
String methodDeclaringClassName = getMethod().getDeclaringClass().getName().toString();

if (j == 0 && methodDeclaringClassName.contains("/")) {
int v = m.nextLocal++;
paramValues[j] = v;

Expand All @@ -57,22 +58,14 @@ public SSAAbstractInvokeInstruction addCall(AbstractRootMethod m) {
PythonTypes.Root,
Atom.findOrCreateUnicodeAtom(
"global "
+ getMethod()
.getDeclaringClass()
.getName()
.toString()
.substring(
1,
getMethod()
.getDeclaringClass()
.getName()
.toString()
.lastIndexOf('/'))),
+ methodDeclaringClassName.substring(
1, methodDeclaringClassName.lastIndexOf('/'))),
PythonTypes.Root);

int idx = m.statements.size();
int cls = m.nextLocal++;
int obj = m.nextLocal++;

m.statements.add(insts.GlobalRead(m.statements.size(), cls, global));
idx = m.statements.size();

Expand All @@ -87,10 +80,11 @@ public SSAAbstractInvokeInstruction addCall(AbstractRootMethod m) {
new Pair[0]);

m.statements.add(invokeInstruction);

idx = m.statements.size();
String method = getMethod().getDeclaringClass().getName().toString();

String method = methodDeclaringClassName;
String field = method.substring(method.lastIndexOf('/') + 1);

FieldReference f =
FieldReference.findOrCreate(
PythonTypes.Root, Atom.findOrCreateUnicodeAtom(field), PythonTypes.Root);
Expand All @@ -100,21 +94,16 @@ public SSAAbstractInvokeInstruction addCall(AbstractRootMethod m) {
FieldReference global =
FieldReference.findOrCreate(
PythonTypes.Root,
Atom.findOrCreateUnicodeAtom(
"global "
+ getMethod().getDeclaringClass().getName().toString().substring(1)),
Atom.findOrCreateUnicodeAtom("global " + methodDeclaringClassName.substring(1)),
PythonTypes.Root);

m.statements.add(insts.GlobalRead(m.statements.size(), v, global));
}
} else {
paramValues[j] = makeArgument(m, j);
}
} else paramValues[j] = makeArgument(m, j);

if (paramValues[j] == -1) {
if (paramValues[j] == -1)
// there was a problem
return null;
}

TypeReference x[] = getParameterTypes(j);

Expand Down

0 comments on commit 485546e

Please sign in to comment.