Set() private method

private Set ( Decoration decoration ) : VisitorArgument
decoration Decoration
return VisitorArgument
 public override bool Visit(
     UnifiedBinaryExpression element, VisitorArgument arg)
 {
     var paren = GetRequiredParen(element);
     Writer.Write(paren.Item1);
     element.LeftHandSide.TryAccept(this, arg.Set(Paren));
     Writer.Write(" ");
     element.Operator.TryAccept(this, arg);
     Writer.Write(" ");
     element.RightHandSide.TryAccept(this, arg.Set(Paren));
     Writer.Write(paren.Item2);
     return false;
 }
 public override bool Visit(
     UnifiedTernaryExpression element, VisitorArgument arg)
 {
     var paren = GetRequiredParen(element);
     Writer.Write(paren.Item1);
     element.Condition.TryAccept(this, arg.Set(Paren));
     Writer.Write(" ? ");
     element.TrueExpression.TryAccept(this, arg.Set(Paren));
     Writer.Write(" : ");
     element.FalseExpression.TryAccept(this, arg.Set(Paren));
     Writer.Write(paren.Item2);
     return false;
 }
 //配列orオブジェクトのインスタンス化式
 public override bool Visit(UnifiedNew element, VisitorArgument arg)
 {
     //配列 : e.g. var a = [1, 2, 3] の [1, 2, 3];
     if (element.InitialValue != null) {
         element.InitialValue.TryAccept(this, arg.Set(Brace));
         return true;
     }
     //オブジェクト : e.g. var a = new X();
     Writer.Write("new ");
     element.Target.TryAccept(this, arg);
     element.Arguments.TryAccept(this, arg.Set(Paren));
     return true;
 }
 // e.g. (Int)a  or (int)(a + b)
 public override bool Visit(UnifiedCast element, VisitorArgument arg)
 {
     Writer.Write("(");
     element.Type.TryAccept(this, arg);
     Writer.Write(")");
     element.Expression.TryAccept(this, arg.Set(Paren));
     return false;
 }
 //キャスト式
 public override bool Visit(UnifiedCast element, VisitorArgument arg)
 {
     Writer.Write("(");
     element.Type.TryAccept(this, arg);
     Writer.Write(")");
     //TODO ここのarg.Set(Paren)が不要な気がするので、後ではずしてテストしてみる
     element.Expression.TryAccept(this, arg.Set(Paren));
     return true;
 }
Exemplo n.º 6
0
 public override bool Visit(
     UnifiedNamespaceDefinition element, VisitorArgument arg)
 {
     element.Annotations.TryAccept(this, arg);
     Writer.Write("namespace ");
     element.Name.Accept(this, arg);
     Writer.Write(" ");
     element.Body.Accept(this, arg.Set(ForBlock));
     return false;
 }
        // enum定義(UnifiedEnumDefinition)
        public override bool Visit(
				UnifiedEnumDefinition element, VisitorArgument arg)
        {
            // enum COLOR {RED, BLUE, YELLOW};
            element.Modifiers.TryAccept(this, arg);
            Writer.Write("enum ");
            element.Name.TryAccept(this, arg);
            Writer.Write(" ");
            element.Body.TryAccept(this, arg.Set(ForBlock));
            return true;
        }
 // e.g. (Int)a  or (int)(a + b)
 public override bool Visit(UnifiedCast element, VisitorArgument arg)
 {
     // ((TestCase)(test)).setName(name); などに対応するため括弧を出力
     Writer.Write("(");
     Writer.Write("(");
     element.Type.TryAccept(this, arg);
     Writer.Write(")");
     element.Expression.TryAccept(this, arg.Set(Paren));
     Writer.Write(")");
     return true;
 }
        // 関数定義(UnifiedFunctionDefinition)
        public override bool Visit(
				UnifiedFunctionDefinition element, VisitorArgument arg)
        {
            // int main(int param) { ... };
            element.Modifiers.TryAccept(this, arg);
            element.Type.TryAccept(this, arg);
            Writer.Write(" ");
            element.Name.TryAccept(this, arg);
            element.Parameters.TryAccept(this, arg);
            element.Body.TryAccept(this, arg.Set(ForBlock));
            return element.Body == null;
        }
