示例#1
0
		public override void PrintCode (CodeWriter cp)
		{
			if (tryBlock == null) return;
			
			cp.Write ("try {");
			cp.Indent ();
			condition.PrintCode (cp);
			cp.Unindent ();
			foreach (DictionaryEntry de in catchBlocks) {
				CodeVariableDeclaration vd = (CodeVariableDeclaration) de.Key;
				cp.Write ("} catch (");
				if (vd.Variable.Name.Length > 0)
					vd.PrintCode (cp);
				else
					cp.Write (vd.Variable.Type.FullName);
				cp.Write (") {");
				cp.Indent ();
				((CodeBlock) de.Value).PrintCode (cp);
				cp.Unindent ();
			}
			if (!finallyBlock.IsEmpty) {
				cp.Write ("} finally {");
				cp.Indent ();
				finallyBlock.PrintCode (cp);
				cp.Unindent ();
			}
			cp.Write ("}");
		}
示例#2
0
        public override void PrintCode(CodeWriter cp)
        {
            for (int n = 0; n < blocks.Count; n++)
            {
                if (n == 0)
                {
                    cp.Write("if (");
                }
                else
                {
                    cp.Write("else if (");
                }

                ((CodeExpression)conditions[n]).PrintCode(cp);
                cp.Write(") {");
                cp.EndLine();
                cp.Indent();
                ((CodeBlock)blocks[n]).PrintCode(cp);
                cp.Unindent();
                cp.BeginLine().Write("}");
                if (n < blocks.Count - 1)
                {
                    cp.EndLine();
                    cp.BeginLine();
                }
            }
        }
示例#3
0
		public override void PrintCode (CodeWriter cp)
		{
			if (tryBlock == null) return;
			
			cp.Write ("try {");
			cp.Indent ();
			condition.PrintCode (cp);
			cp.Unindent ();
			foreach (DictionaryEntry de in catchBlocks) {
				CodeVariableDeclaration vd = (CodeVariableDeclaration) de.Key;
				cp.Write ("} catch (");
				if (vd.Variable.Name.Length > 0)
					vd.PrintCode (cp);
				else
					cp.Write (vd.Variable.Type.FullName);
				cp.Write (") {");
				cp.Indent ();
				((CodeBlock) de.Value).PrintCode (cp);
				cp.Unindent ();
			}
			if (!finallyBlock.IsEmpty) {
				cp.Write ("} finally {");
				cp.Indent ();
				finallyBlock.PrintCode (cp);
				cp.Unindent ();
			}
			cp.Write ("}");
		}
示例#4
0
 public override void PrintCode(CodeWriter cp)
 {
     cp.Write("foreach (" + itemType + " item in ");
     array.PrintCode(cp);
     cp.Write(") {");
     cp.EndLine();
     cp.Indent();
     forBlock.PrintCode(cp);
     cp.Unindent();
     cp.BeginLine().Write("}");
 }
示例#5
0
 public override void PrintCode(CodeWriter cp)
 {
     cp.Write("while (");
     condition.PrintCode(cp);
     cp.Write(") {");
     cp.EndLine();
     cp.Indent();
     whileBlock.PrintCode(cp);
     cp.Unindent();
     cp.BeginLine().Write("}");
 }
示例#6
0
		public override void PrintCode (CodeWriter cp)
		{
			cp.Write ("while (");
			condition.PrintCode (cp);
			cp.Write (") {");
			cp.EndLine ();
			cp.Indent ();
			whileBlock.PrintCode (cp);
			cp.Unindent ();
			cp.BeginLine ().Write ("}");
		}
示例#7
0
文件: CodeFor.cs 项目: raj581/Marvin
 public override void PrintCode(CodeWriter cp)
 {
     cp.Write("for (");
     initExp.PrintCode(cp);
     cp.Write(";");
     conditionExp.PrintCode(cp);
     cp.Write(";");
     nextExp.PrintCode(cp);
     cp.Write(") {");
     cp.EndLine();
     cp.Indent();
     forBlock.PrintCode(cp);
     cp.Unindent();
     cp.BeginLine().Write("}");
 }
示例#8
0
文件: CodeFor.cs 项目: nlhepler/mono
		public override void PrintCode (CodeWriter cp)
		{
			cp.Write ("for (");
			initExp.PrintCode (cp);
			cp.Write (";");
			conditionExp.PrintCode (cp);
			cp.Write (";");
			nextExp.PrintCode (cp);
			cp.Write (") {");
			cp.EndLine ();
			cp.Indent ();
			forBlock.PrintCode (cp);
			cp.Unindent ();
			cp.BeginLine ().Write ("}");
		}
示例#9
0
 public void PrintCode(CodeWriter cp)
 {
     cp.BeginLine();
     foreach (CodeCustomAttribute a in customAttributes)
     {
         a.PrintCode(cp);
     }
     cp.BeginLine();
     if (IsStatic)
     {
         cp.Write("static ");
     }
     if (IsPublic)
     {
         cp.Write("public ");
     }
     if (returnType != null)
     {
         cp.Write(returnType + " ");
     }
     cp.Write(name);
     if (parameterTypes.Length > 0)
     {
         cp.Write(name + " [");
         for (int n = 0; n < parameterTypes.Length; n++)
         {
             if (n > 0)
             {
                 cp.Write(", ");
             }
             cp.Write(parameterTypes[n] + " arg" + n);
         }
         cp.Write("]");
     }
     cp.Write(" {");
     cp.EndLine();
     cp.Indent();
     cp.WriteLineInd("get {");
     get_builder.PrintCode(cp);
     cp.WriteLineUnind("}");
     cp.WriteLine("set {");
     set_builder.PrintCode(cp);
     cp.WriteLine("}");
     cp.WriteLineUnind("}");
 }
示例#10
0
		public override void PrintCode (CodeWriter cp)
		{
			if (trueBlock == null) return;
			
			cp.Write ("if (");
			condition.PrintCode (cp);
			cp.Write (") {");
			cp.EndLine ();
			cp.Indent ();
			trueBlock.PrintCode (cp);
			cp.Unindent ();
			cp.BeginLine ().Write ("}");
			if (falseBlock != null) {
				cp.EndLine ();
				cp.WriteLineInd ("else {");
				falseBlock.PrintCode (cp);
				cp.Unindent ();
				cp.BeginLine ().Write ("}");
			}
		}
		public override void PrintCode (CodeWriter cp)
		{
			for (int n=0; n<blocks.Count; n++) {
				if (n == 0)
					cp.Write ("if (");
				else
					cp.Write ("else if (");
				
				((CodeExpression)conditions[n]).PrintCode (cp);
				cp.Write (") {");
				cp.EndLine ();
				cp.Indent ();
				((CodeBlock) blocks[n]).PrintCode (cp);
				cp.Unindent ();
				cp.BeginLine ().Write ("}");
				if (n < blocks.Count - 1) {
					cp.EndLine ();
					cp.BeginLine ();
				}
			}
		}
示例#12
0
        public override void PrintCode(CodeWriter cp)
        {
            if (trueBlock == null)
            {
                return;
            }

            cp.Write("if (");
            condition.PrintCode(cp);
            cp.Write(") {");
            cp.EndLine();
            cp.Indent();
            trueBlock.PrintCode(cp);
            cp.Unindent();
            cp.BeginLine().Write("}");
            if (falseBlock != null)
            {
                cp.EndLine();
                cp.WriteLineInd("else {");
                falseBlock.PrintCode(cp);
                cp.Unindent();
                cp.BeginLine().Write("}");
            }
        }
		public void PrintCode (CodeWriter cp)
		{
			cp.BeginLine ();
			foreach (CodeCustomAttribute a in customAttributes)
				a.PrintCode (cp);
			cp.BeginLine ();
			if (IsStatic)
				cp.Write ("static ");
			if (IsPublic)
				cp.Write ("public ");
			if (returnType != null) cp.Write (returnType + " ");
			cp.Write (name);
			if (parameterTypes.Length > 0) {
				cp.Write (name + " [");
				for (int n=0; n<parameterTypes.Length; n++) {
					if (n > 0) cp.Write (", ");
					cp.Write (parameterTypes[n] + " arg" + n);
				}
				cp.Write ("]");
			}
			cp.Write (" {");
			cp.EndLine ();
			cp.Indent ();
			cp.WriteLineInd ("get {");
			get_builder.PrintCode (cp);
			cp.WriteLineUnind ("}");
			cp.WriteLine ("set {");
			set_builder.PrintCode (cp);
			cp.WriteLine ("}");
			cp.WriteLineUnind ("}");
		}
示例#14
0
		public override void PrintCode (CodeWriter cp)
		{
			cp.Write ("foreach (" + itemType + " item in ");
			array.PrintCode (cp);
			cp.Write (") {");
			cp.EndLine ();
			cp.Indent ();
			forBlock.PrintCode (cp);
			cp.Unindent ();
			cp.BeginLine ().Write ("}");
		}