Esempio n. 1
0
 //------------------------------------------------------------
 // コンストラクタ。
 public FunctionArgumentDecl(
     TypePath aTypePath
     , Identifier aIdent
     , bool aIsConst
     , bool aIsRef
     , bool aIsIn
     )
 {
     TypePath = aTypePath;
     Ident    = aIdent;
     IsConst  = aIsConst;
     IsRef    = aIsRef;
     IsIn     = aIsIn;
 }
        //------------------------------------------------------------
        // TypeInfoを生成する。
        public TypeInfo CreateTypeInfo(TypePath typePath)
        {
            BuiltInType builtInType = typePath.BuiltInType;

            TypeInfo.TypeKind kind = TypeInfo.TypeKind.VALUE;
            if (builtInType == BuiltInType.Void)
            {
                kind = TypeInfo.TypeKind.UNKNOWN;
            }
            return(new TypeInfo(
                       new TypeInfo.TypeSymbol(builtInType)
                       , kind
                       , new TypeInfo.TypeAttribute(false, false)
                       ));
        }
Esempio n. 3
0
        //------------------------------------------------------------
        /// <summary>
        /// CastExpression:
        ///   "cast" "(" TypePath ")" UnaryExpression
        /// </summary>
        /// <returns></returns>
        IExpression parseCastExpression()
        {
            // "cast"
            System.Diagnostics.Debug.Assert(currentToken().Value == Token.Kind.KeyCast);
            nextToken();

            // "("
            if (!expectToken(Token.Kind.OpLParen, ErrorKind.CAST_EXPRESSION_LPAREN_EXPECTED))
            {
                return(null);
            }

            // TypePath
            TypePath typePath = parseTypePath();

            if (typePath == null)
            {
                return(null);
            }

            // ")"
            if (!expectToken(Token.Kind.OpRParen, ErrorKind.CAST_EXPRESSION_RPAREN_EXPECTED))
            {
                return(null);
            }

            // UnaryExpression
            IExpression expr = parseUnaryExpression();

            if (expr == null)
            {
                return(null);
            }

            return(new CastExpression(typePath, expr));
        }
Esempio n. 4
0
        //------------------------------------------------------------
        /// <summary>
        /// NewExpression:
        ///   "new" TypePath FunctionCallExpression
        /// </summary>
        /// <returns></returns>
        IExpression parseNewExpression()
        {
            // "new"
            System.Diagnostics.Debug.Assert(currentToken().Value == Token.Kind.KeyNew);
            nextToken();

            // TypePath
            TypePath typePath = parseTypePath();

            if (typePath == null)
            {
                return(null);
            }

            // FunctionCallExpression
            FunctionCallExpression funcCallExpr = parseFunctionCallExpression();

            if (funcCallExpr == null)
            {
                return(null);
            }

            return(new NewExpression(typePath, funcCallExpr));
        }
Esempio n. 5
0
 //------------------------------------------------------------
 // コンストラクタ。
 public NewExpression(TypePath aTypePath, FunctionCallExpression aFuncCallExpr)
 {
     mTypePath     = aTypePath;
     mFuncCallExpr = aFuncCallExpr;
 }
Esempio n. 6
0
 //------------------------------------------------------------
 // コンストラクタ。
 public VariableDecl(TypePath aTypePath, Identifier aIdent, IExpression aExpr)
 {
     TypePath = aTypePath;
     Ident    = aIdent;
     Expr     = aExpr;
 }
Esempio n. 7
0
 //------------------------------------------------------------
 // コンストラクタ。
 public CastExpression(TypePath aTypePath, IExpression aExpr)
 {
     mTypePath = aTypePath;
     mExpr     = aExpr;
 }