Skip to content

java-slang frontend integration #3124

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
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
13 changes: 8 additions & 5 deletions src/commons/utils/JavaHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
isUsingCse: boolean,
options?: { uploadIsActive?: boolean; uploads?: UploadResult }
) {
let compiled = {};
let compiled: {[key: string]: string} = {};

const stderr = (type: 'TypeCheck' | 'Compile' | 'Runtime', msg: string) => {
context.errors.push({
Expand Down Expand Up @@ -110,10 +110,13 @@
}

try {
const classFile = compileFromSource(javaCode);
compiled = {
'Main.class': Buffer.from(new BinaryWriter().generateBinary(classFile)).toString('base64')
};
const binaryWriter = new BinaryWriter();
const classes = compileFromSource(javaCode);
console.debug(classes)
classes.forEach(c => {

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

View workflow job for this annotation

GitHub Actions / lint (tsc)

Parameter 'c' implicitly has an 'any' type.

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

View workflow job for this annotation

GitHub Actions / lint (tsc)

Property 'forEach' does not exist on type 'ClassFile'.
compiled[c.className + '.class']
= Buffer.from(binaryWriter.generateBinary(c.classFile)).toString('base64');
});
} catch (e) {
stderr('Compile', e);
return Promise.resolve({ status: 'error' });
Expand Down
9 changes: 9 additions & 0 deletions src/features/cseMachine/java/components/Control.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@
return `res ${resInstr.name}`;
case ECE.InstrType.DEREF:
return 'deref';
case ECE.InstrType.BRANCH:

Check failure on line 131 in src/features/cseMachine/java/components/Control.tsx

View workflow job for this annotation

GitHub Actions / lint (tsc)

Property 'BRANCH' does not exist on type 'typeof InstrType'.
return `branch`;
case ECE.InstrType.SWITCH:

Check failure on line 133 in src/features/cseMachine/java/components/Control.tsx

View workflow job for this annotation

GitHub Actions / lint (tsc)

Property 'SWITCH' does not exist on type 'typeof InstrType'.
return `switch`;
default:
return 'INSTRUCTION';
}
Expand Down Expand Up @@ -188,6 +192,11 @@
return `Resolve field ${resInstr.name} of most recently pushed value from stash`;
case ECE.InstrType.DEREF:
return 'Dereference most recently pushed value from stash';
case ECE.InstrType.BRANCH:

Check failure on line 195 in src/features/cseMachine/java/components/Control.tsx

View workflow job for this annotation

GitHub Actions / lint (tsc)

Property 'BRANCH' does not exist on type 'typeof InstrType'.
return 'Evaluate condition and push either consequent or alternative to stash';
case ECE.InstrType.SWITCH:

Check failure on line 197 in src/features/cseMachine/java/components/Control.tsx

View workflow job for this annotation

GitHub Actions / lint (tsc)

Property 'SWITCH' does not exist on type 'typeof InstrType'.
const switchInstr = controlItem as ECE.SwitchInstr;

Check failure on line 198 in src/features/cseMachine/java/components/Control.tsx

View workflow job for this annotation

GitHub Actions / lint (tsc)

Namespace '"/home/runner/work/frontend/frontend/node_modules/java-slang/dist/ec-evaluator/index"' has no exported member 'SwitchInstr'.
return `Switch on ${astToString(switchInstr.expr)} and push result of case to stash`;
default:
return 'INSTRUCTION';
}
Expand Down
Loading