Example #1
0
        public static TotemValue Push(TotemValue array, TotemArguments parameters)
        {
            TotemArray arr = (TotemArray)array;

            arr.value.Add(parameters.Value(0));
            return(arr);
        }
Example #2
0
 public override TotemValue Add(TotemValue other)
 {
     if (other.GetType() == typeof(TotemString))
     {
         return(new TotemString(value + ((TotemString)other).Value));
     }
     return(base.Add(other));
 }
Example #3
0
 public static TotemValue Filter(TotemValue array, TotemArguments parameters)
 {
     TotemArray newArr = new TotemArray();
     TotemArray arr = (TotemArray)array;
     TotemValue fn = parameters.Value(0);
     foreach (var itm in arr.value)
     {
         var arguments = new TotemArguments();
         arguments.Add(null, itm);
         if ((bool)fn.Execute(arguments))
             newArr.AddItem(itm);
     }
     return newArr;
 }
Example #4
0
        public static TotemValue Filter(TotemValue array, TotemArguments parameters)
        {
            TotemArray newArr = new TotemArray();
            TotemArray arr    = (TotemArray)array;
            TotemValue fn     = parameters.Value(0);

            foreach (var itm in arr.value)
            {
                var arguments = new TotemArguments();
                arguments.Add(null, itm);
                if ((bool)fn.Execute(arguments))
                {
                    newArr.AddItem(itm);
                }
            }
            return(newArr);
        }
Example #5
0
 public static TotemValue Implement(TotemValue type, TotemArguments args)
 {
     var tt = (TotemType)type;
     foreach (var arg in args)
     {
         if (!string.IsNullOrEmpty(arg.Name) && arg.Value.Type.GetType() == typeof(Types.Function))
         {
             var fn = (TotemFunction)arg.Value;
             tt.MapMethod(arg.Name, (@this, arguments) =>
             {
                 var a = new TotemArguments();
                 a.Add(null, @this);
                 foreach (var ar in arguments)
                     a.Add(ar.Name, ar.Value);
                 return fn.Execute(a);
             });
         }
     }
     return TotemValue.Undefined;
 }
Example #6
0
        public static TotemValue Implement(TotemValue type, TotemArguments args)
        {
            var tt = (TotemType)type;

            foreach (var arg in args)
            {
                if (!string.IsNullOrEmpty(arg.Name) && arg.Value.Type.GetType() == typeof(Types.Function))
                {
                    var fn = (TotemFunction)arg.Value;
                    tt.MapMethod(arg.Name, (@this, arguments) =>
                    {
                        var a = new TotemArguments();
                        a.Add(null, @this);
                        foreach (var ar in arguments)
                        {
                            a.Add(ar.Name, ar.Value);
                        }
                        return(fn.Execute(a));
                    });
                }
            }
            return(TotemValue.Undefined);
        }
Example #7
0
 public static TotemString ToString(TotemValue str, TotemArguments args)
 {
     return new TotemString(((TotemString)str).Value);
 }
Example #8
0
 public static TotemValue GetParent(TotemValue type)
 {
     return ((TotemType)type).Parent ?? TotemValue.Null;
 }
Example #9
0
 public static TotemValue GetParent(TotemValue type)
 {
     return(((TotemType)type).Parent ?? TotemValue.Null);
 }
Example #10
0
 public static TotemType GetType(TotemValue @this)
 {
     return(@this.Type);
 }
Example #11
0
 public override TotemValue Add(TotemValue other)
 {
     if (other.GetType() == typeof(TotemString))
         return new TotemString(value + ((TotemString)other).Value);
     return base.Add(other);
 }
Example #12
0
 public TotemMethod(TotemValue @this, TotemScope env, string name, TotemParameter[] parametersDefinition)
     : base(env, name, parametersDefinition)
 {
     this.@this = @this;
 }
Example #13
0
 public ClrMethod(string name, TotemValue @this, Method method)
     : base(@this, TotemScope.Global, name, new TotemParameter[0])
 {
     this.method = method;
 }
Example #14
0
 public static TotemValue GetLength(TotemValue @this)
 {
     return new TotemNumber(((TotemArray)@this).value.Count);
 }
Example #15
0
 public static TotemNumber GetLength(TotemValue str)
 {
     return new TotemNumber(((TotemString)str).Value.Length);
 }
Example #16
0
 public static TotemValue GetLength(TotemValue @this)
 {
     return(new TotemNumber(((TotemArray)@this).value.Count));
 }
Example #17
0
 public static TotemString ToString(TotemValue @null, TotemArguments args)
 {
     return(new TotemString("<undefined>"));
 }
Example #18
0
 public static TotemString ToString(TotemValue type, TotemArguments args)
 {
     return new TotemString("[Totem " + ((TotemType)type).Name + "]");
 }
Example #19
0
 public static TotemValue Push(TotemValue array, TotemArguments parameters)
 {
     TotemArray arr = (TotemArray)array;
     arr.value.Add(parameters.Value(0));
     return arr;
 }
Example #20
0
 public static TotemString ToUpperCase(TotemValue str, TotemArguments args)
 {
     return new TotemString(((TotemString)str).Value.ToUpper());
 }
Example #21
0
 public static TotemString ToString(TotemValue @null, TotemArguments args)
 {
     return new TotemString("<undefined>");
 }
Example #22
0
 public TotemMethod(TotemValue @this, TotemScope env, string name, TotemParameter[] parametersDefinition)
     : base(env, name, parametersDefinition)
 {
     this.@this = @this;
 }
Example #23
0
 public ClrMethod(string name, TotemValue @this, Method method)
     : base(@this, TotemScope.Global, name, new TotemParameter[0])
 {
     this.method = method;
 }
Example #24
0
 public static TotemNumber GetLength(TotemValue str)
 {
     return(new TotemNumber(((TotemString)str).Value.Length));
 }
Example #25
0
 public static TotemString ToString(TotemValue @this, TotemArguments args)
 {
     return(new TotemString("[" + @this.Type.Name + "]"));
 }
Example #26
0
 public static TotemString ToLowerCase(TotemValue str, TotemArguments args)
 {
     return(new TotemString(((TotemString)str).Value.ToLower()));
 }
Example #27
0
 public TotemParameter(string name, TotemValue defaultValue)
 {
     this.defaultValue = defaultValue ?? TotemValue.Undefined;
     this.name = string.IsNullOrWhiteSpace(name) ? null : name;
 }
Example #28
0
 public static TotemString ToString(TotemValue str, TotemArguments args)
 {
     return(new TotemString(((TotemString)str).Value));
 }
Example #29
0
 public static TotemString ToString(TotemValue type, TotemArguments args)
 {
     return(new TotemString("[Totem " + ((TotemType)type).Name + "]"));
 }
Example #30
0
 public static TotemType GetType(TotemValue @this)
 {
     return @this.Type;
 }
Example #31
0
 public TotemParameter(string name, TotemValue defaultValue)
 {
     this.defaultValue = defaultValue ?? TotemValue.Undefined;
     this.name         = string.IsNullOrWhiteSpace(name) ? null : name;
 }
Example #32
0
 public static TotemString ToString(TotemValue @this, TotemArguments args)
 {
     return new TotemString("[" + @this.Type.Name + "]");
 }