public GenContext(string assyName, string directory, CompilerMode mode) { AssemblyName aname = new AssemblyName(assyName); _assyBldr = AppDomain.CurrentDomain.DefineDynamicAssembly(aname, AssemblyBuilderAccess.RunAndSave,directory); _moduleBldr = _assyBldr.DefineDynamicModule(aname.Name, aname.Name + ".dll", true); _mode = mode; }
public GenContext(string assyName, string directory, CompilerMode mode) { AssemblyName aname = new AssemblyName(assyName); _assyBldr = AppDomain.CurrentDomain.DefineDynamicAssembly(aname, AssemblyBuilderAccess.RunAndSave, directory); _moduleBldr = _assyBldr.DefineDynamicModule(aname.Name, aname.Name + ".dll", true); _mode = mode; }
public void Reset() { ROMFilePath = string.Empty; Mode = CompilerMode.Standard; DebugMode = DebugLevel.Normal; FreeSpaceByte = 0xFF; DynamicOffset = 0; DynamicOverwrite = false; Definitions.Clear(); }
/// <summary> /// Gets a string containing the compiled sass output. /// </summary> /// <param name="input"> /// The input to compile. /// </param> /// <param name="fileName"> /// The name of the file to compile. /// </param> /// <returns> /// The <see cref="string"/> containing the compiled sass output. /// </returns> public string CompileSass(string input, string fileName) { lock (SyncRoot) { this.Initialize(); try { CompilerMode mode = CompilerMode.Scss; if (Regex.IsMatch(fileName, @"\.sass$")) { mode = CompilerMode.Sass; } // Change the executing directory so imports work. string statement = string.Format("Dir.chdir '{0}'", Path.GetDirectoryName(fileName)); engine.Execute(statement, scope); dynamic sassMode = mode == CompilerMode.Sass ? engine.Execute( "{:cache => false, :syntax => :sass, :filename => '" + fileName + "'}") : engine.Execute( "{:cache => false, :syntax => :scss, :filename => '" + fileName + "'}"); return((string)sassEngine.compile(input, sassMode)); } catch (Exception ex) { if (ex.Message == "Sass::SyntaxError") { const string Empty = ""; dynamic error = ex; StringBuilder sb = new StringBuilder(); sb.AppendFormat("{0}\n\n", error.to_s()); sb.AppendFormat("Backtrace:\n{0}\n\n", error.sass_backtrace_str(fileName) ?? Empty); sb.AppendFormat("FileName: {0}\n\n", error.sass_filename() ?? fileName); sb.AppendFormat("MixIn: {0}\n\n", error.sass_mixin() ?? Empty); sb.AppendFormat("Line Number: {0}\n\n", error.sass_line() ?? Empty); sb.AppendFormat("Sass Template:\n{0}\n\n", error.sass_template ?? Empty); throw new SassAndScssCompilingException(sb.ToString(), ex); } throw ex; } } }
public void Compile(CompilerMode mode, string sourceCode, string filename) { _compilers[mode].Compile(sourceCode, filename); if (_compilers[mode].CompileErrors.Count > 0) { Console.WriteLine(_compilers[mode].CompileErrors.Count > 1 ? $"Compilation ended with errors" : $"Compilation ended with error"); foreach (var cur in _compilers[mode].CompileErrors) { Console.WriteLine(cur.ToString()); } } else { Console.WriteLine($"Compilation from {filename} completed to {_compilers[mode].OutputFilename}"); } }
/// <summary> /// Gets a string containing the compiled sass output. /// </summary> /// <param name="input"> /// The input to compile. /// </param> /// <param name="fileName"> /// The name of the file to compile. /// </param> /// <returns> /// The <see cref="string"/> containing the compiled sass output. /// </returns> public string CompileSass(string input, string fileName) { try { CompilerMode mode = CompilerMode.Scss; if (Regex.IsMatch(fileName, @"\.sass$")) { mode = CompilerMode.Sass; } string processedInput = mode == CompilerMode.Scss ? input : this.ConvertToScss(input); return(this.compiler.Compile(processedInput, OutputStyle.Nested, false, 5, new[] { Path.GetDirectoryName(fileName) })); } catch (Exception ex) { throw new SassAndScssCompilingException(ex.Message, ex.InnerException); } }
private GenContext(CompilerMode mode) { _mode = mode; }
public GenContext(string assyName, CompilerMode mode) : this(assyName,null,mode) { }
//Type _baseType; //public Type BaseType //{ // get { return _baseType; } // //set { _baseType = value; } //} //ParameterExpression _thisFn; //public ParameterExpression ThisFn //{ // get { return _thisFn; } // //set { _thisFn = value; } //} #endregion #region C-tors & factory methods public GenContext(string assyName, CompilerMode mode) : this(assyName, null, mode) { }
public void Compiler_Mode_Should_Be_Populated(CompilerMode mode) { var compiler = new SimpleCompiler(new Expression("", ExpressionFlag.HsFlagAllowempty), mode); compiler.Mode.Should().Be(mode); }