コード例 #1
0
ファイル: Parser.cs プロジェクト: mintberry/stackrecaller
        private void ParseFixedBuffer(StructNode st, FixedBufferNode node)
        {
            if (st == null)
            {
                ReportError("fixed buffer authorized only in structure declaration.");
            }

            if (!node.IsUnsafe)
            {
                ReportError("fixed buffer authorized only in unsafe context.");
            }

            if ((node.Modifiers & Modifier.Static) != Modifier.Empty)
            {
                ReportError("fixed buffer can not be declared as static.");
            }

            if ( node.Type is TypePointerNode )
            {
                ReportError("fixed buffer can not be pointer.");
            }
            else
            {
                StringCollection strColl = new StringCollection();
                string type_str = ((TypeNode)node.Type).Identifier.QualifiedIdentifier.ToLower();

                strColl.AddRange(new string[] { "sbyte", "byte", "short", "ushort", "int", "uint", "long", "ulong", "char", "float", "double", "bool" });

                if (!strColl.Contains(type_str))
                {
                    ReportError("fixed buffer element type must be of type sbyte, byte, short, ushort, int, uint, long, ulong, char, float, double or bool.");    
                }
            }
            AssertAndAdvance(TokenID.LBracket);

            ConstantExpression expr = new ConstantExpression(curtok);
            expr.Value = ParseExpression(TokenID.RBracket);
            node.FixedBufferConstants.Add(  expr );

            AssertAndAdvance(TokenID.RBracket);
        }
コード例 #2
0
ファイル: Parser.cs プロジェクト: mintberry/stackrecaller
		private ConstantExpression ParseConstExpr()							
		{
			ConstantExpression node = new ConstantExpression(curtok);
			node.Value = ParseExpression();

			return node;
		}
コード例 #3
0
        public virtual object VisitConstantExpressions(ConstantExpression constantExpression, object data)
        {
            stackMap.Push(constantExpression);
             constantExpression.Value.AcceptVisitor(this, data);

             stackMap.Pop();
             return null;

        }