public override Func <T> CreateModifyFunction <T>(object value, CompilerData cdata, Token.Type operation) { Type rtype = CompilerUtility.GetReturnType(value); Operation.BinaryOperationDelegate del = cdata._assembly.GetBinaryOperation(operation, type, rtype); // This section was made for runtime type inference // May cause some weird issues, definitely check this out if there are problems if (del == null && type != typeof(Object) && rtype == typeof(Object)) { del = cdata._assembly.GetBinaryOperation(operation, type, type); } if (del == null && type == typeof(Object) && rtype != typeof(Object)) { del = cdata._assembly.GetBinaryOperation(operation, rtype, rtype); } if (del == null) { throw new CompilationException("Cannot perform the operation " + operation.ToString() + " on " + type.Name + " and " + rtype.Name); } Func <object> accessorFunc = CompilerUtility.ForceGetFunction <object>(_accessor, cdata); object func = del(this, value, cdata); Type returnType = CompilerUtility.GetReturnType(func); TypeDef returnTypeDef = cdata._assembly.GetTypeDef(returnType); if (accessorFunc == null) { return(() => { object ob = returnTypeDef.CallFunction(func); ((IList)(cdata._environment[_environmentIndex].data))[(int)_accessor] = ob; return (T)ob; }); } else { return(() => { object ob = returnTypeDef.CallFunction(func); ((IList)(cdata._environment[_environmentIndex].data))[(int)accessorFunc()] = ob; return (T)ob; }); } }
public override Func <T> CreateModifyFunction <T>(object value, CompilerData cdata, Token.Type operation) { Type rtype = CompilerUtility.GetReturnType(value); Operation.BinaryOperationDelegate del = cdata._assembly.GetBinaryOperation(operation, type, rtype); // This section was made for runtime type inference // May cause some weird issues, definitely check this out if there are problems if (del == null && type != typeof(Object) && rtype == typeof(Object)) { del = cdata._assembly.GetBinaryOperation(operation, type, type); } if (del == null && type == typeof(Object) && rtype != typeof(Object)) { del = cdata._assembly.GetBinaryOperation(operation, rtype, rtype); } if (del == null) { throw new CompilationException("Cannot perform the operation " + operation.ToString() + " on " + type.Name + " and " + rtype.Name); } Func <object> targetFunc = CompilerUtility.ForceGetFunction <object>(_targetObject, cdata); object func = del(this, value, cdata); Type returnType = CompilerUtility.GetReturnType(func); TypeDef returnTypeDef = cdata._assembly.GetTypeDef(returnType); if (targetFunc == null) { return(() => { object ob = returnTypeDef.CallFunction(func); return (T)RunTimeUtility.SetMemberValue(_targetObject, _identifer, cdata, ob); }); } else { return(() => { object ob = returnTypeDef.CallFunction(func); return (T)RunTimeUtility.SetMemberValue(targetFunc(), _identifer, cdata, ob); }); } }