public IStatus service(Command command, IProcess context) throws InterruptedException, CoreException { if (!(command instanceof RepeatWith)) { return Status.CANCEL_STATUS; } RepeatWith repeatWith = (RepeatWith) command; Command todo = repeatWith.getCommand(); ISession session = context.getSession(); for (Object cmd : repeatWith.getCommands()) { Command prefix = getCommand(cmd); IPipe pipe = session.createPipe(); IStatus status = session.execute(prefix, null, pipe).waitFor(); if (!status.isOK()) { return status; } IPipe output = session.createPipe(); status = session.execute(todo, pipe, output).waitFor(); if (!status.isOK()) { return status; } for (Object obj : CoreUtils.readPipeContent(output)) { context.getOutput().write(obj); } } return Status.OK_STATUS; }
public IStatus service(Command command, IProcess context) throws InterruptedException, CoreException { if (!(command instanceof Let)) { return Status.CANCEL_STATUS; } Let let = (Let) command; DeclarationContainer locals = getLocals(context); boolean inputUsed = false; for (Declaration decl : let.getVals()) { if (!(decl instanceof Val)) { continue; // TODO other declarations support } Val val = (Val) decl; if (val.isInput()) { inputUsed = true; val.setValue(box(context.getInput().take(Long.MAX_VALUE))); } locals.declare(val.getName(), val); } return context .getSession() .execute(let.getBody(), inputUsed ? null : context.getInput(), context.getOutput()) .waitFor(); }
protected static DeclarationContainer getLocals(IProcess context) { ISession session = context.getSession(); if (!(session instanceof CommandSession)) { return null; } return ((CommandSession) session).getStack().getDeclarations(); }
public IStatus service(Command command, IProcess context) throws InterruptedException, CoreException { int paramInt = ((EmitEMFData) command).getParamInt(); context.getOutput().write(paramInt); return Status.OK_STATUS; }