diff --git a/src/commons/utils/JavaHelper.ts b/src/commons/utils/JavaHelper.ts index fbb7199135..47abee2b7f 100644 --- a/src/commons/utils/JavaHelper.ts +++ b/src/commons/utils/JavaHelper.ts @@ -18,7 +18,7 @@ export async function javaRun( 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({ @@ -110,10 +110,14 @@ export async function javaRun( } 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 => { + compiled[c.className + '.class'] = Buffer.from( + binaryWriter.generateBinary(c.classFile) + ).toString('base64'); + }); } catch (e) { stderr('Compile', e); return Promise.resolve({ status: 'error' }); diff --git a/src/features/cseMachine/java/components/Control.tsx b/src/features/cseMachine/java/components/Control.tsx index dcce409585..24958d52a2 100644 --- a/src/features/cseMachine/java/components/Control.tsx +++ b/src/features/cseMachine/java/components/Control.tsx @@ -128,6 +128,10 @@ export class Control extends Visible { return `res ${resInstr.name}`; case ECE.InstrType.DEREF: return 'deref'; + case ECE.InstrType.BRANCH: + return `branch`; + case ECE.InstrType.SWITCH: + return `switch`; default: return 'INSTRUCTION'; } @@ -188,6 +192,11 @@ export class Control extends Visible { 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: + return 'Evaluate condition and push either consequent or alternative to stash'; + case ECE.InstrType.SWITCH: + const switchInstr = controlItem as ECE.SwitchInstr; + return `Switch on ${astToString(switchInstr.expr)} and push result of case to stash`; default: return 'INSTRUCTION'; }