public Function CreateSetter(CodeString Declaration, CodeString ValueName, CodeString Code, IdentifierAccess Access = IdentifierAccess.Public) { var PChildren = Property.Children.Length; var Children = new Identifier[PChildren + 1]; Children[0] = GlobalContainer.CommonIds.Void; Children[PChildren] = new FunctionParameter(this, ValueName, Property.TypeOfSelf); for (var i = 1; i < PChildren; i++) { Children[i] = Property.Children[i]; } var Type = new TypeOfFunction(this, DefaultCallConv, Children); var Ret = CreateFunctionForAccessor("set", Declaration, Type, Access); if (Ret == null || !CreateScopeForAccessor(Ret, Code)) { return(null); } Setter = Ret; return(Ret); }
public AccessModifier(CodeString Code, IdentifierAccess Access) : base(Code) { this.Access = Access; if (Access == IdentifierAccess.Unknown) { throw new ArgumentOutOfRangeException("Access"); } }
public static bool GetIdAccess(IdContainer Container, ref CodeString Code, out IdentifierAccess Ret) { var Mods = Recognize(Container, ref Code); if (Mods == null) { Ret = IdentifierAccess.Unknown; return(false); } return(GetIdAccess(Container.State, Mods, out Ret)); }
public Word Visit(IdentifierAccess identifierAccess) { var result = identifierAccess.IdentifierNode.Accept(this); if (IsError(result)) { return(result); } var idValue = ((MyString)result).StringValue; return(new IdentifierSegment(idValue)); }
private IdentifierAccess CreateIdentifier(string text) { if (_identifiers.Contains(text)) { return _identifiers[text]; } else { var identifier = new IdentifierAccess(text); _identifiers.Add(identifier); return identifier; } }
private IdentifierAccess CreateIdentifier(string text) { if (_identifiers.Contains(text)) { return(_identifiers[text]); } else { var identifier = new IdentifierAccess(text); _identifiers.Add(identifier); return(identifier); } }
public Function CreateGetter(CodeString Declaration, CodeString Code, IdentifierAccess Access = IdentifierAccess.Public) { var Children = new Identifier[Property.Children.Length]; for (var i = 0; i < Property.Children.Length; i++) { Children[i] = Property.Children[i]; } var Type = new TypeOfFunction(this, DefaultCallConv, Children); var Ret = CreateFunctionForAccessor("get", Declaration, Type, Access); if (Ret == null || !CreateScopeForAccessor(Ret, Code)) { return(null); } Getter = Ret; return(Ret); }
public static bool GetIdAccess(CompilerState State, List <Modifier> Mods, out IdentifierAccess Ret) { var RetValue = true; Ret = IdentifierAccess.Unknown; for (var i = 0; i < Mods.Count; i++) { var Mod = Mods[i] as AccessModifier; if (Mod == null) { State.Messages.Add(MessageId.NotExpected, Mods[i].Code); RetValue = false; continue; } Ret = Mod.Access; } return(RetValue); }
Function CreateFunctionForAccessor(string Name, CodeString Declaration, TypeOfFunction Type, IdentifierAccess Access) { if (Identifiers.IsLessRestrictive(Access, Property.Access)) { State.Messages.Add(MessageId.PropertyAccessLevel, Name); return(null); } Function Ret; if (!(Parent is StructuredScope) || (Property.Flags & IdentifierFlags.Static) != 0) { Ret = new Function(this, new CodeString(Name), Type, null); } else { Ret = new MemberFunction(this, new CodeString(Name), Type, null); } Ret.Flags = Property.Flags; Ret.Access = Access; Ret.Declaration = Declaration; return(Ret); }
public virtual IAstNode IdentifierAccess(IdentifierAccess identifierAccess) { return(identifierAccess); }
public IExpression IdentifierAccess(IdentifierAccess identifierAccess) { // First try variables. var identifiers = _resolver.DynamicExpression.ParseResult.Identifiers; for (int i = 0; i < _resolver.IdentifierTypes.Length; i++) { if ( _resolver.IdentifierTypes[i] != null && _resolver.IdentifiersEqual(identifiers[i].Name, identifierAccess.Name) ) { return(VariableAccess(_resolver.IdentifierIndexes[i], _resolver.IdentifierTypes[i])); } } // Next, we go through the owner type. if (_resolver.OwnerType != null) { var result = Resolve(new VariableAccess(_resolver.OwnerType, 0), identifierAccess.Name); if (result == null) { result = Resolve(new TypeAccess(_resolver.OwnerType), identifierAccess.Name); } if (result != null) { return(result); } } // Next, imports. Namespaces have precedence. foreach (var import in _resolver.Imports) { if ( import.Namespace != null && _resolver.IdentifiersEqual(import.Namespace, identifierAccess.Name) ) { if (import.Type != null) { return(new TypeAccess(import.Type)); } else { return(new ImportAccess(import)); } } } // Next, members of the imports. foreach (var import in _resolver.Imports) { if (import.Namespace == null) { var result = Resolve(new TypeAccess(import.Type), identifierAccess.Name); if (result != null) { return(result); } } } // Last, see whether the identifier is a built in type. var type = TypeUtil.GetBuiltInType(identifierAccess.Name, _resolver.DynamicExpression.Language); if (type != null) { return(new TypeAccess(type)); } throw new ExpressionsException( String.Format("Unresolved identifier '{0}'", identifierAccess.Name), ExpressionsExceptionType.UndefinedName ); }