コード例 #1
0
ファイル: HlslExpr.cs プロジェクト: maxburke/HlslDom
        /// <summary>
        /// Constructs an IfExpr with the provided test expression.
        /// </summary>
        /// <param name="test">The condition to test.</param>
        public IfExpr(Expr test)
        {
            if (!test.HasValue())
                throw new HlslDomException("Test expression doesn't return a value!");

            if (!(test.Value.ValueType is BoolType))
                throw new HlslDomException("Test expression doesn't evaluate to a boolean type!");

            Test = test;
        }
コード例 #2
0
ファイル: HlslExpr.cs プロジェクト: maxburke/HlslDom
        /// <summary>
        /// Construct a ForExpr with an attribute and an unroll depth.
        /// </summary>
        /// <param name="initializer">Initializer expression.</param>
        /// <param name="test">Test expression, must evaluate to a scalar boolean.</param>
        /// <param name="update">Update expression.</param>
        /// <param name="attributes">Loop attribute.</param>
        /// <param name="unrollDepth">Depth with which to unroll the loop, used with LoopAttributes.UNROLL</param>
        public ForExpr(DeclExpr initializer, Expr test, Expr update, LoopAttributes attributes, int unrollDepth)
        {
            if (!test.HasValue())
                throw new HlslDomException("Test expression doesn't return a value!");

            if (!(test.Value.ValueType is BoolType))
                throw new HlslDomException("Test expression does not return a boolean value!");

            Initializer = initializer;
            Test = test;
            Update = update;
            Attributes = attributes;
            UnrollDepth = unrollDepth;
        }
コード例 #3
0
ファイル: HlslExpr.cs プロジェクト: maxburke/HlslDom
        /// <summary>
        /// Create a variable declaration initialized to the value of the given expression.
        /// </summary>
        /// <param name="expression">Expression; must resolve to a value.</param>
        public DeclExpr(Expr expression)
        {
            if (!expression.HasValue())
                throw new HlslDomException("Provided expression must resolve to a value!");

            Type = expression.Value.ValueType;
            Name = string.Format("var{0}", Counter++);
            InitValue = expression.Value;
        }
コード例 #4
0
ファイル: HlslExpr.cs プロジェクト: maxburke/HlslDom
        /// <summary>
        /// Create a named variable declaration initialized to the value of the given expression.
        /// </summary>
        /// <param name="expression">Expression; must resolve to a value.</param>
        /// <param name="name">Variable name.</param>
        public DeclExpr(Expr expression, string name)
        {
            if (!expression.HasValue())
                throw new HlslDomException("Provided expression must resolve to a value!");

            Type = expression.Value.ValueType;
            Name = name;
            InitValue = expression.Value;
        }
コード例 #5
0
ファイル: HlslExpr.cs プロジェクト: maxburke/HlslDom
        public CommaExpr(Expr lhs, Expr rhs)
        {
            if (!lhs.HasValue() || !rhs.HasValue())
                throw new HlslDomException("Both the left and right hand sides of the comma expression must have a value!");

            LHS = lhs;
            RHS = rhs;
        }