// ( record fieldname -- value ) public override void Execute(Interpreter interp) { StringItem fieldname = (StringItem)interp.StackPop(); StackItem record = interp.StackPop(); interp.StackPush(record.GetValue(fieldname.StringValue)); }
// ( 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)); }
// ( 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); }
// ( 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); } }
// ( 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); }
// ( 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); } } } }
// ( name -- ) public override void Execute(Interpreter interp) { StringItem name = (StringItem)interp.StackPop(); interp.CurModule().AddVariableIfMissing(name.StringValue); }