Пример #1
0
        private GSCore execWhile(GSCoreCollection args)
        {
            GSCoreCollection commands = args.getSublist(1);
            GSCore           r        = null;

            while (ExecuteElement(args.getSafe(0)).getBooleanValue())
            {
                foreach (GSCore cmd in commands)
                {
                    r = ExecuteElement(cmd);
                    if (r is GSReturn)
                    {
                        break;
                    }
                }

                if (r is GSReturn)
                {
                    GSReturn ret = r as GSReturn;
                    if (ret.Type == GSReturn.TYPE_BREAK)
                    {
                        break;
                    }
                    if (ret.Type == GSReturn.TYPE_RETURN)
                    {
                        return(ret);
                    }
                }
            }

            return(GSCore.Void);
        }
Пример #2
0
        private GSCore execMessage(GSCoreCollection args)
        {
            GSCore result = GSCore.Void;

            // first is token, name of variable, object
            // second is token, message name
            // third etc are arguments
            if (args.Count >= 2 && args.getSafe(0) is GSToken && args.getSafe(1) is GSToken)
            {
                // evaluate the remaining portion of list
                GSCoreCollection subArgs = getNativeValues(args.getSublist(2));
                // first and second tokens
                GSToken t1 = args.getSafe(0) as GSToken;
                GSToken t2 = args.getSafe(1) as GSToken;
                // evaluate reference to object
                GSCore obj = ExecuteElement(t1);
                // execute message in the object
                result = obj.ExecuteMessage(t2.Token, subArgs);
            }

            return(result);
        }