Example #1
0
        // ( record fieldname -- value )
        public override void Execute(Interpreter interp)
        {
            StringItem fieldname = (StringItem)interp.StackPop();
            StackItem  record    = interp.StackPop();

            interp.StackPush(record.GetValue(fieldname.StringValue));
        }
Example #2
0
        // ( items field -- sorted-items )
        public override void Execute(Interpreter interp)
        {
            StringItem       field     = (StringItem)interp.StackPop();
            ArrayItem        items     = (ArrayItem)interp.StackPop();
            List <StackItem> item_list = (List <StackItem>)items.ArrayValue;

            sort(item_list, field.StringValue);
            interp.StackPush(new ArrayItem(item_list));
        }
Example #3
0
        // ( record value fieldname -- record )
        public override void Execute(Interpreter interp)
        {
            StringItem fieldName = (StringItem)interp.StackPop();
            StackItem  valueItem = interp.StackPop();
            StackItem  record    = interp.StackPop();

            record.SetValue(fieldName.StringValue, valueItem);
            interp.StackPush(record);
        }
Example #4
0
        // ( items forthic -- )
        public override void Execute(Interpreter interp)
        {
            StringItem forthic = (StringItem)interp.StackPop();
            ArrayItem  items   = (ArrayItem)interp.StackPop();

            foreach (var item in items.ArrayValue)
            {
                interp.StackPush(item);
                interp.Run(forthic.StringValue);
            }
        }
Example #5
0
        // ( values fields -- record )
        public override void Execute(Interpreter interp)
        {
            ArrayItem fields = (ArrayItem)interp.StackPop();
            ArrayItem values = (ArrayItem)interp.StackPop();

            RecordItem result = new RecordItem();

            for (int i = 0; i < fields.ArrayValue.Count; i++)
            {
                StringItem keyItem = (StringItem)fields.ArrayValue[i];
                result.SetValue(keyItem.StringValue, values.ArrayValue[i]);
            }
            interp.StackPush(result);
        }
Example #6
0
        // ( array forthic -- ? )
        public override void Execute(Interpreter interp)
        {
            StringItem forthic = (StringItem)interp.StackPop();
            ArrayItem  indices = (ArrayItem)interp.StackPop();

            if (indices.ArrayValue.Count == 2)
            {
                IntItem i_max = (IntItem)indices.ArrayValue[0];
                IntItem j_max = (IntItem)indices.ArrayValue[1];
                for (var i = 0; i < i_max.IntValue; i++)
                {
                    for (var j = 0; j < j_max.IntValue; j++)
                    {
                        interp.StackPush(new IntItem(i));
                        interp.StackPush(new IntItem(j));
                        interp.Run(forthic.StringValue);
                    }
                }
            }
        }
Example #7
0
        // ( name -- )
        public override void Execute(Interpreter interp)
        {
            StringItem name = (StringItem)interp.StackPop();

            interp.CurModule().AddVariableIfMissing(name.StringValue);
        }