Inheritance: Expression
Ejemplo n.º 1
0
 internal static Loop Loop(LoopExpression expression)
 {
     return new Loop()
     {
         Body = Serialize(expression.Body),
         BreakLabel = expression.BreakLabel.Null(l => LabelTarget.Serialize(l)),
         ContinueLabel = expression.ContinueLabel.Null(l => LabelTarget.Serialize(l)),
     }.Apply(n => n.Type = TypeRef.Serialize(expression.Type));
 }
Ejemplo n.º 2
0
            protected override Expression VisitLoop(LoopExpression node)
            {
                if (node.BreakLabel != null)
                {
                    Labels.Add(node.BreakLabel);
                }

                if (node.ContinueLabel != null)
                {
                    Labels.Add(node.ContinueLabel);
                }

                return base.VisitLoop(node);
            }
        protected override Expression VisitLoop(LoopExpression node)
        {
            PushLabelInfo(node);

            var body = Visit(node.Body);

            var @break = default(LabelTarget);
            var @continue = default(LabelTarget);
            PopLabelInfo(out @break, out @continue);

            return node.Update(@break, @continue, body);
        }
 protected override Expression VisitLoop(LoopExpression node)
 {
     throw new NotSupportedException();
 }
Ejemplo n.º 5
0
        private void Compile(object frameObj) {
            if (Compiled) {
                return;
            }

            lock (this) {
                if (Compiled) {
                    return;
                }

                PerfTrack.NoteEvent(PerfTrack.Categories.Compiler, "Interpreted loop compiled");

                InterpretedFrame frame = (InterpretedFrame)frameObj;
                var compiler = new LoopCompiler(_loop, frame.Interpreter.LabelMapping, _variables, _closureVariables, _instructionIndex, _loopEnd);
                var instructions = frame.Interpreter.Instructions.Instructions;

                // replace this instruction with an optimized one:
                Interlocked.Exchange(ref instructions[_instructionIndex], new CompiledLoopInstruction(compiler.CreateDelegate()));

                // invalidate this instruction, some threads may still hold on it:
                _loop = null;
                _variables = null;
                _closureVariables = null;
            }
        }
Ejemplo n.º 6
0
 internal EnterLoopInstruction(LoopExpression loop, LocalVariables locals, int compilationThreshold, int instructionIndex) {
     _loop = loop;
     _variables = locals.CopyLocals();
     _closureVariables = locals.ClosureVariables;
     _compilationThreshold = compilationThreshold;
     _instructionIndex = instructionIndex;
 }
Ejemplo n.º 7
0
 public LoopExpressionProxy(LoopExpression node) {
     _node = node;
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Visits the children of the <see cref="LoopExpression"/>.
 /// </summary>
 /// <param name="node">The expression to visit.</param>
 /// <returns>The modified expression, if it or any subexpression was modified;
 /// otherwise, returns the original expression.</returns>
 protected internal virtual Expression VisitLoop(LoopExpression node)
 {
     return(node.Update(VisitLabelTarget(node.BreakLabel), VisitLabelTarget(node.ContinueLabel), Visit(node.Body)));
 }
    public virtual bool IsEvaluatableLoop (LoopExpression node)
    {
      ArgumentUtility.CheckNotNull ("node", node);

      return true;
    }
		}//end static method
		internal XElement LoopExpressionToXElement(LoopExpression e)
		{
			object value;
			string xName = "LoopExpression";
			object[] XElementValues = new object[6];
			value = ((LoopExpression)e).Type;
			XElementValues[0] = GenerateXmlFromProperty(typeof(System.Type),
				"Type", value ?? string.Empty);
			value = ((LoopExpression)e).NodeType;
			XElementValues[1] = GenerateXmlFromProperty(typeof(System.Linq.Expressions.ExpressionType),
				"NodeType", value ?? string.Empty);
			value = ((LoopExpression)e).Body;
			XElementValues[2] = GenerateXmlFromProperty(typeof(System.Linq.Expressions.Expression),
				"Body", value ?? string.Empty);
			value = ((LoopExpression)e).BreakLabel;
			XElementValues[3] = GenerateXmlFromProperty(typeof(System.Linq.Expressions.LabelTarget),
				"BreakLabel", value ?? string.Empty);
			value = ((LoopExpression)e).ContinueLabel;
			XElementValues[4] = GenerateXmlFromProperty(typeof(System.Linq.Expressions.LabelTarget),
				"ContinueLabel", value ?? string.Empty);
			value = ((LoopExpression)e).CanReduce;
			XElementValues[5] = GenerateXmlFromProperty(typeof(System.Boolean),
				"CanReduce", value ?? string.Empty);
			return new XElement(xName, XElementValues);
		}//end static method
Ejemplo n.º 11
0
 public LoopExpressionProxy(LoopExpression node)
 {
     ContractUtils.RequiresNotNull(node, nameof(node));
     _node = node;
 }
Ejemplo n.º 12
0
 public LoopVisitor(LoopExpression node) : base(node)
 {
     this.node = node;
 }
 protected internal override Expression VisitLoop(LoopExpression node)
 {
     Out("loop { ... }");
     return(node);
 }
Ejemplo n.º 14
0
 private Variable VisitLoop(LoopExpression node)
 {
     throw new NotSupportedException("Expression of type " + node.NodeType + " is not supported");
     //this.Out("loop { ... }");
 }
 private void PushLabelInfo(LoopExpression loop)
 {
     _loopLabels.Push(new LoopLabelInfo { Break = loop.BreakLabel, Continue = loop.ContinueLabel });
 }
Ejemplo n.º 16
0
 internal EnterLoopInstruction(LoopExpression loop, int compilationThreshold, int instructionIndex) {
     _loop = loop;
     _compilationThreshold = compilationThreshold;
     _instructionIndex = instructionIndex;
 }
Ejemplo n.º 17
0
 private static string VisitLoop(LoopExpression node)
 {
     throw new NotImplementedException();
 }
 public LoopExpressionProxy(LoopExpression node)
 {
     ContractUtils.RequiresNotNull(node, nameof(node));
     _node = node;
 }