/// <summary> /// Initializes a new instance of the <see cref="SyntaxParser" /> class. /// </summary> /// <param name="sourceFile">PHP source file representation</param> /// <param name="code">Source code of PHP script</param> public SyntaxParser(PhpSourceFile /*!*/ sourceFile, string /*!*/ code) { sourceUnit = new VirtualSourceFileUnit(compilationUnit, code, sourceFile, Encoding.Default); compilationUnit.SourceUnit = sourceUnit; // Assembly of the application is used instead of non-existing PHP script assembly. // To compile PHP, follow the basic technique of Phalanger PHP compilation. // <seealso cref="ScriptContext.CurrentContext" /> // <seealso cref="ApplicationContext.Default" /> // <seealso cref="ApplicationContext.AssemblyLoader" /> var assembly = System.Reflection.Assembly.GetExecutingAssembly(); var assemblyName = assembly.GetName(); var scriptAssembly = new BasicScriptAssembly(assembly, assemblyName, compilationUnit); // TODO: It simulates command compilationUnit.module = scriptAssembly.Module; // It affects compilationUnit.ScriptModule and compilationUnit.ScriptBuilder too var type = compilationUnit.GetType(); var field = type.GetField("module", BindingFlags.NonPublic | BindingFlags.Instance); field.SetValue(compilationUnit, scriptAssembly.GetModule()); IsParsed = false; output = new StringWriter(assemblyName.CultureInfo); Errors = new ErrorSinkThrowingException(); }
/// <summary> /// Initializes a new instance of the <see cref="BasicScriptAssemblyBuilder" /> class. /// </summary> /// <param name="assembly">Assembly of PHP script</param> /// <param name="assemblyName">Unique identity name of the PHP assembly</param> /// <param name="module">Module of PHP script</param> internal BasicScriptAssemblyBuilder( BasicScriptAssembly /*!*/ assembly, AssemblyName assemblyName, Module /*!*/ module) : base( assembly, assemblyName, Path.GetDirectoryName(module.FullyQualifiedName), module.Name, AssemblyKinds.Library, new List <ResourceFileReference>(0), false, false, true, null) { }