protected override void TranslateFunctionDefinition(List<string> output, ParseTree.FunctionDefinition functionDef) { output.Add(this.CurrentTabIndention); string returnType = "void*"; Annotation returnTypeAnnotation = functionDef.GetAnnotation("type"); if (returnTypeAnnotation != null) { returnType = this.CPlatform.GetTypeStringFromAnnotation(new AnnotatedType(returnTypeAnnotation), false, true); } output.Add(returnType); output.Add(" "); output.Add("v_" + functionDef.NameToken.Value); output.Add("("); for (int i = 0; i < functionDef.ArgNames.Length; ++i) { if (i > 0) output.Add(", "); if (functionDef.ArgAnnotations[i] == null) { output.Add("object "); } else { string argType = functionDef.ArgAnnotations[i].GetSingleArgAsString(null); string type = this.CPlatform.GetTypeStringFromAnnotation(functionDef.ArgAnnotations[i].FirstToken, argType, false, true); output.Add(type); output.Add(" "); } output.Add("v_" + functionDef.ArgNames[i].Value); } output.Add(")"); output.Add(this.NL); output.Add(this.CurrentTabIndention); output.Add("{"); output.Add(this.NL); this.CurrentIndention++; Executable[] code = functionDef.Code; if (functionDef.GetAnnotation("omitReturn") != null) { Executable[] newCode = new Executable[code.Length - 1]; Array.Copy(code, newCode, newCode.Length); code = newCode; } this.Translate(output, code); this.CurrentIndention--; output.Add(this.CurrentTabIndention); output.Add("}"); //*/ output.Add(this.NL); }
protected override void TranslateFunctionDefinition(List<string> output, ParseTree.FunctionDefinition functionDef) { Annotation returnType = functionDef.GetAnnotation("type"); string type = returnType == null ? "Object" : this.JavaPlatform.GetTypeStringFromString(returnType.GetSingleArgAsString(null), false, false); output.Add(this.CurrentTabIndention); output.Add("public static "); output.Add(type); output.Add(" v_"); output.Add(functionDef.NameToken.Value); output.Add("("); for (int i = 0; i < functionDef.ArgNames.Length; ++i) { if (i > 0) { output.Add(", "); } Annotation annotation = functionDef.ArgAnnotations[i]; string argType = annotation == null ? "Object" : annotation.GetSingleArgAsString(null); output.Add(this.JavaPlatform.GetTypeStringFromString(argType, false, false)); output.Add(" v_"); output.Add(functionDef.ArgNames[i].Value); } output.Add(") {"); output.Add(this.NL); this.CurrentIndention++; Executable[] code = functionDef.Code; if (functionDef.GetAnnotation("omitReturn") != null) { Executable[] newCode = new Executable[code.Length - 1]; Array.Copy(code, newCode, newCode.Length); code = newCode; } this.Translate(output, code); this.CurrentIndention--; output.Add(this.CurrentTabIndention); output.Add("}"); output.Add(this.NL); }