コード例 #1
0
 public void PreEmitExpImpl(
     MidIfExp exp,
     Span span)
 {
     PreEmitExp(exp.Condition, span);
     PreEmitExp(exp.Then, span);
     PreEmitExp(exp.Else, span);
 }
コード例 #2
0
        private EmitValHLSL EmitExpImpl(MidIfExp exp, Span span)
        {
            var condition = EmitExp(exp.Condition, span);

            bool isVoid = exp.Type is MidVoidType;

            ITypeHLSL expType = VoidVal.Type;
            EmitValHLSL temp = VoidVal;
            if (!isVoid)
            {
                expType = EmitType(exp.Type);
                temp = expType.CreateVal(
                    _shared.GenerateName("_if"));
                DeclareLocal(temp, span);
            }

            span.WriteLine("if ({0})", condition);
            span.WriteLine("{");
            var thenVal = EmitExp(exp.Then, span.IndentSpan());
            if (!isVoid)
            {
                Assign(temp, thenVal, span.IndentSpan());
            }
            span.WriteLine("}");
            span.WriteLine("else");
            span.WriteLine("{");
            var elseVal = EmitExp(exp.Else, span.IndentSpan());
            if (!isVoid)
            {
                Assign(temp, elseVal, span.IndentSpan());
            }
            span.WriteLine("}");

            return temp;
        }
コード例 #3
0
 private void TransformChildrenImpl(
     MidIfExp exp)
 {
     exp.Condition = Transform(exp.Condition);
     exp.Then = Transform(exp.Then);
     exp.Else = Transform(exp.Else);
 }