Made the set tag work to local variables. Moved tests to their own directory.

This commit is contained in:
Brad Arant committed 2024-10-30 16:45:05 -07:00
1 parent ad48c530a0
commit ae4ff5a3dc
10 files changed
+37 -18

No files matched your search

+27 -16
View File
@@ -17,22 +17,33 @@ namespace jet {
throw coreutils::Exception("set tag cannot have both expr and value.");
if(!variableDefined("expr") && !variableDefined("value") && !hasContainer)
throw coreutils::Exception("set tag must have a value, expr or a container.");
if(!variableDefined("scope") || (variables["scope"] == "global")) {
if(variableDefined("expr")) {
if(variableDefined("eval"))
throw coreutils::Exception("Cannot use eval with expr.");
global.variables[variables["name"]] = Operand(variables["expr"]).string;
} else if(hasContainer) {
processContainer(container);
if(evaluate) {
global.variables[variables["name"]] = out;
} else {
global.variables[variables["name"]] = container;
}
} else
global.variables[variables["name"]] = variables["value"];
} else {
if(variableDefined("expr") && variableDefined("eval"))
throw coreutils::Exception("Cannot use eval with expr.");
if(variableDefined("expr")) {
if(!variableDefined("scope") || (variables["scope"] == "global"))
global.variables[variables["name"]] = Operand(variables["expr"]).string;
else if(variables["scope"] == "local")
variables[variables["name"]] = Operand(variables["expr"]).string;
} else if(hasContainer) {
processContainer(container);
if(evaluate) {
if(!variableDefined("scope") || (variables["scope"] == "global"))
global.variables[variables["name"]] = out;
else if(variables["scope"] == "local")
variables[variables["name"]] = out;
} else {
if(!variableDefined("scope") || (variables["scope"] == "global"))
global.variables[variables["name"]] = container;
else if(variables["scope"] == "local")
variables[variables["name"]] = container;
}
} else {
if(!variableDefined("scope") || (variables["scope"] == "global"))
global.variables[variables["name"]] = variables["value"];
else if(variables["scope"] == "local")
variables[variables["name"]] = variables["value"];
}
}
}