Ejemplo n.º 1
0
        public Block GetBlock(PartialExpression p, AstExpression e)
        {
            switch (p.ExpressionType)
            {
            case PartialExpressionType.Block:
                return(((PartialBlock)p).Block);

            case PartialExpressionType.Type:
                var cls = ((PartialType)p).Type as ClassType;
                if (cls != null)
                {
                    return(cls.Block);
                }
                break;
            }

            if (!p.IsInvalid)
            {
                Log.Error(e.Source, ErrorCode.E3101, "Expression is <" + p.ExpressionType + "> but is used as a block.");
            }

            return(Block.Invalid);
        }
Ejemplo n.º 2
0
        public DataType GetType(PartialExpression p, AstExpression e)
        {
            if (p.IsInvalid)
            {
                return(DataType.Invalid);
            }

            if (p.ExpressionType == PartialExpressionType.Type)
            {
                var dt = (p as PartialType).Type;

                if (!dt.IsGenericDefinition || e is AstGeneric)
                {
                    return(dt);
                }

                Log.Error(e.Source, ErrorCode.E3131, "Expression is a generic type definition but is used as a type.");
                return(DataType.Invalid);
            }

            Log.Error(e.Source, ErrorCode.E3132, "Expression is <" + p.ExpressionType + "> but is used as a type.");
            return(DataType.Invalid);
        }