Example #1
0
        public NVTypeNode ResolveNamedTypeNodes(ErrorHandler errs, Scope currentScope, NVTypeNode type)
        {
            if (type is NVNamedTypeNode)
            {
                NVIdNode newType = currentScope.Find(type.Name);
                if (newType != null)
                {
                    return((NVTypeNode)newType);
                }
                AddSemanticError(errs, string.Format("The type name '{0}' could not be found", type.Name), _pos,
                                 ErrorSeverity.Warning);
            }

            return(type);
        }
Example #2
0
        public NVIdNode FindMember(ErrorHandler errs, Position pos, string name)
        {
            if (_scope != null)
            {
                NVIdNode idNode = _scope.Find(name);
                if (idNode != null)
                {
                    return(idNode);
                }
            }

            // Could not obtain the identifier node
            AddSemanticError(errs, string.Format(
                                 "The name '{0}' does not exist in the current context", name), _pos, ErrorSeverity.Warning);
            return(null);
        }
Example #3
0
        public override void DoSemanticChecks(ErrorHandler errs, Scope currentScope)
        {
            _id = currentScope.Find(_name);
            if (_id == null)
            {
                //AddSemanticError(errs, string.Format("The name '{0}' does not exist in the current context", _name),
                //    _pos, ErrorSeverity.Error);
                return;
            }

            _type = _id.Type;
            foreach (NVSelector selector in _selectors)
            {
                _type = selector.DoSemanticChecks(errs, currentScope, _type);
            }
        }
Example #4
0
        public NVTypeNode DoSemanticChecks(ErrorHandler errs, Scope currentScope, NVTypeNode currentType)
        {
            currentType = ResolveNamedTypeNodes(errs, currentScope, currentType);

            // Check to see if the current node is an empty placeholder selector
            if (_id.Name == "")
            {
                return(currentType);
            }

            if (currentType == null)
            {
                //TODO: Uncomment this when support for objects passed through the property bag is much better
                //AddSemanticError(errs, "Type of identifier unknown", _pos, ErrorSeverity.Warning);
                return(null);
            }

            if (!(currentType is NVClassNode))
            {
                AddSemanticError(errs, string.Format(
                                     "Cannot apply identifier selector to type '{0}', the type must be a class type",
                                     currentType.Name), _pos, ErrorSeverity.Warning);
                return(currentType);
            }

            // Check if the member exists
            _id = ((NVClassNode)currentType).FindMember(errs, _pos, _id.Name);
            if (_id == null)
            {
                return(currentType);
            }

            _id.Type = ResolveNamedTypeNodes(errs, currentScope, _id.Type);
            _type    = _id.Type;
            return(_type);
        }
Example #5
0
 public NVSelector(NVIdNode id, NVReference nvReference)
 {
     _id          = id;
     _nvReference = nvReference;
 }