public void GenerateGet(Expression target, MethodBodyGenerator generator, MethodCompileOption option) { if ((option & MethodCompileOption.EmitStartAddress) == MethodCompileOption.EmitStartAddress && property.PropertyType.IsValueType) { var temp = generator.CreateTemporaryVariable(Type); generator.Call(Getter); generator.StoreVariable(temp); generator.LoadAddressOfVariable(temp); return; } generator.Call(Getter); }
public void GenerateGet(Expression target, MethodBodyGenerator generator, MethodCompileOption option) { if ((option & MethodCompileOption.EmitStartAddress) == MethodCompileOption.EmitStartAddress && variable.Type.IsValueType) { generator.LoadAddressOfVariable(variable); } else { generator.LoadVariable(variable); } }
public void GenerateGet(Expression target, MethodBodyGenerator generator, MethodCompileOption option = MethodCompileOption.None) { if (target != null && target.Type.IsValueType) { generator.Box(target.Type); } generator.LoadString(Name); generator.Call(typeof(IDynamicInvocable).GetInstanceMethod(nameof(IDynamicInvocable.SafeGetValue), typeof(string))); // since it is a value type load the address if ((option & MethodCompileOption.EmitStartAddress) == MethodCompileOption.EmitStartAddress) { var temp = generator.DeclareVariable(TypeProvider.AnyType); generator.StoreVariable(temp); generator.LoadAddressOfVariable(temp); } }
public override void GenerateCode(MethodBodyGenerator generator, MethodCompileOption option) { if (Method.IsAbstract && Method.DeclaringType == typeof(IDynamicInvocable)) { Target.GenerateCode(generator); if (Target.Type.IsValueType) { generator.Box(Target.Type); } } else { Target.GenerateCode(generator, MethodCompileOption.EmitStartAddress); } if (Target.NodeType == ExpressionType.MemberAccess) { MemberExpression target = (MemberExpression)Target; if (target.Target.Type.IsValueType) { switch (target.Target.NodeType) { case ExpressionType.Indexer: case ExpressionType.MemberAccess: var temp = generator.DeclareVariable(target.Target.Type); generator.StoreVariable(temp); generator.LoadAddressOfVariable(temp); break; } } } else if (Target.NodeType == ExpressionType.Identifier) { // if it an identifier expression this might be local member call var exp = (NameExpression)Target; if (exp.Binder == null && Method.IsStatic == false) { generator.LoadArgument(0); } } generator.EmitArguments(Arguments, Conversions); generator.Call(Method); // if current value must not be returned for assigment if ((option & MethodCompileOption.Return) == 0 && Type is object && Type != TypeProvider.VoidType) { generator.Pop(); } }
public override void GenerateCode(MethodBodyGenerator generator, MethodCompileOption options) { if (generator.Method is Generators.DynamicMethodGenerator) { // for annonymous type // if this is used in anonymous function or objects var variable = generator.GetLocalVariable("__value"); if (variable.Type.IsValueType && (options & MethodCompileOption.EmitStartAddress) == MethodCompileOption.EmitStartAddress) { generator.LoadAddressOfVariable(variable); } else { generator.LoadVariable(variable); } } else { generator.LoadArgument(0); } }