public String _range(String args[]) { verifyCommand(args, _rangeHelp, _rangePattern, 2, 3); Version version = null; if (args.length >= 3) version = new Version(args[2]); else { String v = domain.getProperty("@"); if (v == null) return null; version = new Version(v); } String spec = args[1]; Matcher m = RANGE_MASK.matcher(spec); m.matches(); String floor = m.group(1); String floorMask = m.group(2); String ceilingMask = m.group(3); String ceiling = m.group(4); String left = version(version, floorMask); String right = version(version, ceilingMask); StringBuilder sb = new StringBuilder(); sb.append(floor); sb.append(left); sb.append(","); sb.append(right); sb.append(ceiling); String s = sb.toString(); VersionRange vr = new VersionRange(s); if (!(vr.includes(vr.getHigh()) || vr.includes(vr.getLow()))) { domain.error( "${range} macro created an invalid range %s from %s and mask %s", s, version, spec); } return sb.toString(); }
ProcessorState(Processor p, Log log, Source source, ProcessingEnvironment env) { processor = p; contributed = false; try { processor.init(env); checkSourceVersionCompatibility(source, log); supportedAnnotationPatterns = new ArrayList<Pattern>(); for (String importString : processor.getSupportedAnnotationTypes()) { supportedAnnotationPatterns.add(importStringToPattern(importString, processor, log)); } supportedOptionNames = new ArrayList<String>(); for (String optionName : processor.getSupportedOptions()) { if (checkOptionName(optionName, log)) supportedOptionNames.add(optionName); } } catch (ClientCodeException e) { throw e; } catch (Throwable t) { throw new AnnotationProcessingError(t); } }
public Branch execute(Processor cpu) { Reg op1 = cpu.regs[op1Index]; cpu.of = cpu.af = cpu.cf = false; cpu.flagResult = (op1.get32() & immd); cpu.flagStatus = SZP; return Branch.None; }
public synchronized boolean waitForState(int state) { switch (state) { case Processor.Configured: p.configure(); break; case Controller.Realized: p.realize(); break; case Controller.Prefetched: p.prefetch(); break; case Controller.Started: p.start(); break; } while (p.getState() < state && !error) { try { wait(1000); } catch (Exception e) { } } // p.removeControllerListener(this); return !(error); }
public void startProcessing() { try { processor = Manager.createProcessor(getMainCamSource()); } catch (IOException e) { // JOptionPane.showMessageDialog(parent, // "IO Exception creating processor: " + e.getMessage(), "Error", // JOptionPane.WARNING_MESSAGE); return; } catch (NoProcessorException e) { // JOptionPane.showMessageDialog(parent, // "Exception creating processor: " + e.getMessage(), "Error", // JOptionPane.WARNING_MESSAGE); return; } CamStateHelper playhelper = new CamStateHelper(processor); if (!playhelper.configure(10000)) { JOptionPane.showMessageDialog( parent, "cannot configure processor", "Error", JOptionPane.WARNING_MESSAGE); return; } processor.setContentDescriptor(null); if (!playhelper.realize(10000)) { JOptionPane.showMessageDialog( parent, "cannot realize processor", "Error", JOptionPane.WARNING_MESSAGE); return; } // In order for or your clones to start, you must start the original source processor.start(); setProcessing(true); }
public static void testBumpIncludeFile() throws Exception { File tmp = new File("tmp-ws"); if (tmp.exists()) IO.deleteWithException(tmp); tmp.mkdir(); assertTrue(tmp.isDirectory()); try { IO.copy(new File("test/ws"), tmp); Workspace ws = Workspace.getWorkspace(tmp); Project project = ws.getProject("bump-included"); project.setTrace(true); Version old = new Version(project.getProperty("Bundle-Version")); assertEquals(new Version(1, 0, 0), old); project.bump("=+0"); Processor processor = new Processor(); processor.setProperties(project.getFile("include.txt")); Version newv = new Version(processor.getProperty("Bundle-Version")); System.err.println("New version " + newv); assertEquals(1, newv.getMajor()); assertEquals(1, newv.getMinor()); assertEquals(0, newv.getMicro()); } finally { IO.deleteWithException(tmp); } }
private String doCommand(Object target, String method, String[] args) { if (target == null) ; // System.err.println("Huh? Target should never be null " + // domain); else { String cname = "_" + method.replaceAll("-", "_"); try { Method m = target.getClass().getMethod(cname, new Class[] {String[].class}); return (String) m.invoke(target, new Object[] {args}); } catch (NoSuchMethodException e) { // Ignore } catch (InvocationTargetException e) { if (e.getCause() instanceof IllegalArgumentException) { domain.error( "%s, for cmd: %s, arguments; %s", e.getCause().getMessage(), method, Arrays.toString(args)); } else { domain.warning("Exception in replace: %s", e.getCause()); e.getCause().printStackTrace(); } } catch (Exception e) { domain.warning("Exception in replace: " + e + " method=" + method); e.printStackTrace(); } } return null; }
/** @return the number of free processors of this machine. */ public int getNumberOfFreeProcessors() { int numFreeProcessors = 0; for (Processor processor : processors) { numFreeProcessors += processor.isBusy() ? 0 : 1; } return numFreeProcessors; }
public String _path(String args[]) { List<String> list = new ArrayList<String>(); for (int i = 1; i < args.length; i++) { list.addAll(Processor.split(args[i])); } return Processor.join(list, File.pathSeparator); }
@Override protected void execute( final @NonNull KernelHttpRequest request, final @NonNull KernelHttpResponse response) { if (!request.isPrivileged()) throw new AdminAccessException(); final String queryType = request.getParameter("queryType"); final PrintWriter writer = response.getWriter(); writer.print("["); try { final ValidatingKernel kernel = getKernel(); final BeginTransactionResult btr = kernel.beginTransaction(); final NodesTransaction txn = btr.getTxn(); boolean commit = false; try { final Processor processor = processors.get(queryType); if (processor == null) writer.println("Query type '" + queryType + "' not found"); else processor.process(txn, request, writer); commit = true; } finally { txn.finish(commit); } writer.print("]"); } finally { writer.close(); } }
@Override public String doConvert() { final InfoLines msgs = new InfoLines(); try { final Processor proc = getProc(); proc.parse(); if (getGenerate()) { proc.generateZoneinfoFiles( Util.buildPath(true, getRootdir(), "/", "zoneinfo"), true); // doLinks } if (getCompare()) { proc.compare(msgs); } for (final String msg : msgs) { System.out.print(msg); } } catch (final Throwable t) { t.printStackTrace(); msgs.exceptionMsg(t); } return msgs.toString(); }
/** * System command. Execute a command and insert the result. * * @param args * @param help * @param patterns * @param low * @param high */ public String system_internal(boolean allowFail, String args[]) throws Exception { verifyCommand( args, "${" + (allowFail ? "system-allow-fail" : "system") + ";<command>[;<in>]}, execute a system command", null, 2, 3); String command = args[1]; String input = null; if (args.length > 2) { input = args[2]; } Process process = Runtime.getRuntime().exec(command, null, domain.getBase()); if (input != null) { process.getOutputStream().write(input.getBytes("UTF-8")); } process.getOutputStream().close(); String s = IO.collect(process.getInputStream(), "UTF-8"); int exitValue = process.waitFor(); if (exitValue != 0) return exitValue + ""; if (!allowFail && (exitValue != 0)) { domain.error("System command " + command + " failed with " + exitValue); } return s.trim(); }
String ls(String args[], boolean relative) { if (args.length < 2) throw new IllegalArgumentException( "the ${ls} macro must at least have a directory as parameter"); File dir = domain.getFile(args[1]); if (!dir.isAbsolute()) throw new IllegalArgumentException( "the ${ls} macro directory parameter is not absolute: " + dir); if (!dir.exists()) throw new IllegalArgumentException( "the ${ls} macro directory parameter does not exist: " + dir); if (!dir.isDirectory()) throw new IllegalArgumentException( "the ${ls} macro directory parameter points to a file instead of a directory: " + dir); Collection<File> files = new ArrayList<File>(new SortedList<File>(dir.listFiles())); for (int i = 2; i < args.length; i++) { Instructions filters = new Instructions(args[i]); files = filters.select(files, true); } List<String> result = new ArrayList<String>(); for (File file : files) result.add(relative ? file.getName() : file.getAbsolutePath()); return Processor.join(result, ","); }
private String doCommands(String key, Link source) { String[] args = commands.split(key); if (args == null || args.length == 0) return null; for (int i = 0; i < args.length; i++) if (args[i].indexOf('\\') >= 0) args[i] = args[i].replaceAll("\\\\;", ";"); if (args[0].startsWith("^")) { String varname = args[0].substring(1).trim(); Processor parent = source.start.getParent(); if (parent != null) return parent.getProperty(varname); return null; } Processor rover = domain; while (rover != null) { String result = doCommand(rover, args[0], args); if (result != null) return result; rover = rover.getParent(); } for (int i = 0; targets != null && i < targets.length; i++) { String result = doCommand(targets[i], args[0], args); if (result != null) return result; } return doCommand(this, args[0], args); }
private synchronized boolean waitForState(Processor p, int state) { p.addControllerListener(new StateListener()); failed = false; // Call the required method on the processor if (state == Processor.Configured) { p.configure(); } else if (state == Processor.Realized) { p.realize(); } // Wait until we get an event that confirms the // success of the method, or a failure event. // See StateListener inner class while (p.getState() < state && !failed) { synchronized (getStateLock()) { try { getStateLock().wait(); } catch (InterruptedException ie) { return false; } } } if (failed) return false; else return true; }
/** Check if the getSubBuilders properly predicts the output. */ public static void testSubBuilders() throws Exception { Workspace ws = Workspace.getWorkspace(new File("test/ws")); Project project = ws.getProject("p4-sub"); Collection<? extends Builder> bs = project.getSubBuilders(); assertNotNull(bs); assertEquals(3, bs.size()); Set<String> names = new HashSet<String>(); for (Builder b : bs) { names.add(b.getBsn()); } assertTrue(names.contains("p4-sub.a")); assertTrue(names.contains("p4-sub.b")); assertTrue(names.contains("p4-sub.c")); File[] files = project.build(); assertTrue(project.check()); System.err.println(Processor.join(project.getErrors(), "\n")); System.err.println(Processor.join(project.getWarnings(), "\n")); assertEquals(0, project.getErrors().size()); assertEquals(0, project.getWarnings().size()); assertNotNull(files); assertEquals(3, files.length); for (File file : files) { Jar jar = new Jar(file); Manifest m = jar.getManifest(); assertTrue(names.contains(m.getMainAttributes().getValue("Bundle-SymbolicName"))); } }
protected void processChildren(Symbols symbols, Writer writer, String padding) { Processor p = children; while (p != null) { p.process(symbols, writer, line, padding); p = p.getNext(); } }
public Branch execute(Processor cpu) { cpu.eip += blockLength; int tmpEip = cpu.eip + jmp; cpu.cs.checkAddress(tmpEip); cpu.eip = tmpEip; return Branch.T1; }
public Branch execute(Processor cpu) { Reg op1 = cpu.regs[op1Index]; Reg op2 = cpu.regs[op2Index]; cpu.zf(cpu.zf()); cpu.cf(((op1.get16() & (1 << (op2.get16() & (16 - 1)))) != 0)); return Branch.None; }
public Branch execute(Processor cpu) { cpu.flagOp1 = cpu.r_eax.get16(); cpu.flagOp2 = immw; cpu.flagResult = (short) (cpu.flagOp1 - cpu.flagOp2); cpu.flagIns = UCodes.SUB16; cpu.flagStatus = OSZAPC; return Branch.None; }
public Branch execute(Processor cpu) { Reg op1 = cpu.regs[op1Index]; cpu.of = cpu.af = cpu.cf = false; cpu.flagResult = (byte) (op1.get8() ^ op2.get8(cpu)); op1.set8((byte) cpu.flagResult); cpu.flagStatus = SZP; return Branch.None; }
public Branch execute(Processor cpu) { cpu.flagOp1 = cpu.r_eax.get32(); cpu.flagOp2 = immd; cpu.flagResult = (cpu.flagOp1 - cpu.flagOp2); cpu.flagIns = UCodes.SUB32; cpu.flagStatus = OSZAPC; return Branch.None; }
public String _uniq(String args[]) { verifyCommand(args, _uniqHelp, null, 1, Integer.MAX_VALUE); Set<String> set = new LinkedHashSet<String>(); for (int i = 1; i < args.length; i++) { Processor.split(args[i], set); } return Processor.join(set, ","); }
public Branch execute(Processor cpu) { cpu.flagOp1 = op1.get32(cpu); cpu.flagResult = (-cpu.flagOp1); op1.set32(cpu, cpu.flagResult); cpu.flagIns = UCodes.NEG32; cpu.flagStatus = OSZAPC; return Branch.None; }
/** * Constructs a new <code>ProcessorStatusEvent</code>. * * @param processor the processor which caused the event, must not be <code>null</code> * @param oldStatus the old processor status */ public ProcessorStatusEvent(Processor processor, int oldStatus) { super(processor); Guardian.assertNotNull("processor", processor); _request = processor.getRequest(); _oldStatus = oldStatus; _newStatus = processor.getCurrentStatus(); _exception = null; // processor.getLastException(); }
public Branch execute(Processor cpu) { cpu.flagOp1 = (byte) op1.get8(cpu); cpu.flagOp2 = (byte) immb; cpu.flagResult = (byte) (cpu.flagOp1 - cpu.flagOp2); cpu.flagIns = UCodes.SUB8; cpu.flagStatus = OSZAPC; return Branch.None; }
public Processor getFreeProcessor() { for (Processor processor : processors) { if (!processor.isBusy()) { return processor; } } return null; }
String processContent(String content, Type type) throws ProcessingException { if (content != null && !content.isEmpty()) { for (Processor processor : type.getProcessors()) { content = processor.process(content); } } return content; }
public Branch execute(Processor cpu) { Reg op1 = cpu.regs[op1Index]; Reg op2 = cpu.regs[op2Index]; int bit = 1 << (op2.get16() & (16 - 1)); cpu.cf = (0 != (op1.get16() & bit)); cpu.flagStatus &= NCF; op1.set16((short) (op1.get16() & ~bit)); return Branch.None; }
public Branch execute(Processor cpu) { cpu.flagOp1 = (short) op1.get16(cpu); cpu.flagOp2 = (short) immw; cpu.flagResult = (short) (cpu.flagOp1 - cpu.flagOp2); op1.set16(cpu, (short) cpu.flagResult); cpu.flagIns = UCodes.SUB16; cpu.flagStatus = OSZAPC; return Branch.None; }