protected override void TranslateAssignment(List <string> output, Assignment assignment) { output.Add(this.CurrentTabIndention); Expression target = assignment.Target; if (target is Variable && ((Variable)target).IsStatic) { output.Add("public static "); } Annotation typeAnnotation = target.GetAnnotation("type"); if (typeAnnotation != null) { CSharpPlatform csharpPlatform = (CSharpPlatform)this.Platform; string csharpType = csharpPlatform.GetTypeStringFromAnnotation(typeAnnotation.FirstToken, typeAnnotation.GetSingleArgAsString(null)); output.Add(csharpType); output.Add(" "); } this.TranslateExpression(output, target); output.Add(" "); output.Add(this.GetAssignmentOp(assignment)); output.Add(" "); this.TranslateExpression(output, assignment.Value); output.Add(";"); output.Add(this.NL); }
protected override void TranslateNewList(List <string> output, StringConstant type) { CSharpPlatform platform = (CSharpPlatform)this.Platform; string csharpType = platform.GetTypeStringFromAnnotation(type.FirstToken, type.Value); output.Add("new List<"); output.Add(csharpType); output.Add(">()"); }
protected override void TranslateCast(List <string> output, StringConstant typeValue, Expression expression) { CSharpPlatform platform = (CSharpPlatform)this.Platform; string typeString = platform.GetTypeStringFromAnnotation(typeValue.FirstToken, typeValue.Value); output.Add("("); output.Add(typeString); output.Add(")"); this.Translator.TranslateExpression(output, expression); }
protected override void TranslateNewListOfSize(List <string> output, StringConstant type, Expression length) { CSharpPlatform platform = (CSharpPlatform)this.Platform; output.Add("TranslationHelper.NewListOfSize<"); output.Add(platform.GetTypeStringFromAnnotation(type.FirstToken, type.Value)); output.Add(">("); this.Translator.TranslateExpression(output, length); output.Add(")"); }
protected override void TranslateNewDictionary(List <string> output, StringConstant keyType, StringConstant valueType) { CSharpPlatform platform = (CSharpPlatform)this.Platform; string csharpKeyType = platform.GetTypeStringFromAnnotation(keyType.FirstToken, keyType.Value); string csharpValueType = platform.GetTypeStringFromAnnotation(valueType.FirstToken, valueType.Value); output.Add("new Dictionary<"); output.Add(csharpKeyType); output.Add(", "); output.Add(csharpValueType); output.Add(">()"); }
protected override void TranslateNewArray(List <string> output, StringConstant type, Expression size) { CSharpPlatform platform = (CSharpPlatform)this.Platform; string csharpType = platform.GetTypeStringFromAnnotation(type.FirstToken, type.Value); output.Add("new "); // Delightful hack... int padding = 0; while (csharpType.EndsWith("[]")) { padding++; csharpType = csharpType.Substring(0, csharpType.Length - 2); } output.Add(csharpType); output.Add("["); this.Translator.TranslateExpression(output, size); output.Add("]"); while (padding-- > 0) { output.Add("[]"); } }