public ScriptBlockAst Obfuscate(int seed, ScriptBlockAst ast) { var firstPass = new _ListVisitor(); ast.Visit(firstPass); var varList = firstPass.GetVariableNameList(); var secondPass = new _AlterVisitor(seed, varList, alphabet_, minLength_); return((ScriptBlockAst)ast.Visit(secondPass)); }
/// <summary> /// Finds all references (not including aliases) in a script for the given symbol /// </summary> /// <param name="scriptAst">The abstract syntax tree of the given script</param> /// <param name="foundSymbol">The symbol that we are looking for referneces of</param> /// <param name="needsAliases">If this reference search needs aliases. /// This should always be false and used for occurence requests</param> /// <returns>A collection of SymbolReference objects that are refrences to the symbolRefrence /// not including aliases</returns> public static IEnumerable <SymbolReference> FindReferencesOfSymbol( ScriptBlockAst scriptAst, SymbolReference foundSymbol, bool needsAliases) { FindReferencesVisitor referencesVisitor = new FindReferencesVisitor(foundSymbol); scriptAst.Visit(referencesVisitor); FindReferencesVisitor2 declarationVisitor2 = new FindReferencesVisitor2(foundSymbol); scriptAst.Visit(declarationVisitor2); return(referencesVisitor.FoundReferences.Concat(declarationVisitor2.FoundReferences).ToList()); }
static public void AstToFile(ScriptBlockAst ast, string path) { using (StreamWriter sw = new StreamWriter(path, false, new UTF8Encoding(false))) { var visitor = new _TextWriterVisitor(sw); ast.Visit(visitor); } }
static public void AstToConsole(ScriptBlockAst ast) { var writer = new StringWriter(); var visitor = new _TextWriterVisitor(writer); ast.Visit(visitor); System.Console.WriteLine(writer); }
/// <summary> /// Finds all references (not including aliases) in a script for the given symbol /// </summary> /// <param name="scriptAst">The abstract syntax tree of the given script</param> /// <param name="foundSymbol">The symbol that we are looking for referneces of</param> /// <param name="needsAliases">If this reference search needs aliases. /// This should always be false and used for occurence requests</param> /// <returns>A collection of SymbolReference objects that are refrences to the symbolRefrence /// not including aliases</returns> public static IEnumerable <SymbolReference> FindReferencesOfSymbol( ScriptBlockAst scriptAst, SymbolReference foundSymbol, bool needsAliases) { FindReferencesVisitor referencesVisitor = new FindReferencesVisitor(foundSymbol); scriptAst.Visit(referencesVisitor); return(referencesVisitor.FoundReferences); }