39 lines
1.6 KiB
C++
39 lines
1.6 KiB
C++
#include "__set.h"
|
|
#include "Exception.h"
|
|
#include "Operand.h"
|
|
#include <iostream>
|
|
|
|
namespace jet {
|
|
|
|
__set::__set(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent) : Tag(in, parentOut, global, parent) {
|
|
output = false;
|
|
if(!variableDefined("name"))
|
|
throw coreutils::Exception("set tag must have name defined.");
|
|
if(!variableDefined("expr") && variableDefined("value") && hasContainer)
|
|
throw coreutils::Exception("set tag cannot have both value and a container.");
|
|
if(variableDefined("expr") && !variableDefined("value") && hasContainer)
|
|
throw coreutils::Exception("set tag cannot have both expr and a container.");
|
|
if(variableDefined("expr") && variableDefined("value") && !hasContainer)
|
|
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 {
|
|
|
|
}
|
|
}
|
|
}
|