// IScriptGenerator implementation
        public IEnumerable <string> Start(HxlForEachElement e)
        {
            yield return(EmitVarLoopStatus(e));

            var inExp = RewriteExpressionSyntax.BindVariables(e.In);

            yield return(string.Format("foreach (var {0} in {1}) {{", e.Var, inExp));

            yield return(string.Format("__closure.{0} = {0};", e.Var));

            yield return(EmitVarLoopStatusCurrent(e));
        }
        private string[] BindIf(Expression test, bool negate)
        {
            var testExp = RewriteExpressionSyntax.BindVariables(test).ToString();

            // TODO Should bind as a Boolean here

            if (negate)
            {
                testExp = string.Format("!({0})", testExp);
            }
            return(new []
            {
                string.Format("if ({0}) {{", testExp)
            });
        }
Beispiel #3
0
        internal HxlRenderWorkElement BindConditional(Expression test, bool negate)
        {
            var testExp = RewriteExpressionSyntax.BindVariables(test).ToString();

            // TODO Should bind as a Boolean here
            if (negate)
            {
                testExp = string.Format("!({0})", testExp);
            }
            string[] pre =
            {
                string.Format("if ({0}) {{", testExp)
            };

            string[] post = { "}" };
            return(new HxlRenderWorkElement(pre, post));
        }