Ejemplo n.º 1
0
 public XElement(string name, Kind kind, Modifiers modifiers, Modifiers visibility, TextRange range, TextInterval interval)
 {
     _Name       = name;
     _Kind       = kind;
     _Modifiers  = modifiers;
     _Visibility = visibility;
     _range      = range;
     _interval   = interval;
     _isStatic   = false;
 }
Ejemplo n.º 2
0
 public XVariable(XElement parent, string name, Kind kind, Modifiers visibility, TextRange span, TextInterval position, string typeName, bool isParameter = false)
     : base(name, kind, Modifiers.None, visibility, span, position)
 {
     if (string.IsNullOrEmpty(typeName))
     {
         typeName = "USUAL";
     }
     _typeName    = typeName;
     _isParameter = isParameter;
     this.Parent  = parent;
 }
Ejemplo n.º 3
0
 public XType(string name, Kind kind, Modifiers modifiers, Modifiers visibility, TextRange span, TextInterval position)
     : base(name, kind, modifiers, visibility, span, position)
 {
     _members    = new List <XTypeMember>();
     _parentName = "System.Object";
     _nameSpace  = "";
     if (modifiers.HasFlag(Modifiers.Static))
     {
         this._isStatic = true;
     }
     if (modifiers.HasFlag(Modifiers.Partial))
     {
         this._isPartial = true;
     }
 }
Ejemplo n.º 4
0
 public XTypeMember(string name, Kind kind, Modifiers modifiers, Modifiers visibility, TextRange span, TextInterval position, string typeName, bool isStatic)
     : this(name, kind, modifiers, visibility, span, position, isStatic)
 {
     _typeName = typeName;
 }
Ejemplo n.º 5
0
 public XTypeMember(string name, Kind kind, Modifiers modifiers, Modifiers visibility, TextRange span, TextInterval position, bool isStatic)
     : base(name, kind, modifiers, visibility, span, position)
 {
     this.Parent      = null;
     this._parameters = new List <XVariable>();
     this._locals     = new List <XVariable>();
     this._typeName   = "";
     this._isStatic   = isStatic;
 }
Ejemplo n.º 6
0
        public override void EnterClassVarList([NotNull] XSharpParser.ClassVarListContext context)
        {
            XSharpParser.ClassVarListContext current = (XSharpParser.ClassVarListContext)context;
            //
            // structure is:

            /*
             * classvars			: (Attributes=attributes)? (Modifiers=classvarModifiers)? Vars=classVarList eos
             *                  ;
             *
             * classVarList		: Var+=classvar (COMMA Var+=classvar)* (As=(AS | IS) DataType=datatype)?
             *                  ;
             *
             * classvar			: (Dim=DIM)? Id=identifier (LBRKT ArraySub=arraysub RBRKT)? (ASSIGN_OP Initializer=expression)?
             *                  ;
             */
            // we want to include the stop position of the datatype in the classvar
            // so we set the range to the whole classvarlist
            var parent = context.Parent as XSharpParserRuleContext;
            int count, currentVar;

            count      = current._Var.Count;
            currentVar = 0;
            foreach (var varContext in current._Var)
            {
                //
                var mods = _currentVarStatic ? Modifiers.Static : Modifiers.None;
                // when many variables then the first one is from the start of the line until the
                // end of its name, and the others start with the start of their name
                // the last one finishes at the end of the line
                currentVar += 1;
                var start = parent.Start;       // LOCAL keyword or GLOBAL keyword
                var stop  = current.Stop;       // end of this line (datatype clause)
                if (currentVar > 1)
                {
                    start = varContext.Start;
                }
                if (currentVar < count) // end at this variable name
                {
                    stop = varContext.Stop;
                }
                var    interval = new TextInterval(start.StartIndex, stop.StopIndex);
                string typeName = current.DataType != null?current.DataType.GetText() : "USUAL";

                XTypeMember newClassVar = new XTypeMember(varContext.Id.GetText(),
                                                          Kind.Field, mods, this._currentVarVisibility,
                                                          new TextRange(start.Line, start.Column, stop.Line, stop.Column + stop.Text.Length),
                                                          interval, typeName, _currentVarStatic);
                newClassVar.File    = this._file;
                newClassVar.IsArray = varContext.Dim != null;
                //
                bool bAdd = true;
                // Suppress classvars generated by errors in the source
                if (_errors != null)
                {
                    foreach (var err in _errors)
                    {
                        if (err.Span.Start.Line == newClassVar.Range.StartLine - 1)
                        {
                            bAdd = false;
                        }
                    }
                }
                if (bAdd)
                {
                    this._classVars.Add(newClassVar);
                }
            }
        }