예제 #1
0
        protected EventSourceImplementerBase(ModuleDefinition module, EventSourceTemplate template)
        {
            this.module   = module;
            this.template = template;
            typeDefs      = template.TypeDefs;
            ensureOpcodes = EnsureNestedBuilder("Opcodes");
            ensureTasks   = EnsureNestedBuilder("Tasks");
#if ENABLE_UNSAFE
            unsafeWriteEventBuilder = new UnsafeWriteEventBuilder(module, typeDefs);
#endif
        }
        private CustomAttribute CreateEventSourceAttribute(IEventSourceTypeDefs typeDefs, string name, string guid)
        {
            var ca = module.NewAttr(typeDefs.EventSourceAttribute);

            if (!String.IsNullOrEmpty(name))
                ca.SetPropertyValue("Name", module.TypeSystem.String, name);

            if (!String.IsNullOrEmpty(guid))
                ca.SetPropertyValue("Guid", module.TypeSystem.String, guid);

            return ca;
        }
예제 #3
0
        public EventSourceTemplate(TypeDefinition template, IEventSourceTypeDefs typeDefs)
        {
            this.typeDefs = typeDefs;
            Type          = template;
            TypeDefs      = typeDefs;

            Keywords = GetNamedNestedType(template, "Keywords");
            Tasks    = GetNamedNestedType(template, "Tasks");
            Opcodes  = GetNamedNestedType(template, "Opcodes");

            traces = new Lazy <IReadOnlyList <TraceMethod> >(() => GetTraceMethods().ToArray());
            guards = new Lazy <IReadOnlyList <GuardMethod> >(() => GetGuardMethods().ToArray());
        }
예제 #4
0
        private CustomAttribute CreateEventSourceAttribute(IEventSourceTypeDefs typeDefs, string name, string guid)
        {
            var source = Module.NewAttr(typeDefs.EventSourceAttribute);

            if (!string.IsNullOrEmpty(name))
            {
                source.SetPropertyValue("Name", Module.TypeSystem.String, name);
            }
            if (!string.IsNullOrEmpty(guid))
            {
                source.SetPropertyValue("Guid", Module.TypeSystem.String, guid);
            }

            return(source);
        }
예제 #5
0
        public UnsafeWriteEventBuilder(ModuleDefinition module, IEventSourceTypeDefs typeDefs)
        {
            this.module   = module;
            this.typeDefs = typeDefs;

            var ts = module.TypeSystem;

            emitters = new Dictionary <string, Func <BodyBuilder, VariableDefinition, ParameterDefinition, IEnumerable <Instruction> > >()
            {
                [ts.String.FullName]  = StoreStringInEventData,
                [ts.Int32.FullName]   = StoreInt32InEventData,
                [ts.Boolean.FullName] = StoreBoolInEventData,
            };

            supportedTypes = new HashSet <string>(emitters.Keys);
        }
예제 #6
0
 public StaticTemplate(TypeDefinition type, IEventSourceTypeDefs typeDefs) : base(type, typeDefs)
 {
 }