Beispiel #1
0
        public ICompiledCode CompileCodeDom(System.CodeDom.CodeMemberMethod code, IScriptModule module)
        {
            Contract.RequiresNotNull(code, "code");

            CompilerOptions options = (module != null) ? module.GetCompilerOptions(this) : GetDefaultCompilerOptions();

            return(CompileSourceUnit(_languageContext.GenerateSourceCode(code), module));
        }
Beispiel #2
0
        /// <summary>
        /// This method returns a ScriptSource object from a System.CodeDom.CodeObject.
        /// This is a factory method for creating a ScriptSources with this language binding.
        ///
        /// The expected CodeDom support is extremely minimal for syntax-independent expression of semantics.
        ///
        /// Languages may do more, but hosts should only expect CodeMemberMethod support,
        /// and only sub nodes consisting of the following:
        ///     CodeSnippetStatement
        ///     CodeSnippetExpression
        ///     CodePrimitiveExpression
        ///     CodeMethodInvokeExpression
        ///     CodeExpressionStatement (for holding MethodInvoke)
        /// </summary>
        public ScriptSource CreateScriptSource(CodeObject content, string path, SourceCodeKind kind)
        {
            ContractUtils.RequiresNotNull(content, "content");
            if (!_language.CanCreateSourceCode)
            {
                throw new NotSupportedException("Invariant engine cannot create scripts");
            }

            return(new ScriptSource(this, _language.GenerateSourceCode(content, path, kind)));
        }