public override IRppNode Analyze(SymbolTable scope, Diagnostic diagnostic) { if (TargetType == null) { throw new Exception("TargetType should be specified before anaylyze is called"); } RType classType = TargetType; // TODO It's kinda weird to have resolution here and not in the scope, because similar // lookup is done for methods while (classType != null && Field == null) { Field = classType.Fields.FirstOrDefault(f => f.Name == Name); if (Field != null) { break; } classType = classType.BaseType; } if (Field == null) { var functions = scope.LookupFunction(Name); if (functions.Any(f => f.Parameters.IsEmpty())) { RppFuncCall funcCall = new RppFuncCall(Name, Collections.NoExprs); return funcCall.Analyze(scope, diagnostic); } throw SemanticExceptionFactory.ValueIsNotMember(Token, TargetType.ToString()); } Debug.Assert(classType != null, "obj != null"); Type = new ResolvableType(Field.Type); return this; }
private RppFieldInfo InflateField(RppFieldInfo field) { return new RppInflatedField(field, _genericArguments, this); }
public RppInflatedField(RppFieldInfo genericFieldDefinition, RType[] genericArguments, RType declaringType) : base(genericFieldDefinition.Name, genericFieldDefinition.Type, genericFieldDefinition.Attributes, declaringType) { GenericFieldDefinition = genericFieldDefinition; _genericArguments = genericArguments; }
private void LoadField(RppFieldInfo field) { if (!_inSelector) { _body.Emit(OpCodes.Ldarg_0); if (ClosureContext?.CapturedThis != null) { _body.Emit(OpCodes.Ldfld, ClosureContext.CapturedThis); } } if (IsInsideGetterOrSetter(field.Name)) { _body.Emit(OpCodes.Ldfld, field.Native); } else { _body.Emit(OpCodes.Callvirt, field.NativeGetter); } }
private static RppSelector CallSetter(IRppExpr target, RppFieldInfo field, IRppExpr value) { return new RppSelector(target, new RppFuncCall(field.SetterName, List(value))); }
private bool Equals(RppFieldInfo other) { return String.Equals(Name, other.Name) && Attributes == other.Attributes && Type.Equals(other.Type) && DeclaringType.Equals(other.DeclaringType); }
private void CreateProperty(RppFieldInfo field, IEnumerable<RppMethodInfo> methods) { Debug.Assert(_typeBuilder != null, "_typeBuilder != null"); PropertyBuilder propertyBuilder = _typeBuilder.DefineProperty(field.Name, PropertyAttributes.None, field.Type.NativeType, null); propertyBuilder.SetCustomAttribute(RTypeUtils.CreateCompilerGeneratedAttribute()); // TODO we need to update visibility somehow FieldBuilder fieldBuilder = _typeBuilder.DefineField(field.MangledName, field.Type.NativeType, FieldAttributes.Public); fieldBuilder.SetCustomAttribute(RTypeUtils.CreateCompilerGeneratedAttribute()); SetAccessors(propertyBuilder, methods); field.Native = fieldBuilder; field.NativeProperty = propertyBuilder; }
public RppFieldInfo DefineField([NotNull] string name, [NotNull] RType type, RFieldAttributes attributes) { RppFieldInfo field = new RppFieldInfo(name, type, attributes, this); _fields.Add(field); return field; }
private static RppFieldInfo Convert(FieldInfo field, RType declaringType) { RType fieldType = GetOrCreateType(field.FieldType.Name, field.FieldType); bool priv = (field.Attributes & FieldAttributes.Private) != 0; RFieldAttributes attr = priv ? RFieldAttributes.Private : RFieldAttributes.Public; RppFieldInfo rppField = new RppFieldInfo(field.Name, fieldType, attr, declaringType) { Native = field }; return rppField; }
private static RppFieldInfo Convert(PropertyInfo property, RType declaringType) { RType fieldType = GetOrCreateType(property.PropertyType.Name, property.PropertyType); const RFieldAttributes attr = RFieldAttributes.Public; RppFieldInfo rppField = new RppFieldInfo(property.Name, fieldType, attr, declaringType) { NativeProperty = property }; return rppField; }
private EmptyTypeDefinition() { TypeParameters = new RppTypeParameterInfo[0]; Constructors = new RppMethodInfo[0]; Fields = new RppFieldInfo[0]; Methods = new RppMethodInfo[0]; }