#include "__set.h" #include "Exception.h" #include "Operand.h" #include "KeywordValue.h" #include namespace jet { __set::__set(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local) : Tag(in, parentOut, global, parent, local) { output = false; if(!keywordDefined("name")) throw coreutils::Exception("set tag must have name defined."); if(!keywordDefined("expr") && keywordDefined("value") && hasContainer) throw coreutils::Exception("set tag cannot have both value and a container."); if(keywordDefined("expr") && !keywordDefined("value") && hasContainer) throw coreutils::Exception("set tag cannot have both expr and a container."); if(keywordDefined("expr") && keywordDefined("value") && !hasContainer) throw coreutils::Exception("set tag cannot have both expr and value."); if(!keywordDefined("expr") && !keywordDefined("value") && !hasContainer) throw coreutils::Exception("set tag must have a value, expr or a container."); if(keywordDefined("expr") && keywordDefined("eval")) throw coreutils::Exception("Cannot use eval with expr."); resolveKeyword("name"); storeVariable(keywords["name"]); // if(keywordDefined("expr")) { // if(!keywordDefined("scope") || (keywords["scope"] == "global")) // global.variables[keywords["name"]] = Operand(keywords["expr"], global, parent->variables, keywords).string; // else if(keywords["scope"] == "local") // local->variables[keywords["name"]] = Operand(keywords["expr"], global, parent->variables, keywords).string; // else if(keywords["scope"] == "parent") // local->parent->variables[keywords["name"]] = Operand(keywords["expr"], global, parent->variables, keywords).string; // } else if(hasContainer) { // processContainer(container); // if(evaluate) { // if(!keywordDefined("scope") || (keywords["scope"] == "global")) // global.variables[keywords["name"]] = out; // else if(keywords["scope"] == "local") // local->variables[keywords["name"]] = out; // else if(keywords["scope"] == "parent") // local->parent->variables[keywords["name"]] = out; // } else { // if(!keywordDefined("scope") || (keywords["scope"] == "global")) // global.variables[keywords["name"]] = container; // else if(keywords["scope"] == "local") // local->variables[keywords["name"]] = container; // else if(keywords["scope"] == "parent") // local->parent->variables[keywords["name"]] = container; // } // } else { // resolveKeyword("value"); // if(!keywordDefined("scope") || (keywords["scope"] == "global")) // global.variables[keywords["name"]] = keywords["value"]; // else if(keywords["scope"] == "local") // local->variables[keywords["name"]] = keywords["value"]; // else if(keywords["scope"] == "parent") // local->parent->variables[keywords["name"]] = keywords["value"]; // } } }