public ClassOrStructDef(ClassOrStructDef parent, string name, MemberName baseClass, MemberName[] inherits, Modifier modifiers) : base(parent, name, baseClass, inherits, modifiers) { parent.AddNestedType(this); }
private static bool IsMethodHandleInvokeBasic(MemberName member) { return member.getDeclaringClass() == CoreClasses.java.lang.invoke.MethodHandle.Wrapper.ClassObject && member.getName() == "invokeBasic"; }
public MemberName(MemberName left, Separators separator, string name) : this(name) { Left = left; Separator = separator; }
/** * Generate customized bytecode for a given LambdaForm. */ public static MemberName generateCustomizedCode(LambdaForm form, MethodType invokerType) { try { MemberName memberName = new MemberName(); memberName._clazz(AnonymousClass.Instance); memberName._name(form.debugName); memberName._type(invokerType); memberName._flags(MethodHandleNatives.Constants.MN_IS_METHOD | MethodHandleNatives.Constants.ACC_STATIC | (MethodHandleNatives.Constants.REF_invokeStatic << MethodHandleNatives.Constants.MN_REFERENCE_KIND_SHIFT)); memberName.vmtarget = new NativeInvokerBytecodeGenerator(form, invokerType).generateCustomizedCodeBytes(); return memberName; } #if DEBUG catch (BailoutException x) { Console.WriteLine(x.Message); Console.WriteLine("generateCustomizedCode: " + form + ", " + invokerType); } #else catch (BailoutException) { } #endif return InvokerBytecodeGenerator.generateCustomizedCode(form, invokerType); }
/** * Emit an invoke for the given name, using the MemberName directly. */ void emitStaticInvoke(MemberName member, Name name) { // push arguments emitPushArguments(name); // invocation if (member.isMethod()) { if (IsMethodHandleLinkTo(member)) { MethodType mt = member.getMethodType(); TypeWrapper[] args = new TypeWrapper[mt.parameterCount()]; for (int j = 0; j < args.Length; j++) { args[j] = TypeWrapper.FromClass(mt.parameterType(j)); args[j].Finish(); } TypeWrapper ret = TypeWrapper.FromClass(mt.returnType()); ret.Finish(); Compiler.MethodHandleMethodWrapper.EmitLinkToCall(ilgen, args, ret); ret.EmitConvSignatureTypeToStackType(ilgen); } else if (IsMethodHandleInvokeBasic(member)) { EmitInvokeBasic(member.getMethodType()); } else { switch (member.getReferenceKind()) { case MethodHandleNatives.Constants.REF_invokeInterface: case MethodHandleNatives.Constants.REF_invokeSpecial: case MethodHandleNatives.Constants.REF_invokeStatic: case MethodHandleNatives.Constants.REF_invokeVirtual: break; default: throw new BailoutException(Bailout.UnsupportedRefKind, member); } MethodWrapper mw = GetMethodWrapper(member); if (!IsStaticallyInvocable(mw)) { throw new BailoutException(Bailout.NotStaticallyInvocable, member); } mw.Link(); mw.DeclaringType.Finish(); mw.ResolveMethod(); if (mw.HasCallerID) { EmitConstant(DynamicCallerIDProvider.Instance); ilgen.Emit(OpCodes.Call, ByteCodeHelperMethods.DynamicCallerID); } if (mw.IsStatic || member.getReferenceKind() == MethodHandleNatives.Constants.REF_invokeSpecial) { mw.EmitCall(ilgen); } else { mw.EmitCallvirt(ilgen); } mw.ReturnType.EmitConvSignatureTypeToStackType(ilgen); } } else if (member.isField()) { FieldWrapper fw = GetFieldWrapper(member); if (!IsStaticallyInvocable(fw)) { throw new BailoutException(Bailout.NotStaticallyInvocable, member); } fw.Link(); fw.DeclaringType.Finish(); fw.ResolveField(); switch (member.getReferenceKind()) { case MethodHandleNatives.Constants.REF_getField: case MethodHandleNatives.Constants.REF_getStatic: fw.EmitGet(ilgen); fw.FieldTypeWrapper.EmitConvSignatureTypeToStackType(ilgen); break; case MethodHandleNatives.Constants.REF_putField: case MethodHandleNatives.Constants.REF_putStatic: fw.EmitSet(ilgen); break; default: throw new BailoutException(Bailout.UnsupportedRefKind, member); } } else { throw new BailoutException(Bailout.NotStaticallyInvocable, member); } }
public DocumentationMember(XmlNode memberNode, IDocumentationService documentationService) { _memberNode = memberNode; var nameAttribute = _memberNode.Attributes["name"]; if (nameAttribute == null) { throw new InvalidOperationException("The member doesn't have a name attribute"); } switch (nameAttribute.Value.Substring(0, 2)) { case "T:": Type = DocumentationMemberType.Type; break; case "M:": Type = DocumentationMemberType.Member; break; case "P:": Type = DocumentationMemberType.Property; break; case "E:": Type = DocumentationMemberType.Event; break; case "F:": Type = DocumentationMemberType.Field; break; default: throw new InvalidOperationException("Unknown member type " + nameAttribute.Value.Substring(0, 2)); } FullMemberName = nameAttribute.Value.Substring(2); var memberNameMatch = Regex.Match(FullMemberName, @"\.[\w\`\+\#\@]+(.#ctor)?(\([\w\.\,\`\+\{\}\[\]\#\@]*\))?$").Value; if (string.IsNullOrEmpty(memberNameMatch)) { throw new Exception("Couldn't get member name"); } MemberName = memberNameMatch.Substring(1); if (MemberName.IndexOf(".#ctor", StringComparison.Ordinal) > 0) { MemberName = MemberName.Substring(0, MemberName.IndexOf(".#ctor", StringComparison.Ordinal)); } if (MemberName.IndexOf("(", StringComparison.Ordinal) > 0) { MemberName = MemberName.Substring(0, MemberName.IndexOf("(", StringComparison.Ordinal)); } IsConstructor = FullMemberName.Contains(".#ctor"); ParameterTypes = new List <string>(); if (Type == DocumentationMemberType.Member) { var parameterTypesMatch = Regex.Match(FullMemberName, @"\([\w\.\,]*\)$"); if (parameterTypesMatch.Success) { var parameterTypesRaw = parameterTypesMatch.Value.Substring(1); parameterTypesRaw = parameterTypesRaw.Substring(0, parameterTypesRaw.Length - 1); foreach (var parameterType in parameterTypesRaw.Split(Convert.ToChar(","))) { ParameterTypes.Add(parameterType); } } } MemberInfos = new List <DocumentationMemberInfo>(); MemberInfos.AddRange(documentationService.GetInfosForMember(memberNode)); MemberSummary = MemberInfos.OfType <DocumentationMemberSummary>().FirstOrDefault(); MemberReturns = MemberInfos.OfType <DocumentationMemberReturns>().FirstOrDefault(); MemberValue = MemberInfos.OfType <DocumentationMemberValue>().FirstOrDefault(); MemberParameters = MemberInfos.OfType <DocumentationMemberParameter>().ToList(); foreach (var memberParameter in MemberParameters) { var memberParameterIndex = MemberParameters.IndexOf(memberParameter); if ((ParameterTypes.Count - 1) >= memberParameterIndex) { memberParameter.ParameterType = memberParameter.CleanText(ParameterTypes[memberParameterIndex]); } } }
public bool Equals(ValueMemberValue other) => (MemberName.Equals(other.MemberName) && (ValueType?.Equals(other.ValueType) ?? false)) ? Object.Equals(this.Value, other.Value) : false;
public TypedValue Invoke(TypedValue instance, MemberName memberName, Tree <Cell> parameters) { var procedure = Processor.Get <Procedures>().GetValue(memberName.Name); return(Invoke((Tree <Cell>)procedure, instance, parameters)); }
public static void init(MemberName self, object refObj) { init(self, refObj, false); }
public TypedValue Invoke(TypedValue instance, MemberName memberName, Tree <Cell> parameters) { return(TypedValue.MakeInvalid(new MemberMissingException(instance.Type, memberName.Name, 1))); }
public bool CanInvoke(TypedValue instance, MemberName memberName, Tree <Cell> parameters) { return(Processor.Get <Procedures>().HasValue(memberName.Name)); }
public bool CanInvoke(TypedValue instance, MemberName memberName, Tree <Cell> parameters) { return(memberName.IsSpecialAction); }
public bool CanInvokeSpecial(TypedValue instance, MemberName memberName, Tree <Cell> parameters) { return(true); }
protected RootNamespace(Namespace parent, MemberName name) : base(parent, name) { }
public ImportDirective(MemberName ns) { Namespace = ns; }
private static void SetModifiers(MemberName self, MemberWrapper mw) { self._flags(self._flags() | (int)mw.Modifiers); }
public ClassDef(Namespace ns, string name, MemberName baseClass, MemberName[] inherits, Modifier modifiers) : base(ns, name, baseClass, inherits, modifiers) { }
public static void expand(MemberName self) { throw new NotImplementedException(); }
public TypedValue Invoke(TypedValue instance, MemberName memberName, Tree <Cell> parameters) { return(Processor.ParseTree(literals[memberName.OriginalName.Trim()], parameters.Branches[0])); }
private static void ResolveMethod(MemberName self, JlClass caller) { bool invokeSpecial = self.getReferenceKind() == MethodHandleNatives.Constants.REF_invokeSpecial; bool newInvokeSpecial = self.getReferenceKind() == MethodHandleNatives.Constants.REF_newInvokeSpecial; bool searchBaseClasses = !newInvokeSpecial; MethodWrapper mw = TypeWrapper.FromClass(self.getDeclaringClass()).GetMethodWrapper(self.getName(), self.getSignature().Replace('/', '.'), searchBaseClasses); if (mw == null) { if (self.getReferenceKind() == MethodHandleNatives.Constants.REF_invokeInterface) { mw = TypeWrapper.FromClass(self.getDeclaringClass()).GetInterfaceMethod(self.getName(), self.getSignature().Replace('/', '.')); if (mw == null) { mw = CoreClasses.java.lang.Object.Wrapper.GetMethodWrapper(self.getName(), self.getSignature().Replace('/', '.'), false); } if (mw != null && mw.IsConstructor) { throw new java.lang.IncompatibleClassChangeError("Found interface " + self.getDeclaringClass().getName() + ", but class was expected"); } } if (mw == null) { string msg = String.Format(invokeSpecial ? "{0}: method {1}{2} not found" : "{0}.{1}{2}", self.getDeclaringClass().getName(), self.getName(), self.getSignature()); throw new java.lang.NoSuchMethodError(msg); } } if (mw.IsStatic != IsReferenceKindStatic(self.getReferenceKind())) { string msg = String.Format(mw.IsStatic ? "Expecting non-static method {0}.{1}{2}" : "Expected static method {0}.{1}{2}", mw.DeclaringType.Name, self.getName(), self.getSignature()); throw new java.lang.IncompatibleClassChangeError(msg); } if (self.getReferenceKind() == MethodHandleNatives.Constants.REF_invokeVirtual && mw.DeclaringType.IsInterface) { throw new java.lang.IncompatibleClassChangeError("Found interface " + mw.DeclaringType.Name + ", but class was expected"); } if (!mw.IsPublic && self.getReferenceKind() == MethodHandleNatives.Constants.REF_invokeInterface) { throw new java.lang.IncompatibleClassChangeError("private interface method requires invokespecial, not invokeinterface: method " + self.getDeclaringClass().getName() + "." + self.getName() + self.getSignature()); } if (mw.IsConstructor && mw.DeclaringType == CoreClasses.java.lang.String.Wrapper) { self.vmtarget = CreateMemberNameDelegate(mw, caller, false, self.getMethodType().changeReturnType(CoreClasses.java.lang.String.Wrapper.ClassObject)); } else if (!mw.IsConstructor || invokeSpecial || newInvokeSpecial) { MethodType methodType = self.getMethodType(); if (!mw.IsStatic) { methodType = methodType.insertParameterTypes(0, mw.DeclaringType.ClassObject); if (newInvokeSpecial) { methodType = methodType.changeReturnType(java.lang.Void.TYPE); } } self.vmtarget = CreateMemberNameDelegate(mw, caller, self.hasReceiverTypeDispatch(), methodType); } SetModifiers(self, mw); self._flags(self._flags() | (mw.IsConstructor ? MethodHandleNatives.Constants.MN_IS_CONSTRUCTOR : MethodHandleNatives.Constants.MN_IS_METHOD)); if (self.getReferenceKind() == MethodHandleNatives.Constants.REF_invokeVirtual && (mw.IsPrivate || mw.IsFinal || mw.IsConstructor)) { int flags = self._flags(); flags -= MethodHandleNatives.Constants.REF_invokeVirtual << MethodHandleNatives.Constants.MN_REFERENCE_KIND_SHIFT; flags += MethodHandleNatives.Constants.REF_invokeSpecial << MethodHandleNatives.Constants.MN_REFERENCE_KIND_SHIFT; self._flags(flags); } if (mw.HasCallerID || DynamicTypeWrapper.RequiresDynamicReflectionCallerClass(mw.DeclaringType.Name, mw.Name, mw.Signature)) { self._flags(self._flags() | MemberName.CALLER_SENSITIVE); } }
public bool CanInvoke(TypedValue instance, MemberName memberName, Tree <string> parameters) { return(true); }
public static long staticFieldOffset(MemberName self) { return(objectFieldOffset(self)); }
static bool isStaticallyInvocable(MemberName member) { if (member == null) return false; if (member.isConstructor()) return false; Class cls = member.getDeclaringClass(); if (cls.isArray() || cls.isPrimitive()) return false; // FIXME /* if (cls.isAnonymousClass() || cls.isLocalClass()) return false; // inner class of some sort if (cls.getClassLoader() != MethodHandle.class.getClassLoader()) return false; // not on BCP if (ReflectUtil.isVMAnonymousClass(cls)) // FIXME: switch to supported API once it is added return false; MethodType mtype = member.getMethodOrFieldType(); if (!isStaticallyNameable(mtype.returnType())) return false; for (Class<?> ptype : mtype.parameterArray()) if (!isStaticallyNameable(ptype)) return false; if (!member.isPrivate() && VerifyAccess.isSamePackage(MethodHandle.class, cls)) return true; // in java.lang.invoke package if (member.isPublic() && isStaticallyNameable(cls)) return true; */ if (member.isMethod()) { // [IKVM] If we can't call the method directly, invoke it via the invokeBasic infrastructure. return IsMethodHandleLinkTo(member) || IsMethodHandleInvokeBasic(member) || IsStaticallyInvocable(GetMethodWrapper(member)); } if (member.isField()) { // [IKVM] If we can't access the field directly, use the invokeBasic infrastructure. return IsStaticallyInvocable(GetFieldWrapper(member)); } return false; }
public static object staticFieldBase(MemberName self) { return(null); }
private static bool IsMethodHandleLinkTo(MemberName member) { return member.getDeclaringClass() == CoreClasses.java.lang.invoke.MethodHandle.Wrapper.ClassObject && member.getName().StartsWith("linkTo", StringComparison.Ordinal); }
public override string ToAsciiDoc() { var builder = new StringBuilder(); if (!string.IsNullOrEmpty(Title)) { builder.AppendLine("." + Title); } builder.AppendLine(!string.IsNullOrEmpty(MemberName) ? $"[source, {Language.ToLowerInvariant()}, method=\"{MemberName.ToLowerInvariant()}\"]" : $"[source, {Language.ToLowerInvariant()}]"); builder.AppendLine("----"); var(code, callOuts) = BlockCallOutHelper.ExtractCallOutsFromCode(Value); builder.AppendLine(code); builder.AppendLine("----"); foreach (var callOut in callOuts) { builder.AppendLine(callOut); } return(builder.ToString()); }
private static MethodWrapper GetMethodWrapper(MemberName member) { return TypeWrapper.FromClass(member.getDeclaringClass()).GetMethodWrapper(member.getName(), member.getSignature().Replace('/', '.'), true); }
public bool CanInvoke(TypedValue instance, MemberName memberName, Tree <T> parameters) { var parameterCount = parameters.Branches.Count; return(instance.Type == typeof(DataRow) && (parameterCount == 0)); }
public SubroutineDef(ClassStructOrModuleDef parent, string name, ParameterList param, Modifier modifiers, MemberName _event) : this(parent, name, param, modifiers) { Event = _event; }
/// <summary> /// Creates descriptor instance. /// </summary> /// <param name="mappingSchema">Mapping schema, associated with descriptor.</param> /// <param name="columnAttribute">Column attribute, from which descriptor data should be extracted.</param> /// <param name="memberAccessor">Column mapping member accessor.</param> public ColumnDescriptor(MappingSchema mappingSchema, ColumnAttribute columnAttribute, MemberAccessor memberAccessor) { MemberAccessor = memberAccessor; MemberInfo = memberAccessor.MemberInfo; if (MemberInfo.IsFieldEx()) { var fieldInfo = (FieldInfo)MemberInfo; MemberType = fieldInfo.FieldType; } else if (MemberInfo.IsPropertyEx()) { var propertyInfo = (PropertyInfo)MemberInfo; MemberType = propertyInfo.PropertyType; } MemberName = columnAttribute.MemberName ?? MemberInfo.Name; ColumnName = columnAttribute.Name ?? MemberInfo.Name; Storage = columnAttribute.Storage; PrimaryKeyOrder = columnAttribute.PrimaryKeyOrder; IsDiscriminator = columnAttribute.IsDiscriminator; DataType = columnAttribute.DataType; DbType = columnAttribute.DbType; CreateFormat = columnAttribute.CreateFormat; if (columnAttribute.HasLength()) { Length = columnAttribute.Length; } if (columnAttribute.HasPrecision()) { Precision = columnAttribute.Precision; } if (columnAttribute.HasScale()) { Scale = columnAttribute.Scale; } if (Storage == null) { StorageType = MemberType; StorageInfo = MemberInfo; } else { var expr = Expression.PropertyOrField(Expression.Constant(null, MemberInfo.DeclaringType), Storage); StorageType = expr.Type; StorageInfo = expr.Member; } var defaultCanBeNull = false; if (columnAttribute.HasCanBeNull()) { CanBeNull = columnAttribute.CanBeNull; } else { var na = mappingSchema.GetAttribute <NullableAttribute>(MemberAccessor.TypeAccessor.Type, MemberInfo, attr => attr.Configuration); if (na != null) { CanBeNull = na.CanBeNull; } else { CanBeNull = mappingSchema.GetCanBeNull(MemberType); defaultCanBeNull = true; } } if (columnAttribute.HasIsIdentity()) { IsIdentity = columnAttribute.IsIdentity; } else if (MemberName.IndexOf(".") < 0) { var a = mappingSchema.GetAttribute <IdentityAttribute>(MemberAccessor.TypeAccessor.Type, MemberInfo, attr => attr.Configuration); if (a != null) { IsIdentity = true; } } SequenceName = mappingSchema.GetAttribute <SequenceNameAttribute>(memberAccessor.TypeAccessor.Type, MemberInfo, attr => attr.Configuration); if (SequenceName != null) { IsIdentity = true; } SkipOnInsert = columnAttribute.HasSkipOnInsert() ? columnAttribute.SkipOnInsert : IsIdentity; SkipOnUpdate = columnAttribute.HasSkipOnUpdate() ? columnAttribute.SkipOnUpdate : IsIdentity; if (defaultCanBeNull && IsIdentity) { CanBeNull = false; } if (columnAttribute.HasIsPrimaryKey()) { IsPrimaryKey = columnAttribute.IsPrimaryKey; } else if (MemberName.IndexOf(".") < 0) { var a = mappingSchema.GetAttribute <PrimaryKeyAttribute>(MemberAccessor.TypeAccessor.Type, MemberInfo, attr => attr.Configuration); if (a != null) { IsPrimaryKey = true; PrimaryKeyOrder = a.Order; } } if (DbType == null || DataType == DataType.Undefined) { var a = mappingSchema.GetAttribute <DataTypeAttribute>(MemberAccessor.TypeAccessor.Type, MemberInfo, attr => attr.Configuration); if (a != null) { if (DbType == null) { DbType = a.DbType; } if (DataType == DataType.Undefined && a.DataType.HasValue) { DataType = a.DataType.Value; } } } }
public VariableMemberDeclaration (MemberName mn, object initializer) { MemberName = mn; if (initializer is ArrayList) { this.expression_or_array_initializer = new ArrayCreation (CSharpParser.current_array_type, "", (ArrayList)initializer, mn.Location); } else { this.expression_or_array_initializer = (Expression)initializer; } }
/// <summary> /// Creates descriptor instance. /// </summary> /// <param name="mappingSchema">Mapping schema, associated with descriptor.</param> /// <param name="columnAttribute">Column attribute, from which descriptor data should be extracted.</param> /// <param name="memberAccessor">Column mapping member accessor.</param> public ColumnDescriptor(MappingSchema mappingSchema, ColumnAttribute?columnAttribute, MemberAccessor memberAccessor) { MappingSchema = mappingSchema; MemberAccessor = memberAccessor; MemberInfo = memberAccessor.MemberInfo; if (MemberInfo.IsFieldEx()) { var fieldInfo = (FieldInfo)MemberInfo; MemberType = fieldInfo.FieldType; } else if (MemberInfo.IsPropertyEx()) { var propertyInfo = (PropertyInfo)MemberInfo; MemberType = propertyInfo.PropertyType; } var dataType = mappingSchema.GetDataType(MemberType); if (dataType.Type.DataType == DataType.Undefined) { dataType = mappingSchema.GetUnderlyingDataType(dataType.SystemType, out var _); } if (columnAttribute == null) { columnAttribute = new ColumnAttribute(); columnAttribute.DataType = dataType.Type.DataType; columnAttribute.DbType = dataType.Type.DbType; if (dataType.Type.Length != null) { columnAttribute.Length = dataType.Type.Length.Value; } if (dataType.Type.Precision != null) { columnAttribute.Precision = dataType.Type.Precision.Value; } if (dataType.Type.Scale != null) { columnAttribute.Scale = dataType.Type.Scale.Value; } } else if (columnAttribute.DataType == DataType.Undefined || columnAttribute.DataType == dataType.Type.DataType) { if (dataType.Type.Length != null && !columnAttribute.HasLength()) { columnAttribute.Length = dataType.Type.Length.Value; } if (dataType.Type.Precision != null && !columnAttribute.HasPrecision()) { columnAttribute.Precision = dataType.Type.Precision.Value; } if (dataType.Type.Scale != null && !columnAttribute.HasScale()) { columnAttribute.Scale = dataType.Type.Scale.Value; } } MemberName = columnAttribute.MemberName ?? MemberInfo.Name; ColumnName = columnAttribute.Name ?? MemberInfo.Name; Storage = columnAttribute.Storage; PrimaryKeyOrder = columnAttribute.PrimaryKeyOrder; IsDiscriminator = columnAttribute.IsDiscriminator; DataType = columnAttribute.DataType; DbType = columnAttribute.DbType; CreateFormat = columnAttribute.CreateFormat; if (columnAttribute.HasLength()) { Length = columnAttribute.Length; } if (columnAttribute.HasPrecision()) { Precision = columnAttribute.Precision; } if (columnAttribute.HasScale()) { Scale = columnAttribute.Scale; } if (columnAttribute.HasOrder()) { Order = columnAttribute.Order; } if (Storage == null) { StorageType = MemberType; StorageInfo = MemberInfo; } else { var expr = ExpressionHelper.PropertyOrField(Expression.Constant(null, MemberInfo.DeclaringType), Storage); StorageType = expr.Type; StorageInfo = expr.Member; } var defaultCanBeNull = false; if (columnAttribute.HasCanBeNull()) { CanBeNull = columnAttribute.CanBeNull; } else { var na = mappingSchema.GetAttribute <NullableAttribute>(MemberAccessor.TypeAccessor.Type, MemberInfo, attr => attr.Configuration); if (na != null) { CanBeNull = na.CanBeNull; } else { CanBeNull = mappingSchema.GetCanBeNull(MemberType); defaultCanBeNull = true; } } if (columnAttribute.HasIsIdentity()) { IsIdentity = columnAttribute.IsIdentity; } else if (MemberName.IndexOf(".") < 0) { var a = mappingSchema.GetAttribute <IdentityAttribute>(MemberAccessor.TypeAccessor.Type, MemberInfo, attr => attr.Configuration); if (a != null) { IsIdentity = true; } } SequenceName = mappingSchema.GetAttribute <SequenceNameAttribute>(memberAccessor.TypeAccessor.Type, MemberInfo, attr => attr.Configuration); if (SequenceName != null) { IsIdentity = true; } SkipOnInsert = columnAttribute.HasSkipOnInsert() ? columnAttribute.SkipOnInsert : IsIdentity; SkipOnUpdate = columnAttribute.HasSkipOnUpdate() ? columnAttribute.SkipOnUpdate : IsIdentity; if (defaultCanBeNull && IsIdentity) { CanBeNull = false; } if (columnAttribute.HasIsPrimaryKey()) { IsPrimaryKey = columnAttribute.IsPrimaryKey; } else if (MemberName.IndexOf(".") < 0) { var a = mappingSchema.GetAttribute <PrimaryKeyAttribute>(MemberAccessor.TypeAccessor.Type, MemberInfo, attr => attr.Configuration); if (a != null) { IsPrimaryKey = true; PrimaryKeyOrder = a.Order; } } if (DbType == null || DataType == DataType.Undefined) { var a = mappingSchema.GetAttribute <DataTypeAttribute>(MemberAccessor.TypeAccessor.Type, MemberInfo, attr => attr.Configuration); if (a != null) { if (DbType == null) { DbType = a.DbType; } if (DataType == DataType.Undefined && a.DataType.HasValue) { DataType = a.DataType.Value; } } } if (MemberType.ToNullableUnderlying().IsEnum) { if (DataType == DataType.Undefined) { var enumtype = mappingSchema.GetDefaultFromEnumType(MemberType); if (enumtype != null) { DataType = mappingSchema.GetDataType(enumtype).Type.DataType; } } if (DataType == DataType.Undefined && MemberType.IsNullable()) { var enumtype = mappingSchema.GetDefaultFromEnumType(MemberType.ToNullableUnderlying()); if (enumtype != null) { DataType = mappingSchema.GetDataType(enumtype).Type.DataType; } } if (DataType == DataType.Undefined) { var enumtype = mappingSchema.GetDefaultFromEnumType(typeof(Enum)); if (enumtype != null) { DataType = mappingSchema.GetDataType(enumtype).Type.DataType; } } if (DataType == DataType.Undefined) { DataType = mappingSchema.GetUnderlyingDataType(MemberType, out var canBeNull).Type.DataType; if (canBeNull) { CanBeNull = canBeNull; } } } if (DataType == DataType.Undefined) { DataType = mappingSchema.GetDataType(MemberType).Type.DataType; } var skipValueAttributes = mappingSchema.GetAttributes <SkipBaseAttribute>(MemberAccessor.TypeAccessor.Type, MemberInfo, attr => attr.Configuration); if (skipValueAttributes.Length > 0) { SkipBaseAttributes = skipValueAttributes; SkipModificationFlags = SkipBaseAttributes.Aggregate(SkipModification.None, (s, c) => s | c.Affects); } var vc = mappingSchema.GetAttribute <ValueConverterAttribute>(memberAccessor.TypeAccessor.Type, MemberInfo, attr => attr.Configuration); if (vc != null) { ValueConverter = vc.GetValueConverter(this); } }
public VariableMemberDeclaration (MemberName mn, Expression initializer) { MemberName = mn; this.initializer = initializer; }
public bool CanInvoke(TypedValue instance, MemberName memberName, Tree <Cell> parameters) { return(parameters.Branches.Count == 1 && literals.ContainsKey(memberName.OriginalName.Trim())); }
public ClassDef(ClassOrStructDef parent, string name, MemberName baseClass, MemberName[] inherits, Modifier modifiers) : base(parent, name, baseClass, inherits, modifiers) { }
public static object createDelegate(MethodType type, MemberName m, bool doDispatch, jlClass lookupClass) { #if FIRST_PASS return(null); #else int index = m.getVMIndex(); if (index == Int32.MaxValue) { bool invokeExact = m.getName() == "invokeExact"; Type targetDelegateType = MethodHandleUtil.CreateDelegateType(invokeExact ? type.dropParameterTypes(0, 1) : type); MethodHandleUtil.DynamicMethodBuilder dm = new MethodHandleUtil.DynamicMethodBuilder("DirectMethodHandle." + m.getName(), type, typeof(IKVM.Runtime.InvokeCache <>).MakeGenericType(targetDelegateType)); dm.Ldarg(0); if (invokeExact) { dm.Call(ByteCodeHelperMethods.GetDelegateForInvokeExact.MakeGenericMethod(targetDelegateType)); } else { dm.LoadValueAddress(); dm.Call(ByteCodeHelperMethods.GetDelegateForInvoke.MakeGenericMethod(targetDelegateType)); dm.Ldarg(0); } for (int i = 1, count = type.parameterCount(); i < count; i++) { dm.Ldarg(i); } dm.CallDelegate(targetDelegateType); dm.Ret(); return(dm.CreateDelegate()); } else { TypeWrapper tw = (TypeWrapper)typeof(MemberName).GetField("vmtarget", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(m); tw.Finish(); MethodWrapper mw = tw.GetMethods()[index]; if (mw.IsDynamicOnly) { MethodHandleUtil.DynamicMethodBuilder dm = new MethodHandleUtil.DynamicMethodBuilder("CustomInvoke:" + mw.Name, type, mw); if (mw.IsStatic) { dm.LoadNull(); dm.BoxArgs(0); } else { dm.Ldarg(0); dm.BoxArgs(1); } dm.Callvirt(typeof(MethodWrapper).GetMethod("Invoke", BindingFlags.Instance | BindingFlags.NonPublic)); dm.UnboxReturnValue(); dm.Ret(); return(dm.CreateDelegate()); } // HACK this code is duplicated in compiler.cs if (mw.IsProtected && (mw.DeclaringType == CoreClasses.java.lang.Object.Wrapper || mw.DeclaringType == CoreClasses.java.lang.Throwable.Wrapper)) { TypeWrapper thisType = TypeWrapper.FromClass(lookupClass); TypeWrapper cli_System_Object = ClassLoaderWrapper.LoadClassCritical("cli.System.Object"); TypeWrapper cli_System_Exception = ClassLoaderWrapper.LoadClassCritical("cli.System.Exception"); // HACK we may need to redirect finalize or clone from java.lang.Object/Throwable // to a more specific base type. if (thisType.IsAssignableTo(cli_System_Object)) { mw = cli_System_Object.GetMethodWrapper(mw.Name, mw.Signature, true); } else if (thisType.IsAssignableTo(cli_System_Exception)) { mw = cli_System_Exception.GetMethodWrapper(mw.Name, mw.Signature, true); } else if (thisType.IsAssignableTo(CoreClasses.java.lang.Throwable.Wrapper)) { mw = CoreClasses.java.lang.Throwable.Wrapper.GetMethodWrapper(mw.Name, mw.Signature, true); } } mw.ResolveMethod(); MethodInfo mi = mw.GetMethod() as MethodInfo; if (mi != null && !mw.HasCallerID && !tw.IsRemapped && !tw.IsGhost && !tw.IsNonPrimitiveValueType && type.parameterCount() <= MethodHandleUtil.MaxArity // FXBUG we should be able to use a normal (unbound) delegate for virtual methods // (when doDispatch is set), but the x64 CLR crashes when doing a virtual method dispatch on // a null reference && (!mi.IsVirtual || (doDispatch && IntPtr.Size == 4)) && (doDispatch || !mi.IsVirtual)) { return(Delegate.CreateDelegate(MethodHandleUtil.CreateDelegateType(tw, mw), mi)); } else { // slow path where we emit a DynamicMethod MethodHandleUtil.DynamicMethodBuilder dm = new MethodHandleUtil.DynamicMethodBuilder(mw.DeclaringType.TypeAsBaseType, "DirectMethodHandle:" + mw.Name, type, mw.HasCallerID ? [email protected](lookupClass) : null); for (int i = 0, count = type.parameterCount(); i < count; i++) { if (i == 0 && !mw.IsStatic && (tw.IsGhost || tw.IsNonPrimitiveValueType)) { dm.LoadFirstArgAddress(); } else { dm.Ldarg(i); } } if (mw.HasCallerID) { dm.LoadCallerID(); } if (doDispatch && !mw.IsStatic) { dm.Callvirt(mw); } else { dm.Call(mw); } dm.Ret(); return(dm.CreateDelegate()); } } #endif }