상속: MidExp
예제 #1
0
        private MidExp SimplifyLabelExpImpl(
            MidLabelExp labelExp,
            MidLetExp letExp,
            SimplifyEnv env)
        {
            // As long as the label doesn't occur in the
            // bound expression, we can move it outside
            // of the label's bounds.
            if (!UsesLabel(letExp.Exp, labelExp.Label))
            {
                MidExp result = new MidLetExp(
                    letExp.Range,
                    letExp.Var,
                    letExp.Exp,
                    new MidLabelExp(
                        labelExp.Range,
                        labelExp.Label,
                        letExp.Body,
                        labelExp.Type));
                result = SimplifyExp(result, env);
                return(result);
            }

            return(labelExp);
        }
예제 #2
0
        private MidExp SimplifyLabelExpImpl(
            MidLabelExp labelExp,
            MidExp exp,
            SimplifyEnv env)
        {
            if (!UsesLabel(exp, labelExp.Label))
            {
                return(exp);
            }

            return(labelExp);
        }
예제 #3
0
        private MidExp SimplifyLabelExpImpl(
            MidLabelExp labelExp,
            MidBreakExp breakExp,
            SimplifyEnv env)
        {
            if (labelExp.Label == breakExp.Label)
            {
                return(breakExp.Value);
            }

            return(labelExp);
        }
        private EmitValHLSL EmitExpImpl(MidLabelExp exp, Span span)
        {
            if (_labels.ContainsKey(exp.Label))
            {
                return EmitExp(exp.Body, span);
            }

            // Try to resolve this label with
            // loop nesting...

            var resultType = EmitType(exp.Type);
            var resultVar = resultType.CreateVal("__block_result");
            DeclareLocal(resultVar, span);

            Label newLabel = new BreakLabel(
                exp.Label,
                this,
                resultVar);

            _nestedLabels.Push(newLabel);
            try
            {
                span.WriteLine("do {");

                var innerSpan = span.IndentSpan();

                var bodyVal = EmitExp(exp.Body, innerSpan);
                if (bodyVal != null)
                {
                    Assign(resultVar, bodyVal, innerSpan);
                }

                span.WriteLine("} while(false);");
            }
            finally
            {
                _nestedLabels.Pop();
            }
            return resultVar;
        }
예제 #5
0
 private MidExp SimplifyExpImpl(MidLabelExp exp, SimplifyEnv env)
 {
     return(SimplifyLabelExpImpl(exp, (dynamic)exp.Body, env));
 }
예제 #6
0
 private void TransformChildrenImpl(
     MidLabelExp exp)
 {
     exp.Body = Transform(exp.Body);
 }
 public void PreEmitExpImpl(
     MidLabelExp exp,
     Span span)
 {
     PreEmitExp(exp.Body, span);
 }
예제 #8
0
        private MidExp SimplifyLabelExpImpl(
            MidLabelExp labelExp,
            MidExp exp,
            SimplifyEnv env)
        {
            if (!UsesLabel(exp, labelExp.Label))
                return exp;

            return labelExp;
        }
예제 #9
0
        private MidExp SimplifyLabelExpImpl(
            MidLabelExp labelExp,
            MidBreakExp breakExp,
            SimplifyEnv env)
        {
            if (labelExp.Label == breakExp.Label)
            {
                return breakExp.Value;
            }

            return labelExp;
        }
예제 #10
0
        private MidExp SimplifyLabelExpImpl(
            MidLabelExp labelExp,
            MidLetExp letExp,
            SimplifyEnv env)
        {
            // As long as the label doesn't occur in the
            // bound expression, we can move it outside
            // of the label's bounds.
            if (!UsesLabel(letExp.Exp, labelExp.Label))
            {
                MidExp result = new MidLetExp(
                    letExp.Range,
                    letExp.Var,
                    letExp.Exp,
                    new MidLabelExp(
                        labelExp.Range,
                        labelExp.Label,
                        letExp.Body,
                        labelExp.Type));
                result = SimplifyExp(result, env);
                return result;
            }

            return labelExp;
        }
예제 #11
0
 private MidExp SimplifyExpImpl(MidLabelExp exp, SimplifyEnv env)
 {
     return SimplifyLabelExpImpl(exp, (dynamic) exp.Body, env);
 }
 private void TransformChildrenImpl(
     MidLabelExp exp)
 {
     exp.Body = Transform(exp.Body);
 }