mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
scripting language now has support for list and map literals: " [a,b,c] "
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@422 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -101,6 +101,11 @@ ScriptValueP Context::eval(const Script& script, bool useScope) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
// Make an object
|
||||
case I_MAKE_OBJECT: {
|
||||
makeObject(i.data);
|
||||
break;
|
||||
}
|
||||
|
||||
// Function call
|
||||
case I_CALL: {
|
||||
@@ -324,3 +329,20 @@ void instrTernary(TernaryInstructionType i, ScriptValueP& a, const ScriptValueP&
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Simple instructions : object
|
||||
|
||||
void Context::makeObject(size_t n) {
|
||||
intrusive_ptr<ScriptCustomCollection> ret(new ScriptCustomCollection());
|
||||
size_t begin = stack.size() - 2 * n;
|
||||
for (size_t i = 0 ; i < n ; ++i) {
|
||||
const ScriptValueP& key = stack[begin + 2 * i];
|
||||
const ScriptValueP& val = stack[begin + 2 * i + 1];
|
||||
ret->value.push_back(val);
|
||||
if (key != script_nil) { // valid key
|
||||
ret->key_value[key->toString()] = val;
|
||||
}
|
||||
}
|
||||
stack.resize(begin);
|
||||
stack.push_back(ret);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user