1 module orelang.operator.SetOperator; 2 import orelang.expression.ClassType, 3 orelang.operator.IOperator, 4 orelang.Engine, 5 orelang.Value; 6 7 class SetOperator : IOperator { 8 /** 9 * call 10 */ 11 public Value call(Engine engine, Value[] args) { 12 return engine.setVariable(args[0].getString, engine.eval(args[1])); 13 } 14 } 15 16 17 /** 18 * Set a value to the variable defined in parent scope 19 */ 20 class SetPOperator : IOperator { 21 /** 22 * call 23 */ 24 public Value call(Engine engine, Value[] args) { 25 return engine.peekSuper.setVariable(args[0].getString, engine.eval(args[1])); 26 } 27 } 28 29 30 /** 31 * Set a value to the variable defined in class value 32 */ 33 class SetCOperator : IOperator { 34 /** 35 * call 36 */ 37 public Value call(Engine engine, Value[] args) { 38 ClassType cls = engine.eval(args[0]).getClassType; 39 string varName = args[1].type == ValueType.SymbolValue ? args[1].getString : engine.eval(args[1]).getString; 40 Value value = engine.eval(args[2]); 41 42 return cls._engine.setVariable(varName, value); 43 } 44 }