Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/20/14 17:33:22 (10 years ago)
Author:
jkarder
Message:

#2136:

  • refactored HLScriptGeneration to separate outputs from different running HL scripts.
  • added persistence support for HLScripts and fixed cloning
  • added code completion for all types in the currently loaded assemblies
  • merged trunk changes
Location:
branches/HLScript
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/HLScript

  • branches/HLScript/HeuristicLab.HLScript/3.3/HLScript.cs

    r10332 r10358  
    1717
    1818namespace HeuristicLab.HLScript {
    19   [Item("HLScript", "A HeuristicLab script.")]
     19  [Item("HL Script", "A HeuristicLab script.")]
    2020  [Creatable("Scripts")]
    2121  [StorableClass]
     
    8484      : base(original, cloner) {
    8585      code = original.code;
    86       //      variableStore = cloner.Clone(original.variableStore);
    87       //      compiledHLScript = cloner.Clone(original.compiledHLScript)
     86      variableStore = new VariableStore();
    8887      compilationUnitCode = original.compilationUnitCode;
    8988      if (original.compileErrors != null)
     
    9291
    9392    public HLScript()
    94       : base("HLS") {
     93      : base("HL Script", "A HeuristicLab script.") {
    9594      code = CodeTemplate;
    96       variableStore = new VariableStore();
    97     }
    98 
    99     [StorableHook(HookType.AfterDeserialization)]
    100     private void AfterDeserialization() {
    101       compiledHLScript = null;
    10295      variableStore = new VariableStore();
    10396    }
     
    172165    }
    173166
     167    public IEnumerable<Assembly> GetAssemblies() {
     168      var assemblies = new List<Assembly>();
     169      foreach (var a in AppDomain.CurrentDomain.GetAssemblies()) {
     170        try {
     171          if (File.Exists(a.Location)) assemblies.Add(a);
     172        } catch (NotSupportedException) {
     173          // NotSupportedException is thrown while accessing
     174          // the Location property of the anonymously hosted
     175          // dynamic methods assembly, which is related to
     176          // LINQ queries
     177        }
     178      }
     179      assemblies.Add(typeof(Microsoft.CSharp.RuntimeBinder.Binder).Assembly); // for dlr functionality
     180      return assemblies;
     181    }
     182
    174183    private readonly Regex LineSplitter = new Regex(@"\r\n|\r|\n");
    175184    private readonly Regex SafeTypeNameCharRegex = new Regex("[_a-zA-Z0-9]+");
     
    177186    private readonly Regex NamespaceDeclarationRegex = new Regex(@"using\s+(@?[a-z_A-Z]\w+(?:\s*\.\s*@?[a-z_A-Z]\w*)*)\s*;");
    178187    private readonly Regex NamespaceRegex = new Regex(@"(@?[a-z_A-Z]\w+(?:\s*\.\s*@?[a-z_A-Z]\w*)*)");
     188    private readonly Regex CommentRegex = new Regex(@"((/\*)[^/]+(\*/))|(//.*)");
    179189
    180190    private CodeCompileUnit CreateCompilationUnit() {
     
    191201
    192202    private IEnumerable<string> GetNamespaces() {
    193       var strings = NamespaceDeclarationRegex.Matches(code)
     203      var strings = NamespaceDeclarationRegex.Matches(CommentRegex.Replace(code, string.Empty))
    194204                                             .Cast<Match>()
    195205                                             .Select(m => m.Value);
     
    207217          yield return trimmedLine;
    208218      }
    209     }
    210 
    211     private IEnumerable<Assembly> GetAssemblies() {
    212       var assemblies = new List<Assembly>();
    213       foreach (var a in AppDomain.CurrentDomain.GetAssemblies()) {
    214         try {
    215           if (File.Exists(a.Location)) assemblies.Add(a);
    216         } catch (NotSupportedException) {
    217           // NotSupportedException is thrown while accessing
    218           // the Location property of the anonymously hosted
    219           // dynamic methods assembly, which is related to
    220           // LINQ queries
    221         }
    222       }
    223       assemblies.Add(typeof(Microsoft.CSharp.RuntimeBinder.Binder).Assembly); // for dlr functionality
    224       return assemblies;
    225219    }
    226220
Note: See TracChangeset for help on using the changeset viewer.