public static ScriptObject MakeFunction( String name, ScriptList arguments, String help, ScriptObject body, ScriptObject declarationScope, bool copyScope = false) { if (copyScope) { var newScope = new Scope(); foreach (var prop in declarationScope.ListProperties()) { newScope.PushVariable(prop as String, declarationScope.GetLocalProperty(prop as String)); } declarationScope = newScope; } return(new GenericScriptObject( "@name", name, "@arguments", arguments, "@help", help, "@function-body", body, "@declaration-scope", declarationScope)); }
public GenericScriptObject(ScriptObject cloneFrom) { foreach (var str in cloneFrom.ListProperties()) { SetProperty(str as String, cloneFrom.GetProperty(str as String)); } }
public Context(ScriptObject obj) { Reset(); foreach (var name in obj.ListProperties()) { Scope.PushVariable(name as String, obj.GetLocalProperty(name as String)); } }
private static void EmitObjectProperties( System.IO.TextWriter to, ScriptObject obj, List <ScriptObject> globalFunctions, List <ObjectRecord> objects, List <ObjectRecord> lambdas, int depth, bool ignoreFunctions = false) { foreach (var propertyName in obj.ListProperties()) { to.Write("\n" + new String(' ', depth * 3) + "(" + propertyName as String + " "); var value = obj.GetLocalProperty(propertyName as String); EmitObjectProperty(to, value, globalFunctions, objects, lambdas, depth, ignoreFunctions); to.Write(")"); } }
public Context(ScriptObject obj) { Reset(); foreach (var name in obj.ListProperties()) Scope.PushVariable(name as String, obj.GetLocalProperty(name as String)); }
public GenericScriptObject(ScriptObject cloneFrom) { foreach (var str in cloneFrom.ListProperties()) SetProperty(str as String, cloneFrom.GetProperty(str as String)); }
private static void EnumerateObject( ScriptObject obj, List<ScriptObject> globalFunctions, List<ObjectRecord> objects, List<ObjectRecord> lambdas, bool ignoreFunctions = false) { if (obj == null) return; if (Function.IsFunction(obj)) { if (ignoreFunctions) return; //System function? if (Function.IsSystemFunction(obj)) return; //Lambda function? if (globalFunctions.Contains(obj)) return; if (AddRef(obj, lambdas)) EnumerateObject(obj["declaration-scope"] as ScriptObject, globalFunctions, objects, lambdas, ignoreFunctions); } else { foreach (var prop in obj.ListProperties()) { var value = obj.GetLocalProperty(prop as String); if (value is ScriptObject) { if (AddRef(value as ScriptObject, objects)) EnumerateObject(value as ScriptObject, globalFunctions, objects, lambdas, ignoreFunctions); } else if (value is ScriptList) { foreach (var item in value as ScriptList) { if (item is ScriptObject) if (AddRef(item as ScriptObject, objects)) EnumerateObject(item as ScriptObject, globalFunctions, objects, lambdas, ignoreFunctions); } } } } }
private static void EmitObjectProperties( System.IO.TextWriter to, ScriptObject obj, List<ScriptObject> globalFunctions, List<ObjectRecord> objects, List<ObjectRecord> lambdas, int depth, bool ignoreFunctions = false) { foreach (var propertyName in obj.ListProperties()) { to.Write("\n" + new String(' ', depth * 3) + "(" + propertyName as String + " "); var value = obj.GetLocalProperty(propertyName as String); EmitObjectProperty(to, value, globalFunctions, objects, lambdas, depth, ignoreFunctions); to.Write(")"); } }
private static void EnumerateObject( ScriptObject obj, List <ScriptObject> globalFunctions, List <ObjectRecord> objects, List <ObjectRecord> lambdas, bool ignoreFunctions = false) { if (obj == null) { return; } if (Function.IsFunction(obj)) { if (ignoreFunctions) { return; } //System function? if (Function.IsSystemFunction(obj)) { return; } //Lambda function? if (globalFunctions.Contains(obj)) { return; } if (AddRef(obj, lambdas)) { EnumerateObject(obj["declaration-scope"] as ScriptObject, globalFunctions, objects, lambdas, ignoreFunctions); } } else { foreach (var prop in obj.ListProperties()) { var value = obj.GetLocalProperty(prop as String); if (value is ScriptObject) { if (AddRef(value as ScriptObject, objects)) { EnumerateObject(value as ScriptObject, globalFunctions, objects, lambdas, ignoreFunctions); } } else if (value is ScriptList) { foreach (var item in value as ScriptList) { if (item is ScriptObject) { if (AddRef(item as ScriptObject, objects)) { EnumerateObject(item as ScriptObject, globalFunctions, objects, lambdas, ignoreFunctions); } } } } } } }
public static ScriptObject MakeFunction( String name, ScriptList arguments, String help, ScriptObject body, ScriptObject declarationScope, bool copyScope = false) { if (copyScope) { var newScope = new Scope(); foreach (var prop in declarationScope.ListProperties()) newScope.PushVariable(prop as String, declarationScope.GetLocalProperty(prop as String)); declarationScope = newScope; } return new GenericScriptObject( "@name", name, "@arguments", arguments, "@help", help, "@function-body", body, "@declaration-scope", declarationScope); }