public void CreateClassConstructor(List <VariableObj> constructorParams, AccessModifier accessModifier) { var constructor = new FunctionObj(DataType.NONE, _className); constructor.FuncParams = constructorParams; CreateClassFunction(constructor, accessModifier); var deconstructor = new FunctionObj(DataType.NONE, "~" + _className); CreateClassFunction(deconstructor, accessModifier, true); }
public void CreateClassFunction(FunctionObj functionObj, AccessModifier accessModifier, bool isOverridable = false) { ClassFunction classFunction; classFunction.functionObj = functionObj; classFunction.accessModifier = accessModifier; classFunction.isOverridable = isOverridable; _functions.Add(classFunction); }
public static void WriteFunctionString(LangStreamWrapper stream, FunctionObj functionObj, string namespaceName = "") { WriteVariableString(stream, functionObj.TypeAndName, namespaceName); stream.Write("("); int index = 0; foreach (VariableObj funcParam in functionObj.FuncParams) { WriteVariableString(stream, funcParam, ""); //add comma if not the last param if (index != functionObj.FuncParams.Count - 1) { stream.Write(", "); } index++; } stream.Write(")"); }
public void CreateClassProperty(VariableObj variableObj, AccessModifier accessModifier) { if (accessModifier != AccessModifier.PRIVATE) { accessModifier = AccessModifier.PROTECTED; } CreateClassMemeber(variableObj, accessModifier); var getFunc = new FunctionObj(variableObj.Type, "get_" + variableObj.Name, (stream) => { stream.WriteLine("return this->" + variableObj.Name + ";"); }); CreateClassFunction(getFunc, AccessModifier.PUBLIC, false); var setFunc = new FunctionObj(DataType.VOID, "set_" + variableObj.Name, (stream) => { stream.WriteLine("this->" + variableObj.Name + " = " + variableObj.Name + ";"); }); setFunc.FuncParams.Add(new VariableObj(variableObj.Type, variableObj.Name)); CreateClassFunction(setFunc, AccessModifier.PUBLIC, false); }