public static ArrayType GetStringType(ResolutionContext ctxt, LiteralSubformat fmt = LiteralSubformat.Utf8)
		{
			ArrayType _t = null;

			if (ctxt != null && ctxt.ScopedBlock != null)
			{
				var obj = ctxt.ParseCache.LookupModuleName(ctxt.ScopedBlock.NodeRoot as DModule, "object").FirstOrDefault();

				if (obj != null)
				{
					string strType = fmt == LiteralSubformat.Utf32 ? "dstring" :
						fmt == LiteralSubformat.Utf16 ? "wstring" :
						"string";

					var strNode = obj[strType];

					if (strNode != null)
						foreach (var n in strNode) {
							_t = TypeDeclarationResolver.HandleNodeMatch(n, ctxt) as ArrayType;
							if (_t != null)
								break;
						}
				}
			}

			if (_t == null)
			{
				var ch = fmt == LiteralSubformat.Utf32 ? DTokens.Dchar :
					fmt == LiteralSubformat.Utf16 ? DTokens.Wchar : DTokens.Char;

				_t = new ArrayType(new PrimitiveType(ch, DTokens.Immutable));
			}

			return _t;
		}
Exemple #2
0
 public IdentifierExpression(string Value, LiteralFormat LiteralFormat = LiteralFormat.None, LiteralSubformat Subformat = 0)
 {
     Strings.Add(Value);
     ValueStringHash = Value.GetHashCode();
     this.Format     = LiteralFormat;
     this.Subformat  = Subformat;
 }
        public static ArrayType GetStringType(ResolverContextStack ctxt, LiteralSubformat fmt = LiteralSubformat.Utf8)
        {
            ArrayType _t = null;

            if (ctxt != null)
            {
                var obj = ctxt.ParseCache.LookupModuleName("object").First();

                string strType = fmt == LiteralSubformat.Utf32 ? "dstring" :
                    fmt == LiteralSubformat.Utf16 ? "wstring" :
                    "string";

                var strNode = obj[strType];

                if(strNode!=null && strNode.Count != 0)
                    _t = DResolver.StripAliasSymbol(TypeDeclarationResolver.HandleNodeMatch(strNode[0], ctxt)) as ArrayType;
            }

            if (_t == null)
            {
                var ch = fmt == LiteralSubformat.Utf32 ? DTokens.Dchar :
                    fmt == LiteralSubformat.Utf16 ? DTokens.Wchar : DTokens.Char;

                _t = new ArrayType(new PrimitiveType(ch, DTokens.Immutable),
                    new ArrayDecl
                    {
                        ValueType = new MemberFunctionAttributeDecl(DTokens.Immutable)
                        {
                            InnerType = new DTokenDeclaration(ch)
                        }
                    });
            }

            return _t;
        }
Exemple #4
0
 public IdentifierExpression(object Val, LiteralFormat LiteralFormat, LiteralSubformat Subformat = 0, string escapeString = null)
 {
     Value          = Val;
     this.Format    = LiteralFormat;
     this.Subformat = Subformat;
     if (escapeString != null)
     {
         Strings.Add(escapeString);
         EscapeStringHash = escapeString.GetHashCode();
     }
 }
 /// <summary>
 /// String constructor.
 /// Given result stores both type and idenfitierexpression whose Value is used as content
 /// </summary>
 public ArrayValue(ArrayType stringLiteralResult, IdentifierExpression stringLiteral = null)
     : base(stringLiteralResult)
 {
     StringFormat = LiteralSubformat.Utf8;
     if (stringLiteralResult.DeclarationOrExpressionBase is IdentifierExpression)
     {
         StringFormat = ((IdentifierExpression)stringLiteralResult.DeclarationOrExpressionBase).Subformat;
         StringValue = ((IdentifierExpression)stringLiteralResult.DeclarationOrExpressionBase).StringValue;
     }
     else
         StringValue = stringLiteral.StringValue;
 }
Exemple #6
0
        public DToken(int kind, int startLocation_Col, int startLocation_Line, int endLocation_Col, int endLocation_Line,
                      object literalValue, string value, LiteralFormat literalFormat = 0, LiteralSubformat literalSubFormat = 0)
        {
            Line        = startLocation_Line;
            Location    = new CodeLocation(startLocation_Col, startLocation_Line);
            EndLocation = new CodeLocation(endLocation_Col, endLocation_Line);

            Kind          = kind;
            LiteralFormat = literalFormat;
            Subformat     = literalSubFormat;
            LiteralValue  = literalValue;
            Value         = value;
        }
