Esempio n. 1
0
        //todo target should be sync, filter
        //todo test params[]
        //todo is in, out, ref hard to impl
        void WeaveSync(GenericInstanceType joinPointType)
        {
            var parameterGeneric = joinPointType.GenericArguments[0];
            var returnGeneric    = joinPointType.GenericArguments[1];

            var joinPoint = _target.Module.ImportReference(_demonTypes.JoinPoint.MakeGenericInstanceType(parameterGeneric, returnGeneric));

            var lambda = CreateLambda(parameterGeneric, returnGeneric);

            ClearBody();

            var joinPointVariable = new VariableDefinition(joinPoint);

            _target.Body.Variables.Add(joinPointVariable);

            InsertLoadParameters(parameterGeneric);
            InsertLoadReturn(returnGeneric);
            InsertLambdaAndCreateJoinPoint(parameterGeneric, returnGeneric, lambda);
            _emitter.Stloc_0();
            _emitter.Ldarg_0();
            _emitter.Ldfld(_adviceField);
            _emitter.Ldloc_0();
            _emitter.Call(_advice); //todo callvirt if needed
            InsertRetWithReturnValue(parameterGeneric, returnGeneric);
        }
Esempio n. 2
0
        //todo verify if weaving doesn't break short addresses
        public void Weave()
        {
            InsertLoadAspectIfNeeded();
            InsertLoadAdviceParametersIfNeeded();

            _emitter.Call(_advice);
        }