示例#1
0
        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);
        }
示例#2
0
        public void CreateClassFunction(FunctionObj functionObj, AccessModifier accessModifier,
                                        bool isOverridable = false)
        {
            ClassFunction classFunction;

            classFunction.functionObj    = functionObj;
            classFunction.accessModifier = accessModifier;
            classFunction.isOverridable  = isOverridable;

            _functions.Add(classFunction);
        }
示例#3
0
        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(")");
        }
示例#4
0
        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);
        }