Ejemplo n.º 1
0
        internal Expression(IExpressionInfo info)
            : base(info.Context)
        {
            Location = info.Location;
            Kind     = info.Kind;
            Type     = info.Type;

            if (Type.Type is null)
            {
                Type = NullType.Create(cx);
            }

            cx.Emit(Tuples.expressions(this, Kind, Type.Type.TypeRef));
            if (info.Parent.IsTopLevelParent)
            {
                cx.Emit(Tuples.expr_parent_top_level(this, info.Child, info.Parent));
            }
            else
            {
                cx.Emit(Tuples.expr_parent(this, info.Child, info.Parent));
            }
            cx.Emit(Tuples.expr_location(this, Location));

            if (info.IsCompilerGenerated)
            {
                cx.Emit(Tuples.expr_compiler_generated(this));
            }

            if (info.ExprValue is string value)
            {
                cx.Emit(Tuples.expr_value(this, value));
            }

            Type.Type.ExtractGenerics();
        }
Ejemplo n.º 2
0
        Expr *new_expr(ExprKind kind, SrcPos pos)
        {
            var e = (Expr *)ast_alloc(sizeof(Expr));

            e->pos  = pos;
            e->kind = kind;
            return(e);
        }
Ejemplo n.º 3
0
        Expr new_expr(ExprKind kind, SrcPos pos)
        {
            var e = new Expr();

            e.pos  = pos;
            e.kind = kind;
            return(e);
        }
Ejemplo n.º 4
0
        internal Expression(IExpressionInfo info)
            : base(info.Context)
        {
            this.info = info;
            Location  = info.Location;
            Kind      = info.Kind;
            Type      = info.Type;

            TryPopulate();
        }
Ejemplo n.º 5
0
 public ExpressionInfo(Context cx, AnnotatedType type, Extraction.Entities.Location location, ExprKind kind, IExpressionParentEntity parent, int child, bool isCompilerGenerated, string value)
 {
     Context             = cx;
     Type                = type;
     Location            = location;
     Kind                = kind;
     Parent              = parent;
     Child               = child;
     ExprValue           = value;
     IsCompilerGenerated = isCompilerGenerated;
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Adjust the expression kind <paramref name="k"/> to match this call type.
        /// </summary>
        public static ExprKind AdjustKind(this Expression.CallType ct, ExprKind k)
        {
            switch (ct)
            {
            case Expression.CallType.Dynamic:
            case Expression.CallType.UserOperator:
                return(ExprKind.OPERATOR_INVOCATION);

            default:
                return(k);
            }
        }
Ejemplo n.º 7
0
        internal Expression(IExpressionInfo info, bool shouldPopulate = true)
            : base(info.Context)
        {
            this.info = info;
            Location  = info.Location;
            Kind      = info.Kind;
            Type      = info.Type;

            if (shouldPopulate)
            {
                TryPopulate();
            }
        }
Ejemplo n.º 8
0
        internal Expression(IExpressionInfo info)
            : base(info.Context)
        {
            this.info = info;
            Location  = info.Location;
            Kind      = info.Kind;
            Type      = info.Type;
            if (Type.Type is null)
            {
                Type = NullType.Create(cx);
            }

            TryPopulate();
        }
Ejemplo n.º 9
0
 public ExpressionNodeInfo SetKind(ExprKind kind)
 {
     Kind = kind;
     return(this);
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Adapt the operator kind depending on whether it's a dynamic call or a user-operator call.
 /// </summary>
 /// <param name="cx"></param>
 /// <param name="node"></param>
 /// <param name="originalKind"></param>
 /// <returns></returns>
 public static ExprKind UnaryOperatorKind(Context cx, ExprKind originalKind, ExpressionSyntax node) =>
 GetCallType(cx, node).AdjustKind(originalKind);
Ejemplo n.º 11
0
 internal static void expressions(this TextWriter trapFile, Expression expr, ExprKind kind, Type exprType)
 {
     trapFile.WriteTuple("expressions", expr, (int)kind, exprType);
 }
Ejemplo n.º 12
0
 internal static Tuple expressions(Expression expr, ExprKind kind, Type exprType) => new Tuple("expressions", expr, kind, exprType);
Ejemplo n.º 13
0
 PostfixUnary(ExpressionNodeInfo info, ExprKind kind, ExpressionSyntax operand)
     : base(info.SetKind(UnaryOperatorKind(info.Context, kind, info.Node)))
 {
     Operand      = operand;
     OperatorKind = kind;
 }
Ejemplo n.º 14
0
 Unary(ExpressionNodeInfo info, ExprKind kind)
     : base(info.SetKind(UnaryOperatorKind(info.Context, info.Kind, info.Node)))
 {
     OperatorKind = kind;
 }
Ejemplo n.º 15
0
 public Expression(AbstractNode lhs, ExprKind kind, AbstractNode rhs)
 {
     adoptChildren(lhs);
     adoptChildren(rhs);
     exprKind = kind;
 }
Ejemplo n.º 16
0
 public Expression(AbstractNode expr, ExprKind kind)
 {
     adoptChildren(expr);
     exprKind = kind;
 }