Exemple #7
0
 /// <summary>
 /// String constructor.
 /// Given result stores both type and idenfitierexpression whose Value is used as content
 /// </summary>
 public ArrayValue(ArrayType stringLiteralResult, IdentifierExpression stringLiteral = null)
     : base(stringLiteralResult)
 {
     StringFormat = LiteralSubformat.Utf8;
     if (stringLiteralResult.DeclarationOrExpressionBase is IdentifierExpression)
     {
         StringFormat = ((IdentifierExpression)stringLiteralResult.DeclarationOrExpressionBase).Subformat;
         StringValue  = ((IdentifierExpression)stringLiteralResult.DeclarationOrExpressionBase).StringValue;
     }
     else
     {
         StringValue = stringLiteral.StringValue;
     }
 }
        public static ArrayType GetStringType(ResolutionContext ctxt, LiteralSubformat fmt = LiteralSubformat.Utf8)
        {
            ArrayType _t = null;

            if (ctxt != null)
            {
                var obj = ctxt.ParseCache.LookupModuleName("object").FirstOrDefault();

                if (obj != null)
                {
                    string strType = fmt == LiteralSubformat.Utf32 ? "dstring" :
                                     fmt == LiteralSubformat.Utf16 ? "wstring" :
                                     "string";

                    var strNode = obj[strType];

                    if (strNode != null)
                    {
                        foreach (var n in strNode)
                        {
                            _t = DResolver.StripAliasSymbol(TypeDeclarationResolver.HandleNodeMatch(n, ctxt)) as ArrayType;
                            if (_t != null)
                            {
                                break;
                            }
                        }
                    }
                }
            }

            if (_t == null)
            {
                var ch = fmt == LiteralSubformat.Utf32 ? DTokens.Dchar :
                         fmt == LiteralSubformat.Utf16 ? DTokens.Wchar : DTokens.Char;

                _t = new ArrayType(new PrimitiveType(ch, DTokens.Immutable),
                                   new ArrayDecl
                {
                    ValueType = new MemberFunctionAttributeDecl(DTokens.Immutable)
                    {
                        InnerType = new DTokenDeclaration(ch)
                    }
                });
            }

            return(_t);
        }
Exemple #9
0
		DToken Token(byte kind, int startLocation_Col, int startLocation_Line, int tokenLength,
			object literalValue,/* string value,*/ LiteralFormat literalFormat = 0, LiteralSubformat literalSubFormat = 0)
		{
			var tk = tok();
			tk.Line = startLocation_Line;
			tk.Column = startLocation_Col;
			tk.EndLineDifference = 0;
			tk.EndColumn = unchecked(startLocation_Col + tokenLength);

			tk.Kind = kind;
			tk.LiteralFormat = literalFormat;
			tk.Subformat = literalSubFormat;
			tk.LiteralValue = literalValue;
			tk.RawCodeRepresentation = null;
			
			return tk;
		}
 ArrayType GetStringType(LiteralSubformat fmt = LiteralSubformat.Utf8)
 {
     return(Evaluation.GetStringType(ctxt, fmt));
 }
		ArrayType GetStringType(LiteralSubformat fmt = LiteralSubformat.Utf8)
		{
			return GetStringType(ctxt, fmt);
		}
Exemple #12
0
        public DToken(int kind, CodeLocation startLocation, CodeLocation endLocation, string val, object literalValue, 
			LiteralFormat literalFormat,
			LiteralSubformat Subformat=0)
        {
            this.Kind = kind;
            this.col = startLocation.Column;
            this.line = startLocation.Line;
            this.endLocation = endLocation;
            this.val = val;
            this.literalValue = literalValue;
            this.literalFormat = literalFormat;
            this.Subformat = Subformat;
        }
Exemple #13
0
		void TryReadExplicitStringFormat(out LiteralSubformat subFmt)
		{
			switch ((char)this.ReaderPeek ()) {
				case 'c':
					ReaderRead ();
					break;
				case 'd':
					subFmt = LiteralSubformat.Utf32;
					ReaderRead ();
					return;
				case 'w':
					subFmt = LiteralSubformat.Utf16;
					ReaderRead ();
					return;
			}

			subFmt = LiteralSubformat.Utf8;
		}
Exemple #14
0
 public IdentifierExpression(object Val, LiteralFormat LiteralFormat, LiteralSubformat Subformat = 0)
 {
     Value          = Val;
     this.Format    = LiteralFormat;
     this.Subformat = Subformat;
 }
Exemple #15
0
		DToken Token(byte kind, int startLocation_Col, int startLocation_Line, int endLocation_Col, int endLocation_Line,
			object literalValue,/* string value,*/ LiteralFormat literalFormat = 0, LiteralSubformat literalSubFormat = 0, string rawCode = null)
		{
			var tk = tok();
			tk.Line = startLocation_Line;
			tk.Column = startLocation_Col;
			
			tk.EndLineDifference = (ushort)unchecked(endLocation_Line-startLocation_Line);
			tk.EndColumn = endLocation_Col;
			
			tk.Kind = kind;
			tk.LiteralFormat = literalFormat;
			tk.Subformat = literalSubFormat;
			tk.LiteralValue = literalValue;
			tk.RawCodeRepresentation = rawCode;
			
			return tk;
		}
Exemple #16
0
 /// <summary>
 /// String constructor.
 /// Used for generating string results 'internally'.
 /// </summary>
 public ArrayValue(ArrayType stringTypeResult, string content) : base(stringTypeResult)
 {
     StringFormat = LiteralSubformat.Utf8;
     StringValue  = content;
 }
Exemple #17
0
 /// <summary>
 /// String constructor.
 /// Used for generating string results 'internally'.
 /// </summary>
 public ArrayValue(ArrayType stringTypeResult, IExpression baseExpression, string content)
     : base(ExpressionValueType.Array, stringTypeResult, baseExpression)
 {
     StringFormat = LiteralSubformat.Utf8;
     StringValue  = content;
 }
 /// <summary>
 /// String constructor.
 /// Used for generating string results 'internally'.
 /// </summary>
 public ArrayValue(ArrayType stringTypeResult, string content)
     : base(stringTypeResult)
 {
     StringFormat = LiteralSubformat.Utf8;
     StringValue = content;
 }
Exemple #19
0
 public DToken(int kind, int x, int y, string val, object literalValue, LiteralFormat literalFormat, LiteralSubformat Subformat=0)
     : this(kind, new CodeLocation(x, y), new CodeLocation(x + val.Length, y), val, literalValue, literalFormat, Subformat)
 {
 }