コード例 #1
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;
        }
コード例 #2
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;
        }
コード例 #3
0
ファイル: HlslExpr.cs プロジェクト: maxburke/HlslDom
 /// <summary>
 /// Construct a ForExpr.
 /// </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>
 public ForExpr(DeclExpr initializer, Expr test, Expr update)
     : this(initializer, test, update, (int)LoopAttributes.NO_ATTRIBUTE, 0)
 {
 }
コード例 #4
0
ファイル: HlslExpr.cs プロジェクト: maxburke/HlslDom
 /// <summary>
 /// Construct a ForExpr with an attribute.
 /// </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>
 public ForExpr(DeclExpr initializer, Expr test, Expr update, LoopAttributes attributes)
     : this(initializer, test, update, attributes, 0)
 {
     if (attributes == LoopAttributes.UNROLL)
         throw new HlslDomException("Unroll attribute specified without an unroll depth!");
 }
コード例 #5
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;
        }
コード例 #6
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;
        }
コード例 #7
0
ファイル: HlslExpr.cs プロジェクト: maxburke/HlslDom
 /// <summary>
 /// Add an expression to the body of this compound expression.
 /// </summary>
 /// <param name="expr">The expression to add</param>
 public void Add(Expr expr)
 {
     Body.Add(expr);
 }
コード例 #8
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;
        }
コード例 #9
0
ファイル: HlslExpr.cs プロジェクト: maxburke/HlslDom
        /// <summary>
        /// Construct a CallExpr to the specified function with the specified parameters.
        /// </summary>
        /// <param name="fn">Function to call.</param>
        /// <param name="parameters">Parameters for function.</param>
        public CallExpr(Function fn, Expr[] parameters)
        {
            Fn = fn;
            Parameters = new Value[parameters.Length];

            for (int i = 0; i < parameters.Length; ++i)
                Parameters[i] = parameters[i].Value;

            if (!fn.IsValidCall(Parameters))
                throw new HlslDomException(string.Format("Call to {0} is not valid!", fn.Name));
        }
コード例 #10
0
ファイル: HlslExpr.cs プロジェクト: maxburke/HlslDom
        /// <summary>
        /// Construct a ternary expression.
        /// </summary>
        /// <param name="testExpr">The value to perform the test on.</param>
        /// <param name="ifTrue">Expression value if the test evaluates to true.</param>
        /// <param name="ifFalse">Expression value if the test evaluates to false.</param>
        public TernaryExpr(Expr testExpr, Expr ifTrue, Expr ifFalse)
        {
            if (!(testExpr.Value.ValueType is BoolType))
                throw new HlslDomException("Ternary expression test must evaluate to a boolean type!");

            if (ifTrue.Value.ValueType != ifFalse.Value.ValueType)
                throw new HlslDomException("Both sides of the ternary expression must evaluate to the same type!");

            TestExpr = testExpr;
            IfTrue = ifTrue;
            IfFalse = ifFalse;
        }
コード例 #11
0
ファイル: HlslExpr.cs プロジェクト: maxburke/HlslDom
 /// <summary>
 /// Construct a ReturnExpr.
 /// </summary>
 /// <param name="value">Value to return.</param>
 public ReturnExpr(Expr value)
 {
     ReturnValue = value;
 }