コード例 #1
0
 public void EvaluateClass(LangClassBuilderBase classBuilder, Dictionary <string, string> extraParams)
 {
     TryCastUtil.TryCast <ICreateFileClass>(_fileBuilder).CreateFileClass(
         classBuilder, GetAccessModifierFromExtraParams(extraParams, AccessModifier.PUBLIC));
 }
コード例 #2
0
 public void EvaluateVariable(VariableObj variableObj, Dictionary <string, string> extraParams)
 {
     TryCastUtil.TryCast <ICreateFileVariable>(_fileBuilder).CreateFileVariable(variableObj);
 }
コード例 #3
0
 public void EvaluateFunction(FunctionObj functionObj, Dictionary <string, string> extraParams)
 {
     TryCastUtil.TryCast <ICreateFileFunction>(_fileBuilder).CreateFileFunction(functionObj);
 }
コード例 #4
0
 public void EvaluateConstructor(List <VariableObj> constructorParams, Dictionary <string, string> extraParams)
 {
     TryCastUtil.TryCast <ICreateClassConstructor>(_classBuilder).CreateClassConstructor(
         constructorParams, GetAccessModifierFromExtraParams(extraParams, AccessModifier.PUBLIC));
 }
コード例 #5
0
 public void EvaluateFunction(FunctionObj functionObj, Dictionary <string, string> extraParams)
 {
     TryCastUtil.TryCast <ICreateClassFunction>(_classBuilder).CreateClassFunction(
         functionObj, GetAccessModifierFromExtraParams(extraParams, AccessModifier.PUBLIC));
 }
コード例 #6
0
 public void EvaluateProperty(VariableObj variableObj, Dictionary <string, string> extraParams)
 {
     TryCastUtil.TryCast <ICreateClassProperty>(_classBuilder).CreateClassProperty(
         variableObj, GetAccessModifierFromExtraParams(extraParams, AccessModifier.PRIVATE));
 }
コード例 #7
0
        public void CreateFileClass(LangClassBuilderBase classBuilder, AccessModifier accessModifier)
        {
            CppClassBuilder cppClassBuilder = TryCastUtil.TryCast <CppClassBuilder>(classBuilder);

            _classes.Add(cppClassBuilder);
        }
コード例 #8
0
        private void InterpretContent(XmlNode contentNode, ContextEvaluatorBase contextEvaluator)
        {
            foreach (XmlNode parentNode in contentNode.ChildNodes)
            {
                Dictionary <string, string> extraParams;
                switch (parentNode.Name)
                {
                case "Files":
                    foreach (XmlNode node in parentNode.ChildNodes)
                    {
                        LangFileBuilderBase fileBuilder = TryCastUtil.TryCast <ICreateFileBuilder>(_langFactory).CreateFileBuilder();
                        fileBuilder.CreateFile(_outDir + GetAttributeOrDefault(node, "name", ""));

                        extraParams = InterpretIdentifier(node, () =>
                        {
                            return(new FileContextEvaluator(fileBuilder));
                        });

                        TryCastUtil.TryCast <IEvaluateFile>(contextEvaluator).EvaluateFile(fileBuilder, extraParams);
                    }
                    break;

                case "Variables":
                    foreach (XmlNode node in parentNode.ChildNodes)
                    {
                        var variableObj = new VariableObj(
                            ParseDataType(GetAttributeOrDefault(node, "type", "")),
                            GetAttributeOrDefault(node, "name", "")
                            );

                        extraParams = InterpretIdentifier(node, null);

                        TryCastUtil.TryCast <IEvaluateVariable>(contextEvaluator).EvaluateVariable(variableObj, extraParams);
                    }
                    break;

                case "Functions":
                    foreach (XmlNode node in parentNode.ChildNodes)
                    {
                        var functionObj = new FunctionObj(
                            ParseDataType(GetAttributeOrDefault(node, "returnType", "")),
                            GetAttributeOrDefault(node, "name", "")
                            );
                        functionObj.FuncParams = ParseFuncParams(GetAttributeOrDefault(node, "params", ""));

                        extraParams = InterpretIdentifier(node, null);

                        TryCastUtil.TryCast <IEvaluateFunction>(contextEvaluator).EvaluateFunction(functionObj, extraParams);
                    }
                    break;

                case "Properties":
                    foreach (XmlNode node in parentNode.ChildNodes)
                    {
                        var propertyObj = new VariableObj(
                            ParseDataType(GetAttributeOrDefault(node, "type", "")),
                            GetAttributeOrDefault(node, "name", "")
                            );

                        extraParams = InterpretIdentifier(node, null);

                        TryCastUtil.TryCast <IEvaluateProperty>(contextEvaluator).EvaluateProperty(propertyObj, extraParams);
                    }
                    break;

                case "Classes":
                case "InnerClasses":
                    foreach (XmlNode node in parentNode.ChildNodes)
                    {
                        LangClassBuilderBase classBuilder = TryCastUtil.TryCast <ICreateClassBuilder>(_langFactory).CreateClassBuilder();

                        classBuilder.CreateClass(GetAttributeOrDefault(node, "name", ""));

                        extraParams = InterpretIdentifier(node, () =>
                        {
                            return(new ClassContextEvaluator(classBuilder));
                        });

                        TryCastUtil.TryCast <IEvaluateClass>(contextEvaluator).EvaluateClass(classBuilder, extraParams);
                    }
                    break;

                case "Constructor":
                    List <VariableObj> constructorParams = ParseFuncParams(GetAttributeOrDefault(parentNode, "params", ""));

                    extraParams = InterpretIdentifier(parentNode, null);

                    TryCastUtil.TryCast <IEvaluateConstructor>(contextEvaluator).EvaluateConstructor(constructorParams, extraParams);
                    break;

                default:
                    /* Note: this should be impossible since an invalid identifier would be caught by the
                     * schema validation, but we should still throw an exception just in case */
                    throw new InterpreterParseException($"Identifier \"{parentNode.Name}\" not recognized.");
                }
            }
        }