public static TotemValue Push(TotemValue array, TotemArguments parameters) { TotemArray arr = (TotemArray)array; arr.value.Add(parameters.Value(0)); return(arr); }
public override TotemValue Add(TotemValue other) { if (other.GetType() == typeof(TotemString)) { return(new TotemString(value + ((TotemString)other).Value)); } return(base.Add(other)); }
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; }
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); }
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; }
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); }
public static TotemString ToString(TotemValue str, TotemArguments args) { return new TotemString(((TotemString)str).Value); }
public static TotemValue GetParent(TotemValue type) { return ((TotemType)type).Parent ?? TotemValue.Null; }
public static TotemValue GetParent(TotemValue type) { return(((TotemType)type).Parent ?? TotemValue.Null); }
public static TotemType GetType(TotemValue @this) { return(@this.Type); }
public override TotemValue Add(TotemValue other) { if (other.GetType() == typeof(TotemString)) return new TotemString(value + ((TotemString)other).Value); return base.Add(other); }
public TotemMethod(TotemValue @this, TotemScope env, string name, TotemParameter[] parametersDefinition) : base(env, name, parametersDefinition) { this.@this = @this; }
public ClrMethod(string name, TotemValue @this, Method method) : base(@this, TotemScope.Global, name, new TotemParameter[0]) { this.method = method; }
public static TotemValue GetLength(TotemValue @this) { return new TotemNumber(((TotemArray)@this).value.Count); }
public static TotemNumber GetLength(TotemValue str) { return new TotemNumber(((TotemString)str).Value.Length); }
public static TotemValue GetLength(TotemValue @this) { return(new TotemNumber(((TotemArray)@this).value.Count)); }
public static TotemString ToString(TotemValue @null, TotemArguments args) { return(new TotemString("<undefined>")); }
public static TotemString ToString(TotemValue type, TotemArguments args) { return new TotemString("[Totem " + ((TotemType)type).Name + "]"); }
public static TotemValue Push(TotemValue array, TotemArguments parameters) { TotemArray arr = (TotemArray)array; arr.value.Add(parameters.Value(0)); return arr; }
public static TotemString ToUpperCase(TotemValue str, TotemArguments args) { return new TotemString(((TotemString)str).Value.ToUpper()); }
public static TotemString ToString(TotemValue @null, TotemArguments args) { return new TotemString("<undefined>"); }
public static TotemNumber GetLength(TotemValue str) { return(new TotemNumber(((TotemString)str).Value.Length)); }
public static TotemString ToString(TotemValue @this, TotemArguments args) { return(new TotemString("[" + @this.Type.Name + "]")); }
public static TotemString ToLowerCase(TotemValue str, TotemArguments args) { return(new TotemString(((TotemString)str).Value.ToLower())); }
public TotemParameter(string name, TotemValue defaultValue) { this.defaultValue = defaultValue ?? TotemValue.Undefined; this.name = string.IsNullOrWhiteSpace(name) ? null : name; }
public static TotemString ToString(TotemValue str, TotemArguments args) { return(new TotemString(((TotemString)str).Value)); }
public static TotemString ToString(TotemValue type, TotemArguments args) { return(new TotemString("[Totem " + ((TotemType)type).Name + "]")); }
public static TotemType GetType(TotemValue @this) { return @this.Type; }
public static TotemString ToString(TotemValue @this, TotemArguments args) { return new TotemString("[" + @this.Type.Name + "]"); }