protected virtual void _visit( JsPreUnaryExpression node )
 {
     throw new NotImplementedException( "JsPreUnaryExpression" );
 }
Example #2
0
        public JsNode ExportInitializer(IMember fieldOrProperty, BlockStatement ccBlock, bool isGlobal, bool isNative = false)
        {
            var initializer = GetCreateInitializer(fieldOrProperty);
            var init2 = AccessSelfFieldOrProperty(fieldOrProperty).Assign(initializer);

            var jsInit = AstNodeConverter.VisitExpression(init2);
            if (isGlobal)
            {
                //danel HACK
                var st = new JsPreUnaryExpression { Operator = "var ", Right = jsInit }.Statement();
                return st;
            }
            else if (isNative)
            {
                var st = jsInit.Statement();
                return st;
            }
            else //clr
            {
                var st = jsInit.Statement();
                return st;
            }
        }
 protected override void _visit(JsPreUnaryExpression node)
 {
     if (node != null)
     {
         visit(node.Right);
     }
 }
        private JsNode Unary(OperatorResolveResult res)
        {
            if (res.UserDefinedOperatorMethod != null && !Sk.UseNativeOperatorOverloads(res.UserDefinedOperatorMethod.DeclaringTypeDefinition))
            {
                var fake = Cs.InvokeMethod(res.UserDefinedOperatorMethod, null, res.Operands[0]);
                return Visit(fake);
            }

            var isProperty = false;
            var meRes = res.Operands[0] as MemberResolveResult;
            if (meRes != null && meRes.Member != null && IsEntityFunctionProperty(meRes.Member, res))
                isProperty = true;

            JsExpression node2;
            if (res.OperatorType.IsAny(ExpressionType.Negate, ExpressionType.PreDecrementAssign, ExpressionType.PreIncrementAssign, ExpressionType.Not, ExpressionType.OnesComplement))
            {
                var simpler = res.OperatorType.ExtractCompoundAssignment();
                if (isProperty && simpler != null)
                {
                    var fakeCs = meRes.ShallowClone().Binary(simpler.Value, Cs.Value(1, Project), meRes.Type);
                    node2 = VisitExpression(fakeCs);
                }
                else
                {
                    node2 = new JsPreUnaryExpression { Operator = Visit(res.OperatorType), Right = VisitExpression(res.Operands[0]) };
                }
            }
            else if (res.OperatorType.IsAny(ExpressionType.PostIncrementAssign, ExpressionType.PostDecrementAssign, ExpressionType.PreIncrementAssign, ExpressionType.PreDecrementAssign))
            {
                if (isProperty)
                {
                    var simpler = res.OperatorType.ExtractCompoundAssignment();
                    var fakeCs = meRes.ShallowClone().Binary(simpler.Value, Cs.Value(1, Project), meRes.Type);
                    node2 = VisitExpression(fakeCs);

                }
                else
                {
                    node2 = new JsPostUnaryExpression { Operator = Visit(res.OperatorType), Left = VisitExpression(res.Operands[0]) };
                }
            }
            else
            {
                throw new NotImplementedException();
            }
            return node2;
        }
Example #5
0
 void _Visit(JsPreUnaryExpression node)
 {
     Control(node.Operator);
     Visit(node.Right);
 }