public TargetCodeResult Compile(SourceCode aSourceCode, string aCurrentCodeLine, int aLinePosition) { TargetCodeResult result = new TargetCodeResult(aCurrentCodeLine); int propertyNameLocationInCode = 0; String propertyName = GetPropertyName(aCurrentCodeLine, out propertyNameLocationInCode); String propertyType = GetPropertyType(aCurrentCodeLine, propertyNameLocationInCode); String memberVariableName = "_" + propertyName.ToLower(); String parameterName = "a" + propertyName; StringBuilder newLine = new StringBuilder(); newLine.Append("\n"); newLine.Append("private ").Append(propertyType).Append(" ").Append(memberVariableName).Append(";\n\n"); newLine.Append("public").Append(" ").Append(propertyType).Append(" ").Append("get").Append(propertyName).Append("()\n"); newLine.Append("{\n"); newLine.Append("return this.").Append(memberVariableName).Append(";\n"); newLine.Append("}"); newLine.Append("\n\n"); newLine.Append("public void ").Append("set").Append(propertyName).Append("(").Append(propertyType).Append(" ").Append(parameterName).Append(")").Append("\n"); newLine.Append("{\n"); newLine.Append("this.").Append(memberVariableName).Append(" = ").Append(parameterName).Append(";\n"); newLine.Append("}\n"); result = new TargetCodeResult(newLine.ToString()); return result; }
public TargetCodeResult Compile(SourceCode aSourceCode, string aCurrentCodeLine, int aLinePosition) { TargetCodeResult result = new TargetCodeResult(aCurrentCodeLine); String usingNamespace = GetUsingNamespace(aSourceCode, aCurrentCodeLine); bool correctLine = IsUsingCorrect(usingNamespace); if (!correctLine && (IsSystemNamespace(usingNamespace) || IsProgramNamespace(aSourceCode, usingNamespace))) return new TargetCodeResult(""); if (correctLine) { // TODO: For now we import all the Java classes in that package, we don't worry much about that since the Java compiler will take care of this for us // Suggest that we do change this in the future if required StringBuilder newLine = new StringBuilder(); newLine.Append("import ").Append(usingNamespace).Append(".*;"); result = new TargetCodeResult(newLine.ToString()); } else { StringBuilder newLine = new StringBuilder(); newLine.Append("//"); newLine.Append(aCurrentCodeLine); newLine.Append(" // Not supported yet"); result = new TargetCodeResult(newLine.ToString()); result.LogError(aSourceCode.GetFileName() + ": Using directive not supported yet on line: " + aLinePosition); } return result; }
public TargetCodeResult Compile(SourceCode aSourceCode, string aCurrentCodeLine, int aLinePosition) { TargetCodeResult result = new TargetCodeResult(aCurrentCodeLine); String superClassName = GetSupperClassName(aCurrentCodeLine); if (superClassName != null) { String classDef = GetClassDefinition(aCurrentCodeLine); StringBuilder newLine = new StringBuilder(); if (classDef.StartsWith("class")) newLine.Append("public "); newLine.Append(classDef); if (superClassName.IndexOf(",") > -1) newLine.Append(" extends ").Append(GetExtendClass(superClassName)).Append(GetInterfaces(superClassName)); else { if (!superClassName.StartsWith("I")) newLine.Append(" extends ").Append(superClassName); else newLine.Append(" implements ").Append(superClassName); } result = new TargetCodeResult(newLine.ToString()); } return result; }
public TargetCodeResult Compile(SourceCode aSourceCode, string aCurrentCodeLine, int aLinePosition) { TargetCodeResult result = new TargetCodeResult(aCurrentCodeLine); if (aSourceCode.Arguments.ContainProgramArgument("package")) { String namespaceName = aSourceCode.Arguments.GetProgramArgumentValue("package"); StringBuilder newLine = new StringBuilder(); newLine.Append("\npackage ").Append(namespaceName).Append(";"); result = new TargetCodeResult(newLine.ToString()); } else result = new TargetCodeResult(""); return result; }