private void WriteMetadataExpression(IMetadataExpression expression) { IMetadataConstant constant = expression as IMetadataConstant; if (constant != null) { WriteMetadataConstant(constant); return; } IMetadataCreateArray array = expression as IMetadataCreateArray; if (array != null) { WriteMetadataArray(array); return; } IMetadataTypeOf type = expression as IMetadataTypeOf; if (type != null) { WriteKeyword("typeof", noSpace: true); WriteSymbol("("); WriteTypeName(type.TypeToGet, noSpace: true); WriteSymbol(")"); return; } throw new NotSupportedException("IMetadataExpression type not supported"); }
public override void Visit(IMetadataExpression expression) { if (Process(expression)) { visitor.Visit(expression); } base.Visit(expression); }
private void ValidateTypeOfExpression(MethodInfo validatedMethod, IExpression expression) { IMethodCallExpression callExpression = expression as IMethodCallExpression; if (callExpression == null) { return; } if (callExpression.Method != typeof(Type).GetMethod("GetTypeFromHandle")) { return; } IMetadataExpression metadataExpression = callExpression.Arguments[0] as IMetadataExpression; if (metadataExpression == null) { return; } Type type = metadataExpression.Declaration as Type; if (type == null) { return; } if (!type.GetCustomAttributes(typeof(FileExtensionAttribute)).Any()) { MessageSource.MessageSink.Write( new Message( MessageLocation.Of(this.userMethod), SeverityType.Error, "MYERR1", String.Format("Calling method {0} on type {1} is not allowed.", validatedMethod, type), null, null, null ) ); } }
public virtual void Visit(IMetadataExpression expression) { this.Visit(expression.Type); expression.Dispatch(this); }
/// <summary> /// Traverses the children of the metadata expression. /// </summary> public virtual void TraverseChildren(IMetadataExpression expression) { this.Traverse(expression.Type); }
public virtual void onMetadataElement(IMetadataExpression expression) { }
public void Visit(IMetadataExpression expression) { Contract.Assume(false); }
/// <summary> /// Traverses the metadata expression. /// </summary> public void Traverse(IMetadataExpression expression) { Contract.Requires(expression != null); expression.Dispatch(this.dispatchingVisitor); }
/// <summary> /// Performs some computation with the given metadata expression. /// </summary> public virtual void Visit(IMetadataExpression expression) { }
/// <summary> /// Rewrites the given metadata expression. /// </summary> public virtual IMetadataExpression Rewrite(IMetadataExpression metadataExpression) { return metadataExpression; }
public override void Visit(IMetadataExpression expression) { allElements.Add(new InvokInfo(Traverser, "IMetadataExpression", expression)); }
// get a constant value or null private object GetConstantValue(IMetadataExpression expression) { var constExp = expression as IMetadataConstant; return constExp != null ? constExp.Value : null; }
public override void Visit(IMetadataExpression expression) { if(Process(expression)){visitor.Visit(expression);} base.Visit(expression); }
// get a constant value or null private object GetConstantValue(IMetadataExpression expression) { var constExp = expression as IMetadataConstant; return(constExp != null ? constExp.Value : null); }
/// <summary> /// Performs some computation with the given metadata expression. /// </summary> /// <param name="expression"></param> public virtual void Visit(IMetadataExpression expression) { // IMetadataExpression is a base interface that should never be implemented directly. // Get expression to call the most type specific visitor. expression.Dispatch(this); }
/// <summary> /// Performs some computation with the given metadata expression. /// </summary> public virtual void Visit(IMetadataExpression expression) { //IMetadataExpression is a base interface that should never be implemented directly. //Get expression to call the most type specific visitor. expression.Dispatch(this); }
public void Expression(IMetadataExpression expression) { IMetadataNamedArgument namedArg = expression as IMetadataNamedArgument; if (namedArg != null) { ITypeDefinitionMember tdm = namedArg.ResolvedDefinition as ITypeDefinitionMember; string tdmStr = Helper.TypeDefinitionMember(this.CurrentModule, tdm); this.ILDasmPaper.DataString(tdmStr); this.ILDasmPaper.Symbol("="); this.Expression(namedArg.ArgumentValue); return; } IMetadataConstant ct = expression as IMetadataConstant; if (ct != null) { this.ILDasmPaper.Keyword("const"); this.ILDasmPaper.Symbol("("); this.ILDasmPaper.Constant(ct.Value); this.ILDasmPaper.Symbol(","); this.TypeReference(ct.Type); this.ILDasmPaper.Symbol(")"); return; } IMetadataTypeOf te = expression as IMetadataTypeOf; if (te != null) { this.ILDasmPaper.Keyword("typeof"); this.ILDasmPaper.Symbol("("); this.TypeDefinitionAsReference(te.TypeToGet); this.ILDasmPaper.Symbol(")"); return; } IMetadataCreateArray arrc = expression as IMetadataCreateArray; if (arrc != null) { this.ILDasmPaper.Keyword("array"); this.ILDasmPaper.Symbol("("); this.TypeReference(arrc.Type); this.ILDasmPaper.Symbol(")"); this.ILDasmPaper.Symbol("{"); bool isFirst = true; foreach (IMetadataExpression e in arrc.Initializers) { if (!isFirst) this.ILDasmPaper.Symbol(", "); this.Expression(e); isFirst = false; } this.ILDasmPaper.Symbol("}"); } }
/// <summary> /// Traverses the children of the metadata expression. /// </summary> public virtual void TraverseChildren(IMetadataExpression expression) { Contract.Requires(expression != null); this.Traverse(expression.Type); }
/// <summary> /// Performs some computation with the given metadata expression. /// </summary> /// <param name="expression"></param> public virtual void Visit(IMetadataExpression expression) { if (this.stopTraversal) return; //^ int oldCount = this.path.Count; this.path.Push(expression); this.Visit(expression.Type); //^ assume this.path.Count == oldCount+1; //True because all of the virtual methods of this class promise not to decrease this.path.Count. this.path.Pop(); expression.Dispatch(this); }
public override void TraverseChildren(IMetadataExpression expression) { MethodEnter(expression); base.TraverseChildren(expression); MethodExit(); }
/// <summary> /// Performs some computation with the given metadata expression. /// </summary> public void Visit(IMetadataExpression expression) { }
public void Visit(IMetadataExpression expression) { throw new NotImplementedException(); }
internal CustomAttribute(PEFileToObjectModel peFileToObjectModel, uint attributeRowId, IMethodReference constructor, IMetadataExpression[]/*?*/ arguments, IMetadataNamedArgument[]/*?*/ namedArguments) : base(peFileToObjectModel) { this.AttributeRowId = attributeRowId; this.Constructor = constructor; this.Arguments = arguments; this.NamedArguments = namedArguments; }
/// <summary> /// Traverses the metadata expression. /// </summary> public void Traverse(IMetadataExpression expression) { expression.Dispatch(this.dispatchingVisitor); }