public bool DeclareVariables(VarDeclarationList List, VarDeclConvMode Mode = VarDeclConvMode.Nothing, GetIdMode IdMode = GetIdMode.Everywhere) { var Variables = List.ToVariables(GetPlugin(), BeginEndMode.Both, Mode); return(DeclareVariables(Variables, IdMode)); }
public List <IdentifierFound> GetIdentifier(string Name, GetIdMode Mode = GetIdMode.Everywhere, Predicate <Identifier> Func = null) { var Out = new List <IdentifierFound>(); GetIdentifier(Name, Out, Mode, Func: Func); return(Out); }
public bool DeclareVariables(CodeString Str, List <Modifier> Mods = null, VarDeclConvMode Mode = VarDeclConvMode.Nothing, GetIdMode IdMode = GetIdMode.Everywhere) { var List = VarDeclarationList.Create(this, Str, Mods); if (List == null) { return(false); } return(DeclareVariables(List, Mode, IdMode)); }
public virtual bool DeclareVariables(Variable[] Variables, GetIdMode IdMode = GetIdMode.Everywhere) { var RetValue = true; for (var i = 0; i < Variables.Length; i++) { if (Variables[i] == null || !DeclareIdentifier(Variables[i])) { RetValue = false; } } return(RetValue); }
public bool GetIdentifier(string Name, List <IdentifierFound> Out, GetIdMode Mode = GetIdMode.Everywhere, bool SearchedInBasicTypes = false, Predicate <Identifier> Func = null) { /*if (FunctionScope != null && Mode != GetIdMode.Scope) * { * Predicate<T> LFunc = x => * { * if (x.Container != this && !IsSubContainerOf(x.Container)) * return false; * * return Func == null || Func(x); * }; * * FunctionScope.LocalIdentifiers.Get<T>(Name, Out, LFunc); * if (Mode == GetIdMode.Everywhere && FunctionScope.Parent != null) * FunctionScope.Parent.GetIdentifier(Name, Out, Mode, SearchedInBasicTypes, Func); * } * else * {*/ if (!SearchedInBasicTypes) { var R = GetPredeclaredIdentifier(Name); if (R != null && (Func == null || Func(R))) { Out.Add(new IdentifierFound(GlobalContainer, R)); return(true); } SearchedInBasicTypes = true; } var RetValue = GetContainerId(Name, Out, Func); if (Parent != null && Mode != GetIdMode.Container) { var F = FunctionScope; if (Mode != GetIdMode.Function || (Parent.FunctionScope == F && F != null)) { if (Parent.GetIdentifier(Name, Out, Mode, SearchedInBasicTypes, Func)) { RetValue = true; } } } return(RetValue); //} }
public override bool DeclareVariables(Variable[] Variables, GetIdMode IdMode = GetIdMode.Everywhere) { var Ret = base.DeclareVariables(Variables, IdMode); for (var i = 0; i < Variables.Length; i++) { var e = Variables[i]; if (e != null && e.InitValue != null) { Children.Add(new Command(this, e.InitString, CommandType.Expression) { Expressions = new List <ExpressionNode>() { e.InitValue }, }); } } return(Ret); }
public bool IsIdDefined(string Name, GetIdMode Mode = GetIdMode.Everywhere, Predicate <Identifier> Func = null) { return(GetIdentifier(Name, Mode, Func).Count > 0); }