use of org.btrplace.btrpsl.element.BtrpSet in project scheduler by btrplace.
the class ImportStatement method go.
@Override
@SuppressWarnings("squid:S1166")
public BtrpOperand go(BtrPlaceTree parent) {
String id = scriptId();
List<Script> res;
try {
res = includes.getScripts(id);
script.getDependencies().addAll(res);
} catch (ScriptBuilderException e) {
int nb = e.getErrorReporter().getErrors().size();
return ignoreError(Integer.toString(nb) + " error(s) imported through '" + id + "'");
}
if (res.isEmpty()) {
return ignoreError(getChild(0).getToken(), "Unable to locate '" + id + "'");
}
if (id.endsWith(".*")) {
// Prepare the global variable.
BtrpSet global = new BtrpSet(1, BtrpOperand.Type.VM);
global.setLabel("$".concat(id.substring(0, id.length() - 2)));
if (global.size() > 0 && !symTable.declareImmutable(global.label(), global)) {
return ignoreError("Unable to add variable '" + global.label() + "'");
}
}
for (Script v : res) {
for (BtrpOperand op : v.getImportables(script.id())) {
String fqn = v.fullyQualifiedSymbolName(op.label());
if (!symTable.declareImmutable(fqn, op)) {
return ignoreError("Unable to import '" + fqn + "': already declared");
}
}
}
return IgnorableOperand.getInstance();
}
use of org.btrplace.btrpsl.element.BtrpSet in project scheduler by btrplace.
the class NameSpaceStatement method go.
@Override
public BtrpOperand go(BtrPlaceTree parent) {
StringBuilder fqdn = new StringBuilder();
for (int i = 0; i < getChildCount(); i++) {
fqdn.append(getChild(i));
if (i != getChildCount() - 1) {
fqdn.append('.');
}
}
String id = fqdn.toString();
script.setFullyQualifiedName(id);
// $me is immutable and contains all the VMs.
BtrpSet me = new BtrpSet(1, BtrpOperand.Type.VM);
me.setLabel(SymbolsTable.ME);
symbols.declareImmutable(me.label(), me);
errors.updateNamespace();
return IgnorableOperand.getInstance();
}
use of org.btrplace.btrpsl.element.BtrpSet in project scheduler by btrplace.
the class ScriptBuilderTest method testLargeRange.
public void testLargeRange() throws ScriptBuilderException {
ScriptBuilder b = new ScriptBuilder(new DefaultModel());
Script v = b.build("namespace foo; @N[1..500] : defaultNode;\n$all = @N[251..500]; export $all to *;");
BtrpSet out = (BtrpSet) v.getImportable("$all");
Assert.assertEquals(out.size(), 250);
}
Aggregations