Exemple #1
0
        public override void Eval(EvaluatorState ev)
        {
            //Console.WriteLine(this.ToString());

            // index is in R
            IValue keyValue = ev.GetVal();

            // get table (it is on the stack[top])
            IValue tableValue = ev.GetStackTopVal();

            ev.Stack.Pop();

            // for array returns ptr to array[index] as TYPE_TABLEDATAREF
            // else raises an error
            if (tableValue.TypeOf() == ValueTypeID.TYPE_TABLEREF)
            {
                string         key   = keyValue.GetStringValue();
                ValueTable     table = (ValueTable)tableValue.GetObjectValue();
                ValueTableItem vti   = table.Search(key);
                if (vti == null)
                {
                    vti = table.Insert(key, new UndefinedValue());
                }

                ev.RegR = new TableDataRefValue(vti);
            }
            else
            {
                throw new SharpNektonException(new SharpNektonError(SharpNektonErrorID.E_EXPTYPETABLEREF));
            }
        }
Exemple #2
0
        public override void Eval(EvaluatorState ev)
        {
            //Console.WriteLine(this.ToString());

            // value is in R
            IValue val = ev.GetVal();

            // get tableptr
            // TODO: add a test, if is the value at the stack top a table
            ValueTable table = (ValueTable)ev.Stack.ReadTop().GetObjectValue();

            // get the key and assign the value to the array
            // table[key] = value
            table.Insert(table.AssignAutoKey().ToString(), val);
        }
Exemple #3
0
        public override void Eval(EvaluatorState ev)
        {
            //Console.WriteLine(this.ToString());

            // value is in R
            IValue val = ev.GetVal();

            // pop key
            IValue key = ev.GetStackTopVal();

            ev.Stack.Pop(); // pop key

            // get tableptr
            // TODO: add a test, if is the value at the stack top a table
            ValueTable table = (ValueTable)ev.Stack.ReadTop().GetObjectValue();

            // table[key] = value
            table.Insert(key.GetStringValue(), val);
        }
Exemple #4
0
 public ValueTableItem RegisterObject(string name)
 {
     // TODO: check for object redefinition
     return(libraryData.Insert(name, new UndefinedValue()));
 }