Exemplo n.º 1
0
        public static List <Interfaces.iFunction> getFunctionReferenceOfFQN(NamespaceResolver nsr)
        {
            List <Interfaces.iFunction> retList = new List <Interfaces.iFunction>();

            if (nsr == null)
            {
                return(retList);
            }
            if (!nsr.IsValid)
            {
                return(retList);
            }
            var obj = nsr.objectTree.Last().Parent;

            if (nsr.objectTree.Last() is Interfaces.iClass)
            {
                obj = nsr.objectTree.Last();
            }
            foreach (var it in obj.getAllChildrenOf <Interfaces.iFunction>())
            {
                if (nsr.isSame(it.Name))
                {
                    retList.Add(it);
                }
            }
            return(retList);
        }
Exemplo n.º 2
0
        public bool IsKindOf(VarTypeObject vto)
        {
            if (this.varType != VarType.Object)
            {
                return(false);
            }
            HelperClasses.NamespaceResolver nsrL = this.ident.LastIdent;
            HelperClasses.NamespaceResolver nsrR = vto.ident.LastIdent;
            if (!(nsrL.Reference is Interfaces.iClass))
            {
                return(false);
            }
            if (!(nsrR.Reference is Interfaces.iClass))
            {
                return(false);
            }
            var list = new List <Ident>();

            list.AddRange(((Interfaces.iClass)nsrL.Reference).ExtendedClasses);
            list.Add(((Interfaces.iClass)nsrL.Reference).Name);
            foreach (var it in list)
            {
                HelperClasses.NamespaceResolver nsrTmp = it.LastIdent;
                if (nsrTmp.isSame(nsrR))
                {
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 3
0
        public bool isType(HelperClasses.NamespaceResolver nsr)
        {
            if (!nsr.IsValid)
            {
                throw new Exception();
            }
            var lType = this.GetType();
            var rType = nsr.Reference.GetType();

            return(lType.Equals(rType));
        }
Exemplo n.º 4
0
 public static Interfaces.iClass getClassReferenceOfFQN(NamespaceResolver nsr)
 {
     if (nsr == null)
     {
         return(null);
     }
     if (!nsr.IsValid)
     {
         return(null);
     }
     return((Interfaces.iClass)nsr.objectTree.Last());
 }
Exemplo n.º 5
0
 public bool isInNamespace(NamespaceResolver nsr)
 {
     if (nsr == null)
     {
         return(false);
     }
     foreach (var it in this.objectTree)
     {
         if (nsr.Reference == it)
         {
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 6
0
 public static Variable getVariableReferenceOfFQN(NamespaceResolver nsr, bool localVariables = true, pBaseLangObject blo = null)
 {
     if (nsr == null)
     {
         return(null);
     }
     if (!nsr.IsValid && !localVariables)
     {
         return(null);
     }
     if (!nsr.IsValid)
     {
         if (blo == null)
         {
             return(null);
         }
         pBaseLangObject curObj         = blo;
         List <Variable> privateVarList = new List <Variable>();
         while (true)
         {
             curObj = (pBaseLangObject)curObj.getFirstOf <Interfaces.iCodeBlock>(false);
             if (curObj == null)
             {
                 break;
             }
             privateVarList.AddRange(curObj.getAllChildrenOf <Variable>());
         }
         foreach (var it in privateVarList)
         {
             if (nsr.origString.EndsWith(':' + it.Name.OriginalValue))
             {
                 return(it);
             }
         }
         return(null);
     }
     else
     {
         if (nsr.objectTree.Last() is Variable)
         {
             return((Variable)nsr.objectTree.Last());
         }
         else
         {
             return(null);
         }
     }
 }
Exemplo n.º 7
0
        //public static NamespaceResolver createNSR(string fqn, string origVal, bool takeFirst = false)
        //{
        //    NamespaceResolver nsr = new NamespaceResolver(fqn);
        //    if (takeFirst)
        //        return nsr;
        //    while (!nsr.IsValid)
        //    {
        //        if (nsr.Reference == null)
        //            return null;
        //        if(nsr.LayerCount > 1)
        //        {
        //
        //        }
        //        if (nsr.Reference.Parent is Interfaces.iName)
        //            nsr = new HelperClasses.NamespaceResolver(((Interfaces.iName)nsr.Reference.Parent).Name.FullyQualifiedName + "." + origVal);
        //        else
        //            return null;
        //    }
        //    return nsr;
        //}
        public static NamespaceResolver createNSR(string fqn, bool takeFirst = false)
        {
            NamespaceResolver nsr = new NamespaceResolver(fqn);

            if (takeFirst)
            {
                return(nsr);
            }
            int    index = fqn.LastIndexOf(':');
            string prQN  = index > 0 ? fqn.Substring(fqn.LastIndexOf(':') + 1) : fqn;

            Interfaces.iName lastRef = nsr.Reference is Interfaces.iName ? (Interfaces.iName)nsr.Reference : null;
            if (lastRef == null)
            {
                return(null);
            }
            while (!nsr.IsValid)
            {
                if (nsr.Reference == null)
                {
                    return(null);
                }
                if (((pBaseLangObject)lastRef).Parent is Interfaces.iName)
                {
                    lastRef = (Interfaces.iName)((pBaseLangObject)lastRef).Parent;
                    nsr     = new HelperClasses.NamespaceResolver(lastRef.Name.FullyQualifiedName + "." + prQN);
                }
                else if (((pBaseLangObject)lastRef).Parent is Base)
                {
                    nsr = new HelperClasses.NamespaceResolver(prQN);
                    if (nsr.IsValid)
                    {
                        return(nsr);
                    }
                    else
                    {
                        return(null);
                    }
                }
                else
                {
                    return(null);
                }
            }
            return(nsr);
        }
Exemplo n.º 8
0
 public override bool Equals(object obj)
 {
     if (obj is HelperClasses.NamespaceResolver)
     {
         if (!this.IsObject)
         {
             return(false);
         }
         HelperClasses.NamespaceResolver nsrL = this.ident.LastIdent;
         HelperClasses.NamespaceResolver nsrR = (HelperClasses.NamespaceResolver)obj;
         if (nsrL != null && nsrR != null)
         {
             return(nsrL.isSame(nsrR));
         }
         else
         {
             return(((VarTypeObject)obj).ident.FullyQualifiedName.Equals(this.ident.FullyQualifiedName));
         }
     }
     else
     {
         if (!(obj is VarTypeObject))
         {
             return(false);
         }
         if (((VarTypeObject)obj).varType != this.varType)
         {
             return(false);
         }
         if (this.varType != VarType.Object)
         {
             return(true);
         }
         HelperClasses.NamespaceResolver nsrL = this.ident.LastIdent;
         HelperClasses.NamespaceResolver nsrR = ((VarTypeObject)obj).ident.LastIdent;
         if (nsrL != null && nsrR != null)
         {
             return(nsrL.isSame(nsrR));
         }
         else
         {
             return(((VarTypeObject)obj).ident.FullyQualifiedName.Equals(this.ident.FullyQualifiedName));
         }
     }
 }
Exemplo n.º 9
0
        public bool isSame(NamespaceResolver nsr)
        {
            if (nsr.LayerCount != this.LayerCount)
            {
                return(false);
            }
            bool flag = true;

            for (int i = 0; i < this.LayerCount; i++)
            {
                var it1 = this.objectTree[i];
                var it2 = nsr.objectTree[i];
                if (!it1.Equals(it2))
                {
                    flag = false;
                    break;
                }
            }
            return(flag);
        }
Exemplo n.º 10
0
        public override int doFinalize()
        {
            int   errCount    = 0;
            Ident parentIdent = (this.Parent is Ident ? (Ident)this.Parent : default(Ident));

            //Check what we have here (possible outcomes: variableacces, arrayaccess, functioncall, namespaceaccess)
            #region typeDetection
            type = IdenType.NamespaceAccess;
            var fncCalls  = this.getAllChildrenOf <FunctionCall>();
            var arrAccess = this.getAllChildrenOf <ArrayAccess>();
            if (this.Parent is Template && !(this.Parent.Parent is Ident))
            {
                type = IdenType.TemplateVar;
            }
            else if (this.Parent is SqfCall && ((SqfCall)this.Parent).Name == this)
            {
                type = IdenType.SqfCommandName;
            }
            else if (this.IsSelfReference)
            {
                type = IdenType.ThisVar;
            }
            else if (fncCalls.Count > 0)
            {
                type = IdenType.FunctionCall;
            }
            else if (arrAccess.Count > 0)
            {
                type = IdenType.ArrayAccess;
            }
            else if (IsNamespaceAccess())
            {
                type = IdenType.NamespaceAccess;
            }
            else if (parentIdent == null && this.Access == AccessType.NA)
            {
                if (this.Parent is Interfaces.iClass || (this.Parent is Interfaces.iFunction && ((Interfaces.iFunction) this.Parent).ReturnType.ident == this) || this.Parent is Value || this.Parent is Variable)
                {
                    type = IdenType.NamespaceAccess;
                }
                else
                {
                    type = IdenType.VariableAccess;
                }
            }
            else if (parentIdent != null && (
                         (parentIdent.Access == AccessType.Namespace && this.Access == AccessType.NA) ||
                         this.Access == AccessType.Instance ||
                         (parentIdent.Access == AccessType.Instance && this.Access == AccessType.NA)
                         ))
            {
                var ntr = HelperClasses.NamespaceResolver.createNSR(this);
                if (ntr == null)
                {
                    Logger.Instance.log(Logger.LogLevel.ERROR, ErrorStringResolver.resolve(ErrorStringResolver.LinkerErrorCode.LNK0012, this.Line, this.Pos, this.File));
                    errCount++;
                    return(errCount);
                }
                if (ntr.Reference is Interfaces.iClass)
                {
                    type = IdenType.NamespaceAccess;
                }
                else
                {
                    type = IdenType.VariableAccess;
                }
            }
            else if (this.Access == AccessType.Namespace)
            {
                type = IdenType.NamespaceAccess;
            }
            else if (this.Access == AccessType.Instance && parentIdent == null)
            {
                type = IdenType.VariableAccess;
            }
            else
            {
                Logger.Instance.log(Logger.LogLevel.ERROR, ErrorStringResolver.resolve(ErrorStringResolver.LinkerErrorCode.UNKNOWN, this.Line, this.Pos, this.File));
                errCount++;
            }
            #endregion
            //And process it then ((unless its a simple ident, then we do not want to process ... here any further))
            if (
                this.IsSimpleIdentifier &&
                (
                    (this.Parent is Interfaces.iName && ((Interfaces.iName) this.Parent).Name == this) ||
                    (this.Parent is Interfaces.iHasType && !(this.Parent is Expression) && ((Interfaces.iHasType) this.Parent).ReferencedType.ident == this)
                ) &&
                !(this.Parent is AssignContainer) &&
                !(this.Parent is NewInstance) &&
                !(this.Parent is Interfaces.iHasType && ((Interfaces.iHasType) this.Parent).ReferencedType.ident == this)
                )
            {
                this.ReferencedObject = this.Parent;
                if (this.Parent is Interfaces.iHasType)
                {
                    this.ReferencedType = ((Interfaces.iHasType) this.Parent).ReferencedType;
                }
                else //todo: try to replace with proper refObject type
                {
                    this.ReferencedType = new VarTypeObject(this, (this.Parent is Interfaces.iTemplate ? ((Interfaces.iTemplate) this.Parent).TemplateObject : null));
                }
            }
            else
            {
                switch (type)
                {
                    #region ThisVar
                case IdenType.ThisVar:
                {
                    Interfaces.iClass curObject = this.getFirstOf <Interfaces.iClass>();
                    this.ReferencedObject = (pBaseLangObject)curObject;
                    this.ReferencedType   = curObject.VTO;
                    var fnc = this.getFirstOf <Interfaces.iFunction>();
                    if (fnc.FunctionEncapsulation == Encapsulation.Static)
                    {
                        Logger.Instance.log(Logger.LogLevel.ERROR, ErrorStringResolver.resolve(ErrorStringResolver.LinkerErrorCode.LNK0055, this.Line, this.Pos, this.File));
                        errCount++;
                    }
                }
                break;

                    #endregion
                    #region TemplateVar
                case IdenType.TemplateVar:
                {
                    this.ReferencedObject = (pBaseLangObject)this.getFirstOf <Interfaces.iClass>();
                    this.ReferencedType   = ((Interfaces.iClass) this.ReferencedObject).VTO;
                }
                break;

                    #endregion
                    #region SqfCommandName
                case IdenType.SqfCommandName:
                {
                    this.ReferencedObject = this.Parent;
                    this.ReferencedType   = ((SqfCall)this.Parent).ReferencedType;
                }
                break;

                    #endregion
                    #region VariableAccess & ArrayAccess
                case IdenType.VariableAccess:
                case IdenType.ArrayAccess:
                {
                    var nsr = HelperClasses.NamespaceResolver.createNSR(this);
                    if (nsr != null && nsr.IsValid && (nsr.Reference is oosEnum.EnumEntry || nsr.Reference is oosEnum))
                    {
                        if (nsr.Reference is oosEnum.EnumEntry)
                        {
                            var entry = (oosEnum.EnumEntry)nsr.Reference;
                            this.ReferencedObject = entry;
                            this.ReferencedType   = ((oosEnum)entry.Parent).ReferencedType;
                            break;
                        }
                        else if (nsr.Reference is oosEnum)
                        {
                            var e = (oosEnum)nsr.Reference;
                            this.ReferencedObject = e;
                            this.ReferencedType   = e.ReferencedType;
                            break;
                        }
                    }
                    var variable = HelperClasses.NamespaceResolver.getVariableReferenceOfFQN(HelperClasses.NamespaceResolver.createNSR(this, true), true, this);
                    if (variable == null)
                    {
                        variable = HelperClasses.NamespaceResolver.getVariableReferenceOfFQN(this, false, this);
                    }
                    if (variable == null)
                    {
                        Logger.Instance.log(Logger.LogLevel.ERROR, ErrorStringResolver.resolve(ErrorStringResolver.LinkerErrorCode.LNK0012, this.Line, this.Pos, this.File));
                        errCount++;
                    }
                    else
                    {
                        this.ReferencedObject = variable;
                        //Set type to variable type
                        this.ReferencedType = variable.varType;

                        if (type == IdenType.ArrayAccess)
                        {
                            if (variable.ReferencedType.IsObject)
                            {
                                //Check if given object is implementing the ArrayAccess operator
                                if (variable.ReferencedType.ident.LastIdent.ReferencedObject is Interfaces.iClass)
                                {
                                    Interfaces.iClass            classRef = (Interfaces.iClass)variable.ReferencedType.ident.LastIdent.ReferencedObject;
                                    Interfaces.iOperatorFunction opFnc    = classRef.getOperatorFunction(OverridableOperator.ArrayAccess);
                                    if (opFnc == null)
                                    {
                                        Logger.Instance.log(Logger.LogLevel.ERROR, ErrorStringResolver.resolve(ErrorStringResolver.LinkerErrorCode.LNK0005, this.Line, this.Pos, this.File));
                                        errCount++;
                                    }
                                    else
                                    {
                                        this.ReferencedType = opFnc.ReturnType;
                                        if (variable.TemplateObject != null)
                                        {
                                            var templateList = ((pBaseLangObject)opFnc).getAllParentsOf <Interfaces.iTemplate>();
                                            foreach (var it in templateList)
                                            {
                                                var tmp = HelperClasses.ArgList.resolveVarTypeObject(opFnc.ReturnType, it.TemplateObject, variable.TemplateObject);
                                                if (tmp != opFnc.ReturnType)
                                                {
                                                    this.ReferencedType = tmp;
                                                    break;
                                                }
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    Logger.Instance.log(Logger.LogLevel.ERROR, ErrorStringResolver.resolve(ErrorStringResolver.LinkerErrorCode.UNKNOWN, this.Line, this.Pos, this.File));
                                    errCount++;
                                }
                            }
                            else
                            {
                                //just check if this is an array type
                                switch (this.ReferencedType.varType)
                                {
                                case VarType.BoolArray:
                                    this.ReferencedType         = new VarTypeObject(this.ReferencedType);
                                    this.ReferencedType.varType = VarType.Bool;
                                    break;

                                case VarType.ScalarArray:
                                    this.ReferencedType         = new VarTypeObject(this.ReferencedType);
                                    this.ReferencedType.varType = VarType.Scalar;
                                    break;

                                default:
                                    Logger.Instance.log(Logger.LogLevel.ERROR, ErrorStringResolver.resolve(ErrorStringResolver.LinkerErrorCode.LNK0006, this.Line, this.Pos, this.File));
                                    errCount++;
                                    break;
                                }
                            }
                        }
                    }
                }
                break;

                    #endregion
                    #region FunctionCall
                case IdenType.FunctionCall:
                {
                    List <Interfaces.iFunction> fncList;
                    var fncCall     = fncCalls[0];
                    var newInstance = this.getFirstOf <NewInstance>(true, typeof(Ident));
                    var fqn         = this.FullyQualifiedName;
                    if (parentIdent != null && parentIdent.ReferencedObject is Variable)
                    {
                        //if (((Variable)parentIdent.ReferencedObject).ReferencedType.IsObject)
                        //    fqn = ((Interfaces.iClass)((Variable)parentIdent.ReferencedObject).ReferencedType.ident.LastIdent.ReferencedObject).Name.LastIdent.FullyQualifiedName + "." + this.originalValue;
                        //else
                        parentIdent.ReferencedObject.finalize();
                        fqn = parentIdent.ReferencedType.ident.LastIdent.ReferencedType.ident.LastIdent.FullyQualifiedName + "." + this.originalValue;
                    }
                    if (newInstance == null)
                    {
                        fncList = HelperClasses.NamespaceResolver.getFunctionReferenceOfFQN(HelperClasses.NamespaceResolver.createNSR(fqn));
                    }
                    else
                    {
                        fncList = HelperClasses.NamespaceResolver.getFunctionReferenceOfFQN(HelperClasses.NamespaceResolver.createNSR(fqn + "." + this.originalValue));
                    }
                    if (fncList.Count == 0)
                    {
                        Logger.Instance.log(Logger.LogLevel.ERROR, ErrorStringResolver.resolve(ErrorStringResolver.LinkerErrorCode.LNK0001, this.Line, this.Pos, this.File));
                        errCount++;
                    }
                    else
                    {
                        //Search the correct function in the possible matches
                        Interfaces.iFunction fnc = null;
                        foreach (var it in fncList)
                        {
                            if (HelperClasses.ArgList.matchesArglist(it.ArgList, fncCall.ArgList, (parentIdent != null && parentIdent.ReferencedObject is Variable ? (Variable)parentIdent.ReferencedObject : null)))
                            {
                                fnc = it;
                                break;
                            }
                        }
                        //Raise new linker issue if we could not locate a matching function
                        if (fnc == null)
                        {
                            Logger.Instance.log(Logger.LogLevel.ERROR, ErrorStringResolver.resolve(ErrorStringResolver.LinkerErrorCode.LNK0002, this.Line, this.Pos, this.File));
                            errCount++;
                        }
                        else
                        {
                            if (fnc is Function && ((Function)fnc).IsConstructor && this.getFirstOf <NewInstance>() == null)
                            {
                                Logger.Instance.log(Logger.LogLevel.ERROR, ErrorStringResolver.resolve(ErrorStringResolver.LinkerErrorCode.LNK0026, this.Line, this.Pos, this.File));
                                errCount++;
                            }
                            //Ref the object to the function
                            this.ReferencedObject = (pBaseLangObject)fnc;
                            //Ref the type to the return type
                            this.ReferencedType = fnc.ReturnType;

                            //As last step make sure we got the correct encapsulation here
                            var enc = fnc.FunctionEncapsulation;
                            if (enc != Encapsulation.Static && enc != Encapsulation.Public)
                            {
                                var parentClass = this.getFirstOf <Interfaces.iClass>();
                                HelperClasses.NamespaceResolver fncNsr = fnc.Name;
                                if (enc == Encapsulation.Private)
                                {
                                    //Private encapsulation just requires checking the current class we are operating in
                                    if (!fncNsr.isInNamespace(parentClass == null ? null : parentClass.Name))
                                    {
                                        Logger.Instance.log(Logger.LogLevel.ERROR, ErrorStringResolver.resolve(ErrorStringResolver.LinkerErrorCode.LNK0003, this.Line, this.Pos, this.File));
                                        errCount++;
                                    }
                                }
                                else
                                {
                                    //Protected we need to check ALL extended classes ...
                                    var  classes = parentClass.ExtendedClasses;
                                    bool flag    = false;
                                    foreach (var it in classes)
                                    {
                                        if (fncNsr.isInNamespace(it))
                                        {
                                            flag = true;
                                            break;
                                        }
                                    }
                                    if (!flag)
                                    {
                                        Logger.Instance.log(Logger.LogLevel.ERROR, ErrorStringResolver.resolve(ErrorStringResolver.LinkerErrorCode.LNK0004, this.Line, this.Pos, this.File));
                                        errCount++;
                                    }
                                }
                            }
                        }
                    }
                }
                break;

                    #endregion
                    #region NamespaceAccess
                case IdenType.NamespaceAccess:
                {
                    if (this.IsAnonymousIdent)
                    {
                        this.ReferencedObject = getClassTemplate();
                        this.ReferencedObject = null;
                    }
                    else
                    {
                        var nsr = HelperClasses.NamespaceResolver.createNSR(this);
                        if (nsr == null)
                        {
                            Logger.Instance.log(Logger.LogLevel.ERROR, ErrorStringResolver.resolve(ErrorStringResolver.LinkerErrorCode.LNK0046, this.Line, this.Pos, this.File));
                            errCount++;
                        }
                        else
                        {
                            var reference = nsr.Reference;
                            this.ReferencedObject = reference;
                            if (reference is Interfaces.iClass)
                            {
                                this.ReferencedType = ((Interfaces.iClass)reference).VTO;
                            }
                            else if (reference is Interfaces.iFunction)
                            {
                                this.ReferencedType = ((Interfaces.iFunction)reference).ReturnType;
                            }
                            else
                            {
                                this.ReferencedType = null;
                            }
                        }
                    }
                }
                break;
                    #endregion
                }
            }


            return(errCount);
        }
 public bool isSame(NamespaceResolver nsr)
 {
     if (nsr.LayerCount != this.LayerCount)
         return false;
     bool flag = true;
     for(int i = 0; i < this.LayerCount; i++)
     {
         var it1 = this.objectTree[i];
         var it2 = nsr.objectTree[i];
         if (!it1.Equals(it2))
         {
             flag = false;
             break;
         }
     }
     return flag;
 }
 public bool isInNamespace(NamespaceResolver nsr)
 {
     throw new NotImplementedException();
 }
 public static Variable getVariableReferenceOfFQN(NamespaceResolver nsr, bool localVariables = true, pBaseLangObject blo = null)
 {
     if (nsr == null)
         return null;
     if (!nsr.IsValid && !localVariables)
         return null;
     if(!nsr.IsValid)
     {
         if (blo == null)
             return null;
         pBaseLangObject curObj = blo;
         List<Variable> privateVarList = new List<Variable>();
         while (true)
         {
             curObj = (pBaseLangObject)curObj.getFirstOf<Interfaces.iCodeBlock>(false);
             if (curObj == null)
                 break;
             privateVarList.AddRange(curObj.getAllChildrenOf<Variable>());
         }
         foreach(var it in privateVarList)
         {
             if (it.Name.FullyQualifiedName == nsr.origString)
                 return it;
         }
         return null;
     }
     else
     {
         if (nsr.objectTree.Last() is Variable)
             return (Variable)nsr.objectTree.Last();
         else
             return null;
     }
 }
 public static List<Interfaces.iFunction> getFunctionReferenceOfFQN(NamespaceResolver nsr)
 {
     List<Interfaces.iFunction> retList = new List<Interfaces.iFunction>();
     if (nsr == null)
         return retList;
     if (!nsr.IsValid)
         return retList;
     var obj = nsr.objectTree.Last().Parent;
     if (nsr.objectTree.Last() is Interfaces.iClass)
         obj = nsr.objectTree.Last();
     foreach(var it in obj.getAllChildrenOf<Interfaces.iFunction>())
     {
         if(nsr.isSame(it.Name))
         {
             retList.Add(it);
         }
     }
     return retList;
 }
 public static Interfaces.iClass getClassReferenceOfFQN(NamespaceResolver nsr)
 {
     if (nsr == null)
         return null;
     if (!nsr.IsValid)
         return null;
     return (Interfaces.iClass)nsr.objectTree.Last();
 }
 //public static NamespaceResolver createNSR(string fqn, string origVal, bool takeFirst = false)
 //{
 //    NamespaceResolver nsr = new NamespaceResolver(fqn);
 //    if (takeFirst)
 //        return nsr;
 //    while (!nsr.IsValid)
 //    {
 //        if (nsr.Reference == null)
 //            return null;
 //        if(nsr.LayerCount > 1)
 //        {
 //
 //        }
 //        if (nsr.Reference.Parent is Interfaces.iName)
 //            nsr = new HelperClasses.NamespaceResolver(((Interfaces.iName)nsr.Reference.Parent).Name.FullyQualifiedName + "." + origVal);
 //        else
 //            return null;
 //    }
 //    return nsr;
 //}
 public static NamespaceResolver createNSR(string fqn, bool takeFirst = false)
 {
     NamespaceResolver nsr = new NamespaceResolver(fqn);
     if (takeFirst)
         return nsr;
     int index = fqn.LastIndexOf(':');
     string prQN = index > 0 ? fqn.Substring(fqn.LastIndexOf(':') + 1) : fqn;
     Interfaces.iName lastRef = nsr.Reference is Interfaces.iName ? (Interfaces.iName)nsr.Reference : null;
     while(!nsr.IsValid)
     {
         if (nsr.Reference == null)
             return null;
         if (((pBaseLangObject)lastRef).Parent is Interfaces.iName)
         {
             lastRef = (Interfaces.iName)((pBaseLangObject)lastRef).Parent;
             nsr = new HelperClasses.NamespaceResolver(lastRef.Name.FullyQualifiedName + "." + prQN);
         }
         else
         {
             return null;
         }
     }
     return nsr;
 }