Exemplo n.º 10
0
 public override bool Visit(
     UnifiedFunctionDefinition element, VisitorArgument arg)
 {
     element.Annotations.TryAccept(this, arg);
     element.Modifiers.TryAccept(this, arg);
     element.Type.TryAccept(this, arg);
     Writer.Write(" ");
     element.Name.TryAccept(this, arg);
     element.GenericParameters.TryAccept(this, arg);
     element.Parameters.TryAccept(this, arg);
     element.Throws.TryAccept(this, arg);
     element.Body.TryAccept(this, arg.Set(ForBlock));
     return element.Body == null;
 }
 // If文(UnifiedIf)
 public override bool Visit(UnifiedIf element, VisitorArgument arg)
 {
     Writer.Write("if (");
     element.Condition.TryAccept(this, arg);
     Writer.Write(")");
     element.Body.TryAccept(this, arg.Set(ForBlock));
     if (element.ElseBody != null) {
         Writer.WriteLine(); //if(cond){ }の後の改行
         WriteIndent(arg);
         Writer.Write("else");
         element.ElseBody.TryAccept(this, arg.Set(ForBlock));
     }
     return false;
 }
        // 関数呼び出し(UnifiedCall)
        public override bool Visit(UnifiedCall element, VisitorArgument arg)
        {
            var prop = element.Function as UnifiedProperty;

            // TODO これに該当するケースがあるか調べる
            if (prop != null) {
                prop.Owner.TryAccept(this, arg);
                Writer.Write(prop.Delimiter);
                prop.Name.TryAccept(this, arg);
            } else {
                element.Function.TryAccept(this, arg);
            }
            element.Arguments.TryAccept(this, arg.Set(Paren));
            return true;
        }
 //関数呼び出し
 public override bool Visit(UnifiedCall element, VisitorArgument arg)
 {
     //JavaScriptではTypeArgumentsが存在しない
     var prop = element.Function as UnifiedProperty;
     //呼び出し式がプロパティの場合
     if (prop != null) {
         prop.Owner.TryAccept(this, arg);
         Writer.Write(prop.Delimiter);
         prop.Name.TryAccept(this, arg);
     } else {
         element.Function.TryAccept(this, arg);
     }
     element.Arguments.TryAccept(this, arg.Set(Paren));
     return true;
 }
        public override bool Visit(UnifiedFor element, VisitorArgument arg)
        {
            Writer.Write("for(");
            element.Initializer.TryAccept(this, arg.Set(CommaDelimiter));
            Writer.Write("; ");
            element.Condition.TryAccept(this, arg.Set(CommaDelimiter));
            Writer.Write(";");
            element.Step.TryAccept(this, arg.Set(CommaDelimiter));
            Writer.Write(")");

            element.Body.TryAccept(this, arg.Set(ForBlock));
            return false;
        }
 public override bool Visit(
         UnifiedStaticInitializer element, VisitorArgument arg)
 {
     Writer.Write("static ");
     element.Body.TryAccept(this, arg.Set(ForBlock));
     return false;
 }
 public override bool Visit(
         UnifiedInstanceInitializer element, VisitorArgument arg)
 {
     element.Body.TryAccept(this, arg.Set(ForBlock));
     return false;
 }
 public override bool Visit(
         UnifiedConstructor element, VisitorArgument arg)
 {
     element.Modifiers.TryAccept(this, arg);
     element.GenericParameters.TryAccept(this, arg);
     var p = element.Ancestors<UnifiedClassLikeDefinition>().First();
     p.Name.Accept(this, arg);
     element.Parameters.TryAccept(this, arg);
     element.Throws.TryAccept(this, arg);
     element.Body.TryAccept(this, arg.Set(ForBlock));
     return false;
 }
 public override bool Visit(UnifiedProgram element, VisitorArgument arg)
 {
     element.Body.TryAccept(this, arg.Set(ForTopBlock));
     return false;
 }
 // e.g. try{...}catch(E e){...}finally{...}
 public override bool Visit(UnifiedTry element, VisitorArgument arg)
 {
     Writer.Write("try");
     element.Body.TryAccept(this, arg.Set(ForBlock));
     element.Catches.TryAccept(this, arg);
     element.FinallyBody.TryAccept(this, arg, "finally");
     return false;
 }
 // e.g. catch(Exception e){...}
 public override bool Visit(UnifiedCatch element, VisitorArgument arg)
 {
     Writer.Write("catch(");
     element.Annotations.TryAccept(this, arg);
     element.Modifiers.TryAccept(this, arg);
     element.Types.FirstOrDefault().TryAccept(this, arg);
     Writer.Write(" ");
     element.Assign.TryAccept(this, arg);
     Writer.Write(")");
     element.Body.TryAccept(this, arg.Set(ForBlock));
     return false;
 }
 public override bool Visit(UnifiedIf ifStatement, VisitorArgument arg)
 {
     Writer.Write("if (");
     ifStatement.Condition.TryAccept(this, arg);
     Writer.Write(")");
     ifStatement.Body.TryAccept(this, arg.Set(ForBlock));
     ifStatement.ElseBody.TryAccept(
             this, arg.Set(ForBlock), GetIndent(arg) + "else");
     return false;
 }
 public override bool Visit(UnifiedCase element, VisitorArgument arg)
 {
     if (element.Condition == null) {
         Writer.Write("default:\n");
     } else {
         Writer.Write("case ");
         element.Condition.TryAccept(this, arg);
         Writer.Write(":\n");
     }
     element.Body.TryAccept(this, arg.Set(ForBlock));
     return false;
 }
 public override bool Visit(UnifiedIndexer element, VisitorArgument arg)
 {
     element.Target.TryAccept(this, arg);
     element.Arguments.TryAccept(this, arg.Set(Bracket));
     return false;
 }
        public override bool Visit(UnifiedForeach element, VisitorArgument arg)
        {
            Writer.Write(ForeachKeyword);
            Writer.Write("(");
            element.Element.TryAccept(this, arg);
            Writer.Write(ForeachDelimiter);
            element.Set.TryAccept(this, arg.Set(CommaDelimiter));
            Writer.Write(")");

            element.Body.TryAccept(this, arg.Set(ForBlock));
            return false;
        }
 public override bool Visit(UnifiedDoWhile element, VisitorArgument arg)
 {
     Writer.Write("do");
     element.Body.TryAccept(this, arg.Set(ForBlock));
     WriteIndent(arg);
     Writer.Write("while(");
     element.Condition.TryAccept(this, arg);
     Writer.Write(");");
     return false;
 }
 //TODO 辞書リテラル : JavaScriptでは出現しない?
 public override bool Visit(
         UnifiedMapLiteral element, VisitorArgument arg)
 {
     Writer.Write("{");
     VisitCollection(element, arg.Set(CommaDelimiter));
     WriteIndent(arg.IndentDepth);
     Writer.Write("}");
     return false;
 }
 public override bool Visit(
         UnifiedGenericArgument element, VisitorArgument arg)
 {
     element.Modifiers.TryAccept(this, arg);
     element.Value.TryAccept(this, arg);
     element.Constrains.TryAccept(this, arg.Set(AndDelimiter));
     return false;
 }
 public override bool Visit(
         UnifiedParameter element, VisitorArgument arg)
 {
     element.Annotations.TryAccept(this, arg);
     var isVariableLength = false;
     if (!element.Modifiers.IsEmptyOrNull()) {
         var newModifiers = element.Modifiers.DeepCopy();
         isVariableLength = newModifiers.Remove(m => m.Name == "...");
         newModifiers.TryAccept(this, arg);
     }
     element.Type.TryAccept(this, arg);
     Writer.Write(" ");
     if (isVariableLength) {
         Writer.Write("... ");
     }
     element.Names.TryAccept(this, arg.Set(CommaDelimiter));
     return false;
 }
 protected bool Visit(
         UnifiedClassLikeDefinition element, VisitorArgument arg,
         string keyword)
 {
     element.Annotations.TryAccept(this, arg);
     element.Modifiers.TryAccept(this, arg);
     Writer.Write(keyword + " ");
     element.Name.TryAccept(this, arg);
     element.GenericParameters.TryAccept(this, arg);
     element.Constrains.TryAccept(this, arg.Set(CommaDelimiter));
     element.Body.TryAccept(this, arg.Set(ForBlock));
     return false;
 }
 public override bool Visit(
         UnifiedSynchronized element, VisitorArgument arg)
 {
     WriteIndent(arg);
     Writer.Write("synchronized (");
     element.Value.TryAccept(this, arg);
     Writer.Write(")");
     element.Body.TryAccept(this, arg.Set(ForBlock));
     return false;
 }