Exemplo n.º 1
0
        public static ZilResult IVECTOR(Context ctx, int count, [CanBeNull] ZilObject init = null)
        {
            if (count < 0)
            {
                throw new InterpreterError(
                          InterpreterMessages._0_Expected_1,
                          "IVECTOR: arg 1",
                          "a non-negative FIX");
            }

            var contents = new List <ZilObject>(count);

            for (int i = 0; i < count; i++)
            {
                if (init != null)
                {
                    var zr = init.Eval(ctx);
                    if (zr.ShouldPass())
                    {
                        return(zr);
                    }

                    contents.Add((ZilObject)zr);
                }
                else
                {
                    contents.Add(ctx.FALSE);
                }
            }

            return(new ZilVector(contents.ToArray()));
        }
Exemplo n.º 2
0
        public static ZilResult EXPAND([NotNull] Context ctx, [NotNull] ZilObject value)
        {
            var result = value.Expand(ctx);

            if (result.ShouldPass())
            {
                return(result);
            }

            if ((ZilObject)result == value)
            {
                result = value.Eval(ctx);
            }

            return(result);
        }
Exemplo n.º 3
0
        public static ZilResult ISTRING(Context ctx, int count, [CanBeNull] ZilObject init = null)
        {
            if (count < 0)
            {
                throw new InterpreterError(
                          InterpreterMessages._0_Expected_1,
                          "ISTRING: arg 1",
                          "a non-negative FIX");
            }

            var contents = new List <char>(count);

            for (int i = 0; i < count; i++)
            {
                if (init != null)
                {
                    var initResult = init.Eval(ctx);
                    if (initResult.ShouldPass())
                    {
                        return(initResult);
                    }

                    if (!((ZilObject)initResult is ZilChar ch))
                    {
                        throw new InterpreterError(InterpreterMessages._0_Iterated_Values_Must_Be_CHARACTERs, "ISTRING");
                    }
                    contents.Add(ch.Char);
                }
                else
                {
                    contents.Add('\0');
                }
            }

            return(ZilString.FromString(new string(contents.ToArray())));
        }
Exemplo n.º 4
0
        public static ZilResult EVAL_IN_SEGMENT([NotNull] Context ctx, ZilObject dummy1,
                                                [NotNull] ZilObject value, [CanBeNull] ZilObject dummy2 = null)
#pragma warning restore RECS0154 // Parameter is never used
        {
            return(value.Eval(ctx));
        }
Exemplo n.º 5
0
 public static ZilResult EVAL([NotNull] Context ctx, [NotNull] ZilObject value, [NotNull] LocalEnvironment env)
 {
     return(value.Eval(ctx, env));
 }
Exemplo n.º 6
0
 public static ZilResult GETPROP([NotNull] Context ctx, [NotNull] ZilObject item, [NotNull] ZilObject indicator,
                                 [CanBeNull] ZilObject defaultValue = null)
 {
     return(ctx.GetProp(item, indicator) ?? defaultValue?.Eval(ctx) ?? ctx.FALSE);
 }