예제 #1
0
        public static ShaderFile CreateFromText(string payload, IGlobalScopeFactory globalScopeFactory = null)
        {
            globalScopeFactory = globalScopeFactory ?? new GlobalScopeFactory();
            ShaderFile result = new ShaderFile();
            AstParser  parser = new AstParser();

            result.SyntaxTree = parser.Parse(payload);

            var globalScope = globalScopeFactory.Construct(result.SyntaxTree.Version);

            SemanticModelBuilderVisitor sBuilder = new SemanticModelBuilderVisitor();
            SemanticModelBuilderContext sContext = new SemanticModelBuilderContext();

            sBuilder.Visit(result.SyntaxTree, sContext);

            result.SemanticContext = new SemanticContext(sContext.Result, globalScope);
            result.SemanticContext.ResolveSymbolReferences();

            return(result);
        }
예제 #2
0
        public static ShaderFile CreateEmpty(ShaderVersion shaderVersion = ShaderVersion.GlslEs300, IGlobalScopeFactory globalScopeFactory = null)
        {
            globalScopeFactory = globalScopeFactory ?? new GlobalScopeFactory();
            ShaderFile result = new ShaderFile();

            result.SyntaxTree = new Root()
            {
                Version = shaderVersion
            };

            var globalScope = globalScopeFactory.Construct(shaderVersion);

            SemanticModelBuilderVisitor sBuilder = new SemanticModelBuilderVisitor();
            SemanticModelBuilderContext sContext = new SemanticModelBuilderContext();

            sBuilder.Visit(result.SyntaxTree, sContext);

            result.SemanticContext = new SemanticContext(sContext.Result, globalScope);

            return(result);
        }