/// <summary> /// Deep-clone the code object. /// </summary> public override CodeObject Clone() { Initializer clone = (Initializer)base.Clone(); clone._expressions = ChildListHelpers.Clone(_expressions, clone); return(clone); }
/// <summary> /// Deep-clone the code object. /// </summary> public override CodeObject Clone() { MultiEnumMemberDecl clone = (MultiEnumMemberDecl)base.Clone(); clone._enumMemberDecls = ChildListHelpers.Clone(_enumMemberDecls, clone); return(clone); }
/// <summary> /// Deep-clone the code object. /// </summary> public override CodeObject Clone() { Unrecognized clone = (Unrecognized)base.Clone(); clone._expressions = ChildListHelpers.Clone(_expressions, clone); return(clone); }
/// <summary> /// Deep-clone the code object. /// </summary> public override CodeObject Clone() { MultiFieldDecl clone = (MultiFieldDecl)base.Clone(); clone._fieldDecls = ChildListHelpers.Clone(_fieldDecls, clone); return(clone); }
/// <summary> /// Deep-clone the code object. /// </summary> public override CodeObject Clone() { IndexerDecl clone = (IndexerDecl)base.Clone(); clone._parameters = ChildListHelpers.Clone(_parameters, clone); return(clone); }
/// <summary> /// Deep-clone the code object. /// </summary> public override CodeObject Clone() { Attribute clone = (Attribute)base.Clone(); clone._attributeExpressions = ChildListHelpers.Clone(_attributeExpressions, clone); return(clone); }
/// <summary> /// Deep-clone the code object. /// </summary> public override CodeObject Clone() { BaseListTypeDecl clone = (BaseListTypeDecl)base.Clone(); clone._baseTypes = ChildListHelpers.Clone(_baseTypes, clone); return(clone); }
/// <summary> /// Deep-clone the code object. /// </summary> public override CodeObject Clone() { ArgumentsOperator clone = (ArgumentsOperator)base.Clone(); clone._arguments = ChildListHelpers.Clone(_arguments, clone); clone.CloneField(ref clone._expression, _expression); return(clone); }
/// <summary> /// Deep-clone the code object. /// </summary> public override CodeObject Clone() { ConstraintClause clone = (ConstraintClause)base.Clone(); clone.CloneField(ref clone._typeParameter, _typeParameter); clone._constraints = ChildListHelpers.Clone(_constraints, clone); return(clone); }
/// <summary> /// Deep-clone the code object. /// </summary> public override CodeObject Clone() { AnonymousMethod clone = (AnonymousMethod)base.Clone(); clone._parameters = ChildListHelpers.Clone(_parameters, clone); clone.CloneField(ref clone._body, _body); return(clone); }
/// <summary> /// Deep-clone the code object. /// </summary> public override CodeObject Clone() { DelegateDecl clone = (DelegateDecl)base.Clone(); clone.CloneField(ref clone._returnType, _returnType); clone._typeParameters = ChildListHelpers.Clone(_typeParameters, clone); return(clone); }
/// <summary> /// Deep-clone the code object. /// </summary> public override CodeObject Clone() { Try clone = (Try)base.Clone(); clone._catches = ChildListHelpers.Clone(_catches, clone); clone.CloneField(ref clone._finally, _finally); return(clone); }
/// <summary> /// Deep-clone the code object. /// </summary> public override CodeObject Clone() { TypeDecl clone = (TypeDecl)base.Clone(); clone._typeParameters = ChildListHelpers.Clone(_typeParameters, clone); clone._constraintClauses = ChildListHelpers.Clone(_constraintClauses, clone); return(clone); }
/// <summary> /// Deep-clone the code object. /// </summary> public override CodeObject Clone() { MethodDeclBase clone = (MethodDeclBase)base.Clone(); clone.CloneField(ref clone._returnType, _returnType); clone.CloneField(ref clone._name, _name); clone._parameters = ChildListHelpers.Clone(_parameters, clone); return(clone); }
/// <summary> /// Deep-clone the code object. /// </summary> public override CodeObject Clone() { DocComment clone = (DocComment)base.Clone(); if (_content is ChildList <DocComment> ) { clone._content = ChildListHelpers.Clone((ChildList <DocComment>)_content, clone); } else { clone.CloneField(ref clone._content, _content); } return(clone); }
/// <summary> /// Deep-clone the code object. /// </summary> public override CodeObject Clone() { For clone = (For)base.Clone(); if (_initializations is ChildList <Expression> ) { clone._initializations = ChildListHelpers.Clone((ChildList <Expression>)_initializations, clone); } else { clone.CloneField(ref clone._initializations, _initializations); } clone.CloneField(ref clone._conditional, _conditional); clone._iterations = ChildListHelpers.Clone(_iterations, clone); return(clone); }
/// <summary> /// Create (or re-create) the compiler-generated invoke methods and constructor. /// This method should be called whenever the parameters of the delegate are set or changed. /// </summary> public void GenerateMethods() { // Remove any existing methods before generating them - since the Body is compiler-generated just // to hold these methods, we can just re-create it. Body = new Block { IsGenerated = true }; // The Invoke method has the same parameters as the delegate, and the same return type MethodDecl invokeDecl = new MethodDecl("Invoke", (Expression)_returnType.Clone(), Modifiers.Public) { IsGenerated = true }; invokeDecl.Parameters = (_parameters != null ? ChildListHelpers.Clone(_parameters, invokeDecl) : null); Add(invokeDecl); // The BeginInvoke method has the same parameters as the delegate, plus 2 extra ones, and a return type of IAsyncResult MethodDecl beginInvokeDecl = new MethodDecl("BeginInvoke", (TypeRef)TypeRef.IAsyncResultRef.Clone(), Modifiers.Public) { IsGenerated = true }; ChildList <ParameterDecl> parameters = (_parameters != null ? ChildListHelpers.Clone(_parameters, beginInvokeDecl) : new ChildList <ParameterDecl>(beginInvokeDecl)); parameters.Add(new ParameterDecl("callback", (TypeRef)TypeRef.AsyncCallbackRef.Clone())); parameters.Add(new ParameterDecl("object", (TypeRef)TypeRef.ObjectRef.Clone())); beginInvokeDecl.Parameters = parameters; Add(beginInvokeDecl); // The EndInvoke method has any 'ref' or 'out' parameters of the delegate, plus 1 extra one, and the same return type MethodDecl endInvokeDecl = new MethodDecl("EndInvoke", (Expression)_returnType.Clone(), Modifiers.Public) { IsGenerated = true }; parameters = new ChildList <ParameterDecl>(endInvokeDecl); if (_parameters != null) { foreach (ParameterDecl parameterDecl in _parameters) { if (parameterDecl.IsRef || parameterDecl.IsOut) { parameters.Add((ParameterDecl)parameterDecl.Clone()); } } } parameters.Add(new ParameterDecl("result", (TypeRef)TypeRef.IAsyncResultRef.Clone())); endInvokeDecl.Parameters = parameters; Add(endInvokeDecl); // Delegates have a constructor that takes an object and an IntPtr that is used internally by the compiler during // code generation. We have to create a dummy constructor that will allow a MethodRef to be passed to it, in order // to make the C# syntax work when resolving. TypeRef delegateTypeRef = CreateRef(); ConstructorDecl constructor = new ConstructorDecl(new[] { new ParameterDecl(DelegateConstructorParameterName, delegateTypeRef) }) { IsGenerated = true }; Add(constructor); }