private static void WriteArrayCreate(LanguageWriter w, IArrayCreateExpression exp) { w.WriteKeyword("gcnew"); w.Write(" "); w.WriteKeyword("array"); w.Write("<"); new TypeRef(exp.Type).WriteNameWithRef(w); if (exp.Dimensions != null && exp.Dimensions.Count > 1) { w.Write(", "); w.WriteAsLiteral(exp.Dimensions.Count); } w.Write(">"); // 要素数の指定 if (exp.Dimensions != null) { w.Write("("); w.WriteExpressionCollection(exp.Dimensions); w.Write(")"); } // {a, b, ... 要素の指定} IBlockExpression initializer = exp.Initializer; if (initializer != null) { WriteBlock(w, initializer); } }
private static void WriteDo(LanguageWriter w, IDoStatement state) { w.WriteKeyword("do"); w.PushScope(); w.Write(" {"); w.WriteLine(); w.WriteIndent(); if (state.Body != null) { WriteBlock(w, state.Body); } w.WriteOutdent(); w.Write("} "); w.PopScope(); w.WriteKeyword("while"); w.Write("("); if (state.Condition != null) { w.SkipWriteLine = true; ExpressionWriter.WriteExpression(w, state.Condition, false); w.SkipWriteLine = false; } w.Write(");"); w.WriteLine(); }
private void WriteForAsmOrModule() { foreach (AttrPair pair in attrs) { if (attr_proc != null && !attr_proc(pair.Key, pair.Value)) { continue; } ICustomAttribute attr = pair.Value; writer.Write("["); writer.WriteKeyword(attr_class); writer.Write(": "); this.WriteCustomAttribute(attr); writer.Write("]"); writer.WriteLine(); } }
private static void WriteTryCast(LanguageWriter w, ITryCastExpression exp) { w.WriteKeyword("dynamic_cast"); w.Write("<"); new TypeRef(exp.TargetType).WriteNameWithRef(w); w.Write(">("); WriteExpression(w, exp.Expression, false); w.Write(")"); }
private static void WriteCondition(LanguageWriter w, IConditionStatement state) { #if EXTRA_TEMP using (NewBlock block3 = new NewBlock(w)) { w.WriteKeyword("if"); w.Write(" "); w.Write("("); ExpressionWriter.WriteExpression(w, state.Condition, false); w.Write(") "); using (NewBlock block2 = new NewBlock(w)) { WriteBracedStatement(w, state.Then); if (!IsBlank(state.Else)) { using (NewBlock block = new NewBlock(w)) { w.Write(" "); w.WriteKeyword("else"); w.Write(" "); WriteBracedStatement(w, state.Else); } } w.WriteLine(); } } #else w.WriteKeyword("if"); w.Write(" "); w.Write("("); ExpressionWriter.WriteExpression(w, state.Condition, false); w.Write(") "); WriteBracedStatement(w, state.Then); if (!IsBlank(state.Else)) { w.Write(" "); w.WriteKeyword("else"); w.Write(" "); WriteBracedStatement(w, state.Else); } w.WriteLine(); #endif }
private static void WriteMethodReturn(LanguageWriter w, IMethodReturnStatement state) { w.WriteKeyword("return"); if (state.Expression != null) { w.Write(" "); ExpressionWriter.WriteExpression(w, state.Expression, false); } w.Write(";"); w.WriteLine(); }
private static void WriteThrowException(LanguageWriter w, IThrowExceptionStatement state) { w.WriteKeyword("throw"); if (state.Expression != null) { w.Write(" "); ExpressionWriter.WriteExpression(w, state.Expression, false); } w.Write(";"); w.WriteLine(); }
private static void WriteSwitch(LanguageWriter w, ISwitchStatement state) { w.WriteKeyword("switch"); w.Write(" ("); ExpressionWriter.WriteExpression(w, state.Expression, false); w.Write(") {"); w.WriteLine(); w.WriteIndent(); foreach (ISwitchCase _case in state.Cases) { IConditionCase case1 = _case as IConditionCase; if (case1 != null) { WriteSwitch_case(w, case1.Condition); w.WriteIndent(); if (case1.Body != null) { WriteStatement(w, case1.Body); } w.WriteOutdent(); } IDefaultCase case2 = _case as IDefaultCase; if (case2 != null) { w.WriteKeyword("default"); w.Write(":"); w.WriteLine(); w.WriteIndent(); if (case2.Body != null) { WriteStatement(w, case2.Body); } w.WriteOutdent(); //this.Write("}"); //this.WriteLine(); } } w.WriteOutdent(); w.Write("}"); w.WriteLine(); }
private static void WriteCanCast(LanguageWriter w, ICanCastExpression exp) { w.WriteKeyword("dynamic_cast"); w.Write("<"); new TypeRef(exp.TargetType).WriteNameWithRef(w); w.Write(">"); w.Write("("); WriteExpression(w, exp.Expression, false); w.Write(")"); w.Write(" != "); w.WriteLiteral("nullptr"); }
private static void WriteDelegateCreate(LanguageWriter w, IDelegateCreateExpression exp) { w.WriteKeyword("gcnew"); w.Write(" "); new TypeRef(exp.DelegateType).WriteName(w); w.Write("("); WriteExpression(w, exp.Target, false); w.Write(", &"); WriteTypeReference(w, (ITypeReference)exp.Method.DeclaringType); w.Write("::"); w.WriteMethodReference(exp.Method); w.Write(")"); }
private static void WriteForEach(LanguageWriter w, IForEachStatement state) { w.PushScope(); w.WriteKeyword("for each"); w.Write(" ("); ExpressionWriter.WriteVariableDeclaration(w, state.Variable); w.Write(" "); w.WriteKeyword("in"); w.Write(" "); w.SkipWriteLine = true; ExpressionWriter.WriteExpression(w, state.Expression, false); w.SkipWriteLine = false; w.Write(") {"); w.WriteLine(); w.WriteIndent(); if (state.Body != null) { WriteBlock(w, state.Body); } w.WriteOutdent(); w.Write("}"); w.WriteLine(); w.PopScope(); }
//=========================================================== // 追加 //=========================================================== private static void WriteStackAllocate(LanguageWriter w, IStackAllocateExpression exp) { TypeRef type = new TypeRef(exp.Type); w.Write("("); type.WriteNameWithRef(w); w.Write("*)::"); w.WriteReference("_alloca", "Crt 関数 #include <malloc.h>", null); w.Write("("); w.WriteKeyword("sizeof"); w.Write("("); type.WriteName(w); w.Write(")*"); WriteExpression(w, exp.Expression, PREC_BI_MUL > GetExpressionPrecedence(exp.Expression)); w.Write(")"); }
private static void WriteFixed(LanguageWriter w, IFixedStatement state) { w.Write("{"); w.WriteIndent(); w.WriteLine(); w.scope.RegisterVariable(state.Variable, false); w.WriteKeyword("pin_ptr"); w.Write("<"); new TypeRef(((IPointerType)state.Variable.VariableType).ElementType).WriteNameWithRef(w); w.Write("> "); w.WriteDeclaration(state.Variable.Name); w.Write(" = "); ExpressionWriter.WriteExpression(w, state.Expression, false); WriteBlock(w, state.Body); w.WriteOutdent(); w.Write("}"); }
private static void WriteSwitch_case(LanguageWriter w, IExpression con_case) { IBinaryExpression exp_bi = con_case as IBinaryExpression; if (exp_bi != null) { if (exp_bi.Operator == BinaryOperator.BooleanOr) { WriteSwitch_case(w, exp_bi.Left); WriteSwitch_case(w, exp_bi.Right); return; } } w.WriteKeyword("case"); w.Write(" "); ExpressionWriter.WriteExpression(w, con_case, false); w.Write(":"); w.WriteLine(); }
private static void WriteFor(LanguageWriter w, IForStatement state) { w.PushScope(); w.WriteKeyword("for"); w.Write(" "); w.Write("("); if (state.Initializer != null) { w.SkipWriteLine = true; WriteStatement(w, state.Initializer); w.SkipWriteLine = false; w.Write(" "); } w.Write("; "); if (state.Condition != null) { w.SkipWriteLine = true; ExpressionWriter.WriteExpression(w, state.Condition, false); w.SkipWriteLine = false; } w.Write("; "); if (state.Increment != null) { w.SkipWriteLine = true; WriteStatement(w, state.Increment); w.SkipWriteLine = false; } w.Write(") {"); w.WriteLine(); w.WriteIndent(); if (state.Body != null) { WriteStatement(w, state.Body); } w.WriteOutdent(); w.Write("}"); w.WriteLine(); w.PopScope(); }
private static void WriteWhile(LanguageWriter w, IWhileStatement state) { w.WriteKeyword("while"); w.Write(" "); w.Write("("); if (state.Condition != null) { w.SkipWriteLine = true; ExpressionWriter.WriteExpression(w, state.Condition, false); w.SkipWriteLine = false; } w.Write(") {"); w.WriteLine(); w.WriteIndent(); if (state.Body != null) { WriteStatement(w, state.Body); } w.WriteOutdent(); w.Write("}"); w.WriteLine(); }
private static void WriteObjectCreate(LanguageWriter w, IObjectCreateExpression exp) { if (exp.Constructor == null) { // 構造体のデフォルトコンストラクタ (StatementAnalyze でフィルタリングされている筈だけれども) new TypeRef(exp.Type).WriteName(w); #if FALSE w.Write("("); #warning 構造体デフォルトコンストラクタ 対応漏れがあるかもしれないので保留 w.WriteComment("/* C++/CLI では本来は T value; 等と書く筈です。*/"); w.Write(") "); #else w.Write("()"); #endif } else { ITypeReference declaringType = exp.Constructor.DeclaringType as ITypeReference; TypeRef decl_type = new TypeRef(exp.Constructor.DeclaringType); if (decl_type.IsRefType) { w.WriteKeyword("gcnew"); w.Write(" "); } decl_type.WriteName(w); w.Write("("); w.WriteExpressionCollection(exp.Arguments); w.Write(")"); } if (exp.Initializer != null) { WriteBlock(w, exp.Initializer); } }
private static void WriteTryCatchFinally_try(LanguageWriter w, IBlockStatement _try) //,int skipCount { #if FUNC_TRY if (skipCount == 0) { #endif w.WriteKeyword("try"); w.Write(" {"); w.WriteLine(); w.WriteIndent(); #if FUNC_TRY } #endif // // try の中身 // if (_try != null) { #if EXTRA_TEMP IStatementCollection statementCollection = _try.Statements; int i = 0; foreach (IStatement state in _try.Statements) { #warning try: 何故スキップが入るのか? // →コンストラクタ内で を全て delegation したから。 // ・delegation の検索は、最初に delegation が適用出来ない物が出た時に終了する // 但し、その際に、ローカル変数 T var=xxx は無視している? // ・最後の delegation が skipCount if (i < skipCount) { i++; IExpressionStatement state_exp = state as IExpressionStatement; if (state_exp == null) { goto write; } IAssignExpression exp_assign = state_exp.Expression as IAssignExpression; if (exp_assign != null) { // this 以外の物の field もスキップされてしまう... if (exp_assign.Target is IFieldReferenceExpression) { continue; } goto write; } IMethodInvokeExpression exp_inv = state_exp.Expression as IMethodInvokeExpression; if (exp_inv != null) { IMethodReferenceExpression method = exp_inv.Method as IMethodReferenceExpression; if (method != null && method.Target is IBaseReferenceExpression) { continue; } goto write; } } write: WriteStatement(w, state); } #else WriteBlock(w, _try); #endif } w.WriteOutdent(); w.Write("}"); }
public static void WriteExpression(LanguageWriter w, IExpression exp, bool paren) { if (paren) { w.Write("("); } switch (GetExpressionType(exp)) { case ExpressionType.AddressDereference: WriteAddressDereference(w, (IAddressDereferenceExpression)exp); break; case ExpressionType.AddressOf: w.Write("&"); WriteExpression(w, ((IAddressOfExpression)exp).Expression, false); break; case ExpressionType.AddressOut: // 引数 out 渡し WriteExpression(w, ((IAddressOutExpression)exp).Expression, false); break; case ExpressionType.AddressReference: // 引数 ref 渡し WriteExpression(w, ((IAddressReferenceExpression)exp).Expression, false); break; case ExpressionType.ArgumentList: w.WriteKeyword("__arglist"); break; case ExpressionType.ArgumentReference: w.WriteParameterReference(((IArgumentReferenceExpression)exp).Parameter); break; case ExpressionType.ArrayCreate: WriteArrayCreate(w, (IArrayCreateExpression)exp); break; case ExpressionType.ArrayIndexer: WriteArrayIndexerExpression(w, (IArrayIndexerExpression)exp); break; case ExpressionType.Assign: WriteAssign(w, (IAssignExpression)exp); break; case ExpressionType.BaseReference: w.baseType.WriteName(w); break; case ExpressionType.Binary: WriteBinary(w, (IBinaryExpression)exp); break; case ExpressionType.Block: WriteBlock(w, (IBlockExpression)exp); break; case ExpressionType.CanCast: WriteCanCast(w, (ICanCastExpression)exp); break; case ExpressionType.Cast: WriteCast(w, (ICastExpression)exp); break; case ExpressionType.Condition: WriteCondition(w, (IConditionExpression)exp); break; case ExpressionType.DelegateCreate: WriteDelegateCreate(w, (IDelegateCreateExpression)exp); break; case ExpressionType.Literal: w.WriteAsLiteral(((ILiteralExpression)exp).Value); break; case ExpressionType.MethodInvoke: WriteMethodInvoke(w, (IMethodInvokeExpression)exp); break; case ExpressionType.ObjectCreate: WriteObjectCreate(w, (IObjectCreateExpression)exp); break; case ExpressionType.SizeOf: w.WriteKeyword("sizeof"); w.Write("("); new TypeRef(((ISizeOfExpression)exp).Type).WriteName(w); w.Write(")"); break; case ExpressionType.Snippet: w.WriteAsLiteral(((ISnippetExpression)exp).Value); break; case ExpressionType.ThisReference: w.WriteKeyword("this"); break; case ExpressionType.TryCast: WriteTryCast(w, (ITryCastExpression)exp); break; case ExpressionType.TypeOf: new TypeRef(((ITypeOfExpression)exp).Type).WriteName(w); w.Write("::"); w.WriteKeyword("typeid"); break; case ExpressionType.TypeReference: WriteTypeReference(w, (ITypeReferenceExpression)exp); break; case ExpressionType.Unary: WriteUnary(w, (IUnaryExpression)exp); break; case ExpressionType.VariableDeclaration: WriteVariableDeclaration(w, ((IVariableDeclarationExpression)exp).Variable); break; case ExpressionType.VariableReference: w.WriteVariableReference(((IVariableReferenceExpression)exp).Variable); break; case ExpressionType.MemberInitializer: // 属性の初期化の際のメンバ指定 WriteMemberInitializer(w, (IMemberInitializerExpression)exp); break; //--------------------------------------------------- // メンバアクセス //--------------------------------------------------- case ExpressionType.EventReference: WriteEventReference(w, (IEventReferenceExpression)exp); break; case ExpressionType.FieldReference: IFieldReferenceExpression exp_fld = (IFieldReferenceExpression)exp; WriteMemberAccess(w, exp_fld.Target); w.WriteFieldReference(exp_fld.Field); break; case ExpressionType.PropertyReference: WritePropertyReference(w, (IPropertyReferenceExpression)exp); break; case ExpressionType.PropertyIndexer: IPropertyIndexerExpression exp_pind = (IPropertyIndexerExpression)exp; WritePropertyReference(w, exp_pind.Target); w.Write("["); w.WriteExpressionCollection(exp_pind.Indices); w.Write("]"); break; case ExpressionType.MethodReference: IMethodReferenceExpression exp_meth = (IMethodReferenceExpression)exp; WriteMemberAccess(w, exp_meth.Target); w.WriteMethodReference(exp_meth.Method); break; //--------------------------------------------------- // 代替 //--------------------------------------------------- case ExpressionType.StackAlloc: WriteStackAllocate(w, (IStackAllocateExpression)exp); break; case ExpressionType.AnonymousMethod: WriteAnonymousMethod(w, (IAnonymousMethodExpression)exp); break; //--------------------------------------------------- // 以下未対応 //--------------------------------------------------- case ExpressionType.NullCoalescing: WriteBinaryNullCoalescing(w, (INullCoalescingExpression)exp); break; case ExpressionType.DelegateInvoke: case ExpressionType.FieldOf: case ExpressionType.GenericDefault: case ExpressionType.Lambda: case ExpressionType.MethodOf: case ExpressionType.Query: goto default; case ExpressionType.TypedReferenceCreate: case ExpressionType.TypeOfTypedReference: case ExpressionType.ValueOfTypedReference: //throw new System.NotImplementedException("未だ実装していません\r\n"); goto default; case ExpressionType.Unknown: default: ThrowUnknownExpression(exp); break; } if (paren) { w.Write(")"); } }
private static void WriteModify(LanguageWriter w, TypeRef modifier, TypeRef elemType, bool required) { if (modifier.tref != null && modifier.tref.Namespace == "System.Runtime.CompilerServices") { switch (modifier.tref.Name) { case "IsVolatile": if (elemType.IsPointer) { elemType.WriteNameWithRef(w); w.WriteKeyword("volatile"); } else { w.WriteKeyword("volatile"); w.Write(" "); elemType.WriteNameWithRef(w); } return; case "IsConst": if (elemType.IsPointer) { elemType.WriteNameWithRef(w); w.WriteKeyword("const"); } else { //#warning RefOnStack の場合には const は要らない → refOnStack で呼び出す側で、自分で之を取り除くようにした w.WriteKeyword("const"); w.Write(" "); elemType.WriteNameWithRef(w); } return; case "IsLong": if (elemType.IsType("System", "Int32")) { w.WriteReference("long", elemType.FullName, elemType.tref); return; } else if (elemType.IsType("System", "UInt32")) { w.WriteReference("unsigned long", elemType.FullName, elemType.tref); return; } else if (elemType.IsType("System", "Double")) { w.WriteReference("long double", elemType.FullName, elemType.tref); return; } break; case "IsExplicitlyDereferenced": IReferenceType reftype = elemType.type as IReferenceType; if (reftype != null) { w.WriteKeyword("pin_ptr"); w.Write("<"); new TypeRef(reftype.ElementType).WriteNameWithRef(w); w.Write(">"); return; } break; case "CallConvStdcall": elemType.WriteNameWithRef(w); w.Write(" "); w.WriteKeyword("__stdcall"); return; case "CallConvCdecl": elemType.WriteNameWithRef(w); w.Write(" "); w.WriteKeyword("__cdecl"); return; case "CallConvFastcall": elemType.WriteNameWithRef(w); w.Write(" "); w.WriteKeyword("__fastcall"); return; case "CallConvThiscall": elemType.WriteNameWithRef(w); w.Write(" "); w.WriteKeyword("__thiscall"); return; case "IsBoxed": IOptionalModifier mod = elemType.type as IOptionalModifier; if (mod == null) { break; } TypeRef modifier2 = new TypeRef(mod.Modifier); if (!modifier2.IsValueType) { break; } if (!new TypeRef(mod.ElementType).IsType("System", "ValueType")) { break; } modifier2.WriteName(w); w.Write("^"); return; } } elemType.WriteNameWithRef(w); w.Write("<"); w.WriteKeyword(required?"modreq":"modopt"); w.Write(" "); w.WriteReference(modifier.Name, modifier.FullName, modifier.tref); w.Write(">"); return; }
public string WriteName(LanguageWriter w) { if (tref != null) { string name = tref.Name.Replace(".", "::").Replace("+", "::"); string special; if (tref.Namespace == "System" && specialTypeNames.TryGetValue(name, out special)) { name = special; } name = NameMangling.UnDecorateName(name); w.WriteReference(name, this.FullName, tref); ITypeCollection genericArguments = tref.GenericArguments; if (genericArguments.Count > 0) { w.Write("<"); bool first = true; foreach (IType type1 in genericArguments) { if (first) { first = false; } else { w.Write(", "); } new TypeRef(type1).WriteNameWithRef(w); } w.Write(">"); } return(name); } IArrayType type2 = type as IArrayType; if (type2 != null) { w.WriteKeyword("array"); w.Write("<"); new TypeRef(type2.ElementType).WriteNameWithRef(w); if (type2.Dimensions.Count > 1) { w.Write(", "); w.WriteAsLiteral(type2.Dimensions.Count); } w.Write(">"); } IPointerType type4 = type as IPointerType; if (type4 != null) { new TypeRef(type4.ElementType).WriteNameWithRef(w); w.Write("*"); } IReferenceType type3 = type as IReferenceType; if (type3 != null) { new TypeRef(type3.ElementType).WriteNameWithRef(w); w.Write("%"); } IOptionalModifier modifier2 = type as IOptionalModifier; if (modifier2 != null) { WriteModify(w, new TypeRef(modifier2.Modifier), new TypeRef(modifier2.ElementType), false); } IRequiredModifier modifier = type as IRequiredModifier; if (modifier != null) { WriteModify(w, new TypeRef(modifier.Modifier), new TypeRef(modifier.ElementType), true); } IFunctionPointer fptr = type as IFunctionPointer; if (fptr != null) { w.Write("("); new TypeRef(fptr.ReturnType.Type).WriteNameWithRef(w); w.Write(" (*)("); bool first = true; foreach (IParameterDeclaration declaration in fptr.Parameters) { if (first) { first = false; } else { w.Write(", "); } new TypeRef(declaration.ParameterType).WriteNameWithRef(w); } w.Write("))"); } IGenericParameter parameter = type as IGenericParameter; if (parameter != null) { w.WriteReference(parameter.Name, "/* ジェネリックパラメータ */ " + parameter.Name, null); } IGenericArgument argument = type as IGenericArgument; if (argument != null) { new TypeRef(argument.Resolve()).WriteNameWithRef(w); } if (type is IValueTypeConstraint) { w.WriteKeyword("value class"); } else if (type is IDefaultConstructorConstraint) { w.Write("<DefaultConstructorConstraint>"); } return("<不明な型>"); }
private static void WriteTryCatchFinally(LanguageWriter w, ITryCatchFinallyStatement state) { #if FUNC_TRY int skipTryCount = w.SkipTryCount; w.SkipTryCount = 0; #endif #if FALSE if (state.Try != null) { foreach (ICatchClause current in state.CatchClauses) { if (current.Body.Statements.Count != 0) { goto write_try; } } if (state.Finally.Statements.Count != 0) { goto write_try; } if (state.Fault.Statements.Count != 0) { goto write_try; } // 中身が何もない場合 this.WriteBlockStatement(state.Try); if (skipTryCount != 0) { this.WriteOutdent(); this.Write("}"); this.WriteLine(); } return; } write_try: #endif WriteTryCatchFinally_try(w, state.Try); //,skipTryCount // // catch 節 // foreach (ICatchClause clause in state.CatchClauses) { WriteTryCatchFinally_catch(w, clause); } // // fault 節 // if (state.Fault != null && state.Fault.Statements.Count > 0) { w.Write(" "); w.WriteKeyword("fault"); w.Write(" {"); w.WriteLine(); w.WriteIndent(); WriteBlock(w, state.Fault); w.WriteOutdent(); w.Write("}"); } // // finally 節 // if (state.Finally != null && state.Finally.Statements.Count > 0) { w.Write(" "); w.WriteKeyword("finally"); w.Write(" {"); w.WriteLine(); w.WriteIndent(); WriteBlock(w, state.Finally); w.WriteOutdent(); w.Write("}"); } w.WriteLine(); }
private static void WriteTryCatchFinally_catch(LanguageWriter w, ICatchClause clause) { w.Write(" "); w.WriteKeyword("catch"); // 特別な場合 catch(...) を検出 // → clauseBody を改変 // clauseBody は StatementAnalyze の時点で改変する様にした bool catchAll = clause.Condition is StatementAnalyze.IsCatchAll; IStatementCollection clause_body = clause.Body == null?null:clause.Body.Statements; TypeRef var_type = new TypeRef(clause.Variable.VariableType); /* * if(var_type.IsObject&&clause.Condition!=null) { * ISnippetExpression iSnippent=clause.Condition as ISnippetExpression; * if(iSnippent!=null&&iSnippent.Value=="?"&&StatementAnalyze.IsCatchAllClause(ref clause_body)){ * catchAll=true; * } * } * //*/ if (catchAll) { w.Write(" (...)"); } else { if (clause.Variable.Name.Length != 0 || !var_type.IsObject) { w.scope.RegisterVariable(clause.Variable, false); w.Write(" ("); var_type.WriteNameWithRef(w); w.Write(" "); w.WriteDeclaration(clause.Variable.Name); w.Write(")"); } if (clause.Condition != null) { w.Write(" "); w.WriteKeyword("when"); w.Write(" "); w.Write("("); w.WriteExpression(clause.Condition); w.Write(")"); } } w.Write(" {"); w.WriteLine(); w.WriteIndent(); if (clause_body != null) { for (int num = 0; num < clause_body.Count; num++) { IStatement statement3 = clause_body[num]; #if EXTRA_TEMP #warning catch: "コンストラクタの中で、最後の一行で、throw" の場合は書き込まない? // →之は、恐らく、 constructor に function-try-statement を適用した時の話である // よって無視する if (w.SomeConstructor && num + 1 >= clause_body.Count && statement3 is IThrowExceptionStatement) { break; } #endif WriteStatement(w, statement3); } } w.WriteOutdent(); w.Write("}"); }
public static void WriteStatement(LanguageWriter w, IStatement state) { switch (GetExpressionType(state)) { case StatementType.AttachEvent: WriteAttachEvent(w, (IAttachEventStatement)state); break; case StatementType.Block: WriteBlock(w, (IBlockStatement)state); break; case StatementType.Break: w.WriteKeyword("break"); w.Write(";"); w.WriteLine(); break; case StatementType.Condition: WriteCondition(w, (IConditionStatement)state); break; case StatementType.Continue: w.WriteKeyword("continue"); w.Write(";"); w.WriteLine(); break; case StatementType.DefaultConstruction: WriteDefaultConstruction(w, (DefaultConstructionStatement)state); break; case StatementType.Delete: w.WriteKeyword("delete"); w.Write(" "); ExpressionWriter.WriteExpression(w, ((DeleteStatement)state).deleteTarget, false); w.Write(";"); w.WriteLine(); break; case StatementType.Do: WriteDo(w, (IDoStatement)state); break; case StatementType.Expression: WriteExpression(w, (IExpressionStatement)state); break; case StatementType.Fixed: WriteFixed(w, (IFixedStatement)state); break; case StatementType.For: WriteFor(w, (IForStatement)state); break; case StatementType.ForEach: WriteForEach(w, (IForEachStatement)state); break; case StatementType.Goto: w.WriteKeyword("goto"); w.Write(" "); w.Write(((IGotoStatement)state).Name); w.Write(";"); w.WriteLine(); break; case StatementType.Label: w.__WriteLabel(((LabelStatement)state).label_name); break; case StatementType.Labeled: WriteLabeled(w, (ILabeledStatement)state); break; case StatementType.LocalRefVariable: WriteLocalRefVariable(w, (LocalRefVariableStatement)state); break; case StatementType.Lock: WriteLock(w, (ILockStatement)state); break; case StatementType.MemoryCopy: WriteMemoryCopy(w, (IMemoryCopyStatement)state); break; case StatementType.MemoryInitialize: WriteMemoryInitialize(w, (IMemoryInitializeStatement)state); break; case StatementType.MethodReturn: WriteMethodReturn(w, (IMethodReturnStatement)state); break; case StatementType.RemoveEvent: WriteRemoveEvent(w, (IRemoveEventStatement)state); break; case StatementType.Switch: WriteSwitch(w, (ISwitchStatement)state); break; case StatementType.ThrowException: WriteThrowException(w, (IThrowExceptionStatement)state); break; case StatementType.TryCatch: WriteTryCatchFinally(w, (ITryCatchFinallyStatement)state); break; // case StatementType.Using: // WriteUsing(w,(IUsingStatement)state); // break; case StatementType.While: WriteWhile(w, (IWhileStatement)state); break; case StatementType.Comment: case StatementType.DebugBreak: case StatementType.Unknown: default: ThrowUnknownStatement(state); break; } w.SkipWriteLine = false; }