Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions src/commons/utils/JavaHelper.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { compileFromSource, ECE, typeCheck } from 'java-slang';
import { BinaryWriter } from 'java-slang/dist/compiler/binary-writer';
import { IOCallbacks } from 'java-slang/dist/ec-evaluator';

Check failure on line 3 in src/commons/utils/JavaHelper.ts

View workflow job for this annotation

GitHub Actions / lint (tsc)

Module '"java-slang/dist/ec-evaluator"' has no exported member 'IOCallbacks'.

Check failure on line 3 in src/commons/utils/JavaHelper.ts

View workflow job for this annotation

GitHub Actions / lint (build)

Module '"java-slang/dist/ec-evaluator"' has no exported member 'IOCallbacks'.
import setupJVM, { parseBin } from 'java-slang/dist/jvm';
import { createModuleProxy, loadCachedFiles } from 'java-slang/dist/jvm/utils/integration';
import { Context, Result } from 'js-slang';
Expand Down Expand Up @@ -98,17 +99,19 @@
return Promise.resolve({ status: 'error' });
}
} else {
if (isUsingCse) {
const result = await runJavaCseMachine(javaCode, targetStep, context, { stdout, stderr });

return result;
}

const typeCheckResult = typeCheck(javaCode);
if (typeCheckResult.hasTypeErrors) {
const typeErrMsg = typeCheckResult.errorMsgs.join('\n');
stderr('TypeCheck', typeErrMsg);
return Promise.resolve({ status: 'error' });
}

if (isUsingCse) {
return await runJavaCseMachine(javaCode, targetStep, context);
}

try {
const classFile = compileFromSource(javaCode);
compiled = {
Expand Down Expand Up @@ -178,7 +181,12 @@
}
}

export async function runJavaCseMachine(code: string, targetStep: number, context: Context) {
export async function runJavaCseMachine(
code: string,
targetStep: number,
context: Context,
ioCallbacks: IOCallbacks
) {
const convertJavaErrorToJsError = (e: ECE.SourceError): SourceError => ({
type: ErrorType.RUNTIME,
severity: ErrorSeverity.ERROR,
Expand All @@ -197,7 +205,7 @@
elaborate: () => e.explain()
});
context.executionMethod = 'cse-machine';
return ECE.runECEvaluator(code, targetStep)
return ECE.runECEvaluator(code, targetStep, ioCallbacks)

Check failure on line 208 in src/commons/utils/JavaHelper.ts

View workflow job for this annotation

GitHub Actions / lint (tsc)

Expected 1-2 arguments, but got 3.

Check failure on line 208 in src/commons/utils/JavaHelper.ts

View workflow job for this annotation

GitHub Actions / lint (build)

Expected 1-2 arguments, but got 3.
.then(result => {
context.runtime.envStepsTotal = result.context.totalSteps;
if (result.status === 'error') {
Expand Down
2 changes: 1 addition & 1 deletion src/features/cseMachine/java/components/Method.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

// Tooltip.
this._tooltipRef = React.createRef();
this._tooltip = astToString(this._method.mtdOrCon);
this._tooltip = astToString(this._method.decl);

Check failure on line 42 in src/features/cseMachine/java/components/Method.tsx

View workflow job for this annotation

GitHub Actions / lint (tsc)

Property 'decl' does not exist on type 'Closure'.

Check failure on line 42 in src/features/cseMachine/java/components/Method.tsx

View workflow job for this annotation

GitHub Actions / lint (build)

Property 'decl' does not exist on type 'Closure'.
}

get method() {
Expand Down
Loading