/// <summary> /// Whether the result of binary expression should be deeply copied. /// </summary> /// <include file='Doc/Nodes.xml' path='doc/method[@name="IsDeeplyCopied"]/*'/> /// <returns>All operators returns immutable values. Hence, returns <B>false</B>.</returns> internal override bool IsDeeplyCopied(CopyReason reason, int nestingLevel) { switch (operation) { // respective operators returns immutable values: case Operations.Xor: case Operations.Or: case Operations.And: case Operations.BitOr: case Operations.BitXor: case Operations.BitAnd: case Operations.Equal: case Operations.NotEqual: case Operations.Identical: case Operations.NotIdentical: case Operations.LessThan: case Operations.GreaterThan: case Operations.LessThanOrEqual: case Operations.GreaterThanOrEqual: case Operations.ShiftLeft: case Operations.ShiftRight: case Operations.Add: case Operations.Sub: case Operations.Mul: case Operations.Div: case Operations.Mod: case Operations.Concat: return(false); } Debug.Fail("Illegal operation type."); return(true); }
public static object Copy(object obj, CopyReason reason) { // cloneable types: IPhpCloneable php_cloneable; if ((php_cloneable = obj as IPhpCloneable) != null) { return(php_cloneable.Copy(reason)); } // string, bool, int, double, null: return(obj); }
internal static int GetPriority(CopyReason reason, int attempt, ProactiveCopyLocationSource proactiveLocationSource) { Contract.Requires(attempt >= 0); // This prioritization has a few constraints: // - Reason's prioritization is ascending // - Source's prioritization is ascending // - Attempt's prioritization is descending // The resulting priorities are ascending (i.e. if a request has priority 0, it is less important than // another with priority 1). attempt = Math.Min(attempt, MaxAttempt); return ((MaxLocationSource + MaxAttempt) * (int)reason + MaxLocationSource * (MaxAttempt - attempt) + (int)proactiveLocationSource); }
public override bool IsDeeplyCopied(UnaryEx node, CopyReason reason, int nestingLevel) { switch (node.Operation) { // respective operators returns immutable values: case Operations.Plus: case Operations.Minus: case Operations.LogicNegation: case Operations.BitNegation: case Operations.Int8Cast: case Operations.Int16Cast: case Operations.Int32Cast: case Operations.Int64Cast: case Operations.UInt8Cast: case Operations.UInt16Cast: case Operations.UInt32Cast: case Operations.UInt64Cast: case Operations.DecimalCast: case Operations.DoubleCast: case Operations.FloatCast: case Operations.StringCast: case Operations.UnicodeCast: case Operations.BoolCast: case Operations.UnsetCast: case Operations.Clone: case Operations.Print: return(false); // respective operators don't do a deep copy: case Operations.ObjectCast: case Operations.ArrayCast: case Operations.BinaryCast: return(true); // the result depends on what follows @: case Operations.AtSign: return(node.Expr.IsDeeplyCopied(reason, nestingLevel)); default: throw null; } }
/// <summary> /// Whether the result of binary expression should be deeply copied. /// </summary> /// <include file='Doc/Nodes.xml' path='doc/method[@name="IsDeeplyCopied"]/*'/> /// <returns>All operators returns immutable values. Hence, returns <B>false</B>.</returns> internal override bool IsDeeplyCopied(CopyReason reason, int nestingLevel) { switch (operation) { // respective operators returns immutable values: case Operations.Xor: case Operations.Or: case Operations.And: case Operations.BitOr: case Operations.BitXor: case Operations.BitAnd: case Operations.Equal: case Operations.NotEqual: case Operations.Identical: case Operations.NotIdentical: case Operations.LessThan: case Operations.GreaterThan: case Operations.LessThanOrEqual: case Operations.GreaterThanOrEqual: case Operations.ShiftLeft: case Operations.ShiftRight: case Operations.Add: case Operations.Sub: case Operations.Mul: case Operations.Div: case Operations.Mod: case Operations.Concat: return false; } Debug.Fail("Illegal operation type."); return true; }
public override bool IsDeeplyCopied(LambdaFunctionExpr node, CopyReason reason, int nestingLevel) { return(false); }
/// <include file='Doc/Nodes.xml' path='doc/method[@name="IsDeeplyCopied"]/*'/> /// <returns> /// The copy-on-assignment value of the right hand side. /// </returns> internal override bool IsDeeplyCopied(CopyReason reason, int nestingLevel) { return true; // J: once assigned value must be copied again // rvalue.IsDeeplyCopied(reason, nestingLevel + 1); }
/// <include file='Doc/Nodes.xml' path='doc/method[@name="IsDeeplyCopied"]/*'/> internal override bool IsDeeplyCopied(CopyReason reason, int nestingLevel) { // J: PhpVariable.Copy is always emitted in Emit method if needed (access == Read && resultTypeCode is copiable) return false; }
internal override bool IsDeeplyCopied(CopyReason reason, int nestingLevel) { switch (operation) { // respective operators returns immutable values: case Operations.Plus: case Operations.Minus: case Operations.LogicNegation: case Operations.BitNegation: case Operations.Int8Cast: case Operations.Int16Cast: case Operations.Int32Cast: case Operations.Int64Cast: case Operations.UInt8Cast: case Operations.UInt16Cast: case Operations.UInt32Cast: case Operations.UInt64Cast: case Operations.DecimalCast: case Operations.DoubleCast: case Operations.FloatCast: case Operations.StringCast: case Operations.UnicodeCast: case Operations.BoolCast: case Operations.UnsetCast: case Operations.Clone: case Operations.Print: return false; // respective operators don't do a deep copy: case Operations.ObjectCast: case Operations.ArrayCast: case Operations.BinaryCast: return true; // the result depends on what follows @: case Operations.AtSign: return expr.IsDeeplyCopied(reason, nestingLevel); default: throw null; } }
/// <returns>It suffice to make a copy only if assignment nesting level is 1 or above (we are starting from 0).</returns> public override bool IsDeeplyCopied(ArrayEx node, CopyReason reason, int nestingLevel) { return(nestingLevel > 0); }
/// <summary> /// Retrieves a copy of this instance. /// </summary> /// <returns>The copy.</returns> /// <remarks> /// If this <see cref="PhpSmartReference"/> <see cref="IsAliased"/>, this instance is returned without copying. /// That is because (deep) copying stops on references in PHP. If this instance is not <see cref="IsAliased"/>, /// a new <see cref="PhpSmartReference"/> referencing a copy of the current value is returned. /// </remarks> public override object Copy(CopyReason reason) { return(IsAliased ? this : new PhpSmartReference(PhpVariable.Copy(value, reason))); }
/// <include file='Doc/Nodes.xml' path='doc/method[@name="IsDeeplyCopied"]/*'/> /// <param name="node">Instance.</param> /// <returns> /// The copy-on-assignment value of the right hand side. /// </returns> public override bool IsDeeplyCopied(AssignEx node, CopyReason reason, int nestingLevel) { return(true); // J: once assigned value must be copied again // rvalue.IsDeeplyCopied(reason, nestingLevel + 1); }
public virtual bool IsDeeplyCopied(T node, CopyReason reason, int nestingLevel) { return(true); }
bool IExpressionCompiler.IsDeeplyCopied(Expression node, CopyReason reason, int nestingLevel) { return(IsDeeplyCopied((T)node, reason, nestingLevel)); }
public override bool IsDeeplyCopied(ConditionalEx node, CopyReason reason, int nestingLevel) { return ((node.TrueExpr ?? node.CondExpr).IsDeeplyCopied(reason, nestingLevel) || node.FalseExpr.IsDeeplyCopied(reason, nestingLevel)); }
/// <summary>Creates a copy of this instance.</summary> /// <remarks> /// Instances of the PhpResource class are never cloned. /// When assigning a resource to another variable in a script, /// only a shallow copy is performed. /// </remarks> /// <returns>The copy of this instance.</returns> public object Copy(CopyReason reason) { return(this); }
// obsolete: //internal override bool TryEvaluate(out object value) //{ // object o; // if (condExpr.TryEvaluate(out o)) // { // return (Convert.ObjectToBoolean(o)) ? trueExpr.TryEvaluate(out value) : falseExpr.TryEvaluate(out value); // } // else // { // value = null; // return false; // } //} #endregion internal override bool IsDeeplyCopied(CopyReason reason, int nestingLevel) { return (trueExpr ?? condExpr).IsDeeplyCopied(reason, nestingLevel) || falseExpr.IsDeeplyCopied(reason, nestingLevel); }
public object Copy(CopyReason reason) { if (reason == CopyReason.ReturnedByCopy && this.InplaceCopyOnReturn) { this.table.InplaceCopyOnReturn = false; // copiesCount = 0 this.table.Share(); // copiesCount = 1 => underlaying table is shared and its values will be copied lazily if necessary return this; } else { // create lazy copied PhpArray, // preserve MaxIntegerKey if array was not passed as an argument or within assignment expression: return new PhpArray(this, (reason != CopyReason.PassedByCopy && reason != CopyReason.Assigned)); } }
/// <summary>Creates a copy of this instance.</summary> /// <remarks> /// Instances of the PhpResource class are never cloned. /// When assigning a resource to another variable in a script, /// only a shallow copy is performed. /// </remarks> /// <returns>The copy of this instance.</returns> public object Copy(CopyReason reason) { return this; }
/// <summary> /// Retrieves a copy of this instance. /// </summary> /// <returns>This instance.</returns> /// <remarks> /// Actually references are not copied and this instance is returned instead. /// </remarks> public virtual object Copy(CopyReason reason) { return(this); }
// obsolete: //internal override bool TryEvaluate(out object value) //{ // object o; // if (condExpr.TryEvaluate(out o)) // { // return (Convert.ObjectToBoolean(o)) ? trueExpr.TryEvaluate(out value) : falseExpr.TryEvaluate(out value); // } // else // { // value = null; // return false; // } //} #endregion internal override bool IsDeeplyCopied(CopyReason reason, int nestingLevel) { return((trueExpr ?? condExpr).IsDeeplyCopied(reason, nestingLevel) || falseExpr.IsDeeplyCopied(reason, nestingLevel)); }
/// <summary> /// Emits IL instructions that makes a copy of variable placed on the top of evaluation stack. /// </summary> /// <param name="reason">Reason of the copy.</param> /// <param name="expression">The <see cref="PHP.Core.AST.Expression"/> to be copied.</param> /// <remarks> /// The variable's value is expected on the top of evaluation stack. /// Calls <see cref="PHP.Core.PhpVariable.Copy"/> method to process the value copying. /// The result is left on the evaluation stack. /// </remarks> public void EmitVariableCopy(CopyReason reason, Expression expression) { // checks whether to make a deep copy; starts with level of nesting set to 0: if (expression == null || expression.IsDeeplyCopied(reason, 0)) { // First parameter should already be placed on the evaluation stack il.LdcI4((int)reason); il.Emit(OpCodes.Call, Methods.PhpVariable.Copy); } }
public object Copy(CopyReason reason) { return DeepCopy(); }
/// <include file='Doc/Nodes.xml' path='doc/method[@name="IsDeeplyCopied"]/*'/> internal override bool IsDeeplyCopied(CopyReason reason, int nestingLevel) { return(false); }
internal override bool IsDeeplyCopied(CopyReason reason, int nestingLevel) { // always returns a string: return(false); }
/// <summary> /// Determines behavior on assignment. /// </summary> /// <include file='Doc/Nodes.xml' path='doc/method[@name="IsDeeplyCopied"]/*'/> /// <returns>Always <B>false</B>, since constants contain immutable objects only.</returns> internal override bool IsDeeplyCopied(CopyReason reason, int nestingLevel) { return false; }
public async Task <PutResult> TryCopyAndPutAsync( OperationContext operationContext, IDistributedContentCopierHost host, ContentHashWithSizeAndLocations hashInfo, CopyReason reason, Func <(CopyFileResult copyResult, AbsolutePath tempLocation, int attemptCount), Task <PutResult> > handleCopyAsync)
public override bool IsDeeplyCopied(NewEx node, CopyReason reason, int nestingLevel) { return(false); }
public override bool IsDeeplyCopied(ShellEx node, CopyReason reason, int nestingLevel) { // always returns a string: return(false); }
public object Copy(CopyReason reason) { return(DeepCopy()); }
internal override bool IsDeeplyCopied(CopyReason reason, int nestingLevel) { // always returns a string: return false; }
/// <include file='Doc/Nodes.xml' path='doc/method[@name="IsDeeplyCopied"]/*'/> internal virtual bool IsDeeplyCopied(CopyReason reason, int nestingLevel) { return(true); }
public record CopyRequest( IDistributedContentCopierHost Host, ContentHashWithSizeAndLocations HashInfo, CopyReason Reason, Func <(CopyFileResult copyResult, AbsolutePath tempLocation, int attemptCount), Task <PutResult> > HandleCopyAsync,
/// <include file='Doc/Nodes.xml' path='doc/method[@name="IsDeeplyCopied"]/*'/> internal virtual bool IsDeeplyCopied(CopyReason reason, int nestingLevel) { return true; }
public static bool IsDeeplyCopied(this Expression /*!*/ node, CopyReason reason, int nestingLevel) { var nodecompiler = node.ExpressionCompiler(); return(nodecompiler.IsDeeplyCopied(node, reason, nestingLevel)); }