예제 #1
0
 public void Load(ICompilateurInstance comp, System.Xml.XmlNode node)
 {
     if (node.Attributes.GetNamedItem("indent") != null)
     {
         Int32.TryParse(node.Attributes.GetNamedItem("indent").Value, out this.indent);
     }
 }
예제 #2
0
 public void Load(ICompilateurInstance comp, System.Xml.XmlNode node)
 {
     if (node.Attributes.GetNamedItem("indent") != null)
     {
         Int32.TryParse(node.Attributes.GetNamedItem("indent").Value, out this.indent);
     }
     this.processName = node.InnerText;
     this.cachedComp  = comp;
 }
예제 #3
0
 public void Load(ICompilateurInstance comp, System.Xml.XmlNode node)
 {
     if (node.Attributes.GetNamedItem("indent") != null)
     {
         Int32.TryParse(node.Attributes.GetNamedItem("indent").Value, out this.indent);
     }
     this.enc        = comp.EncodedFile;
     this.cachedComp = comp;
 }
예제 #4
0
 /// <summary>
 /// Load template data
 /// </summary>
 /// <param name="comp">compiler object</param>
 /// <param name="node">xml node object</param>
 public void Load(ICompilateurInstance comp, XmlNode node)
 {
     if (node.Attributes.GetNamedItem("indent") != null)
     {
         Int32.TryParse(node.Attributes.GetNamedItem("indent").Value, out this.indent);
     }
     this.name = node.Attributes.GetNamedItem("name").Value;
     this.legendes.Load(node.SelectSingleNode("legendes"));
     this.xmlCode = node.SelectSingleNode("code").InnerXml;
 }
예제 #5
0
 public void Load(ICompilateurInstance comp, System.Xml.XmlNode node)
 {
     if (node.Attributes.GetNamedItem("indent") != null)
     {
         Int32.TryParse(node.Attributes.GetNamedItem("indent").Value, out this.indent);
     }
     this.uniqueContainer = comp.Unique.ComputeNewString();
     this.codingName      = node.Attributes.GetNamedItem("name").Value;
     this.xmlCode         = node.SelectSingleNode("code");
 }
예제 #6
0
 public void Load(ICompilateurInstance comp, System.Xml.XmlNode node)
 {
     if (node.Attributes.GetNamedItem("indent") != null)
     {
         Int32.TryParse(node.Attributes.GetNamedItem("indent").Value, out this.indent);
     }
     this.expression = node.SelectSingleNode("expression").InnerText;
     this.labelTrue  = node.SelectSingleNode("iftrue").InnerText;
     this.labelFalse = node.SelectSingleNode("iffalse").InnerText;
 }
예제 #7
0
 public void Load(ICompilateurInstance comp, System.Xml.XmlNode node)
 {
     if (node.Attributes.GetNamedItem("indent") != null)
     {
         Int32.TryParse(node.Attributes.GetNamedItem("indent").Value, out this.indent);
     }
     this.varName    = node.SelectSingleNode("terme").InnerText;
     this.tabName    = node.SelectSingleNode("tableau").InnerText;
     this.cachedComp = comp;
 }
예제 #8
0
 /// <summary>
 /// Load statement data
 /// </summary>
 /// <param name="comp">compiler object</param>
 /// <param name="node">xml node object</param>
 public void Load(ICompilateurInstance comp, System.Xml.XmlNode node)
 {
     if (node.Attributes.GetNamedItem("indent") != null)
     {
         Int32.TryParse(node.Attributes.GetNamedItem("indent").Value, out this.indent);
     }
     this.language   = node.Attributes.GetNamedItem("language").Value;
     this.command    = node.Attributes.GetNamedItem("command").Value;
     this.expression = node.Attributes.GetNamedItem("expression").Value;
     this.cachedComp = comp;
 }
예제 #9
0
 public void Load(ICompilateurInstance comp, System.Xml.XmlNode node)
 {
     if (node.Attributes.GetNamedItem("indent") != null)
     {
         Int32.TryParse(node.Attributes.GetNamedItem("indent").Value, out this.indent);
     }
     this.varName    = node.SelectSingleNode("variable").InnerText;
     this.expression = node.SelectSingleNode("expression").InnerText;
     // on en a besoin pour plus tard dans la conversion
     this.cachedComp = comp;
 }
예제 #10
0
 public void Load(ICompilateurInstance comp, System.Xml.XmlNode node)
 {
     if (node.Attributes.GetNamedItem("indent") != null)
     {
         Int32.TryParse(node.Attributes.GetNamedItem("indent").Value, out this.indent);
     }
     this.tabName    = node.SelectSingleNode("tableau").InnerText;
     this.expression = node.SelectSingleNode("expression").InnerText;
     this.fieldName  = node.SelectSingleNode("variable").InnerText;
     this.enc        = comp.EncodedFile;
     this.cachedComp = comp;
 }
예제 #11
0
 /// <summary>
 /// Fill a new method
 /// </summary>
 /// <param name="comp">compilation</param>
 /// <param name="subProc">sub process object</param>
 /// <param name="converter">language converter</param>
 /// <param name="f">new function</param>
 /// <param name="file">writing in</param>
 public static void FillNewMethod(ICompilateurInstance comp, IProcess subProc, ICodeConverter converter, IFunction f, FinalFile file)
 {
     // la fonction est implémentée
     converter.PushFunction(converter.CurrentFunction);
     f.PropagateControlFlow(converter.CurrentFunction);
     converter.SetCurrentFunction(f);
     subProc.FunctionName = converter.ProcessAsFunction;
     converter.CurrentFunction.ForwardControlFlowSub();
     comp.Convert(converter, subProc, file);
     converter.CurrentFunction.BackwardControlFlowSub();
     converter.SetCurrentFunction(converter.PopFunction());
 }
예제 #12
0
        /// <summary>
        /// Call coding process
        /// </summary>
        /// <param name="comp">compilation</param>
        /// <param name="converter">language converter</param>
        /// <param name="ut">UseTemplate object</param>
        /// <param name="codingName">process name of coding</param>
        /// <param name="file">writing in</param>
        public static void CallCoding(ICompilateurInstance comp, ICodeConverter converter, UseTemplate ut, string codingName, FinalFile file)
        {
            Coding coding = ut.GetCoding(codingName);

            if (coding != null)
            {
                IProcess proc = comp.GetCodingProcess(coding.UniqueCodingName);
                proc.FunctionName = converter.ProcessAsFunction;
                comp.Convert(converter, proc, file);
                comp.RemoveCodingProcess(coding.UniqueCodingName);
            }
        }
예제 #13
0
 /// <summary>
 /// Inject this object onto the injector
 /// </summary>
 /// <param name="injector">injector object</param>
 /// <param name="comp">the compiler object</param>
 /// <param name="node">xml node object</param>
 /// <param name="modifier">modifier after, before or replace</param>
 public void Inject(Injector injector, ICompilateurInstance comp, System.Xml.XmlNode node, string modifier)
 {
     this.Load(comp, node);
     if (comp.UnderConversion)
     {
         string s = String.Empty;
         if (!this.IsComputable(injector.InjectedProcess, out s))
         {
             throw new Exception(s);
         }
     }
 }
예제 #14
0
        public void Load(ICompilateurInstance comp, System.Xml.XmlNode node)
        {
            if (node.Attributes.GetNamedItem("indent") != null)
            {
                Int32.TryParse(node.Attributes.GetNamedItem("indent").Value, out this.indent);
            }
            // remove whitespace
            string innerText = node.InnerText;

            this.text       = innerText.Replace(" ", "").Replace("\t", "").Replace("\n\r", "");
            this.cachedComp = comp;
            this.enc        = comp.EncodedFile;
        }
예제 #15
0
        /// <summary>
        /// Call coding process
        /// Uses a newer variable in which you are adding it in the coding process
        /// </summary>
        /// <param name="comp">compilation</param>
        /// <param name="proc">process</param>
        /// <param name="converter">language converter</param>
        /// <param name="coding">coding object</param>
        /// <param name="varName">name of the variable</param>
        /// <param name="desiredDataType">desired data type of the variable</param>
        /// <param name="file">writing in</param>
        public static void CallCoding(ICompilateurInstance comp, IProcessInstance proc, ICodeConverter converter, Coding coding, string varName, EnumDataType desiredDataType, FinalFile file)
        {
            IProcess subProc = comp.GetCodingProcess(coding.UniqueCodingName);

            // la fonction courante est associée à ce processus
            // ce processus ne crée pas de fonction
            subProc.FunctionName = converter.ProcessAsFunction;
            // les instructions du coding sont stockées dans un processus à part
            // mais il n'y a pas de création d'une nouvelle fonction et cela implique
            // que je dois ranger les variables utilisées dans le processus au dessus
            // afin qu'elles soient déjà connues dans le processus du coding
            IData var = Helper.ConvertNonComputableVariableType(proc, converter, varName, desiredDataType);

            // mais j'ajoute la variable en local dans la fonction courante
            // pour ne pas qu'elle devienne un paramètre de la fonction courante
            Helper.AddIntoLocal(converter, var);
            comp.Convert(converter, subProc, file);
            comp.RemoveCodingProcess(coding.UniqueCodingName);
        }
예제 #16
0
 /// <summary>
 /// Load template data
 /// </summary>
 /// <param name="comp">compiler object</param>
 /// <param name="node">xml node object</param>
 public void Load(ICompilateurInstance comp, System.Xml.XmlNode node)
 {
     if (node.Attributes.GetNamedItem("indent") != null)
     {
         Int32.TryParse(node.Attributes.GetNamedItem("indent").Value, out this.indent);
     }
     this.path = node.Attributes.GetNamedItem("path").Value;
     this.name = node.Attributes.GetNamedItem("name").Value;
     this.legendes.Load(node.SelectSingleNode("legendes"));
     this.pars = new Dictionary <string, string>();
     foreach (XmlNode paramNode in node.SelectNodes("params/param"))
     {
         if (!this.pars.ContainsKey(paramNode.InnerText))
         {
             this.pars.Add(paramNode.InnerText, "");
         }
     }
     this.xmlCode = node.SelectSingleNode("code").InnerXml;
 }
예제 #17
0
 public void Load(ICompilateurInstance comp, System.Xml.XmlNode node)
 {
     if (node.Attributes.GetNamedItem("indent") != null)
     {
         Int32.TryParse(node.Attributes.GetNamedItem("indent").Value, out this.indent);
     }
     this.writerName = node.Attributes.GetNamedItem("name").Value;
     this.filePath   = new List <string>();
     if (node.SelectNodes("file")[0].FirstChild != null)
     {
         foreach (XmlNode paramNode in node.SelectNodes("file/expression"))
         {
             string paramValue = paramNode.InnerText;
             this.filePath.Add(paramValue);
         }
     }
     // on en a besoin pour la conversion
     this.cachedComp = comp;
 }
예제 #18
0
 /// <summary>
 /// Load injector data
 /// </summary>
 /// <param name="comp">compiler object</param>
 /// <param name="node">xml node object</param>
 public void Load(ICompilateurInstance comp, System.Xml.XmlNode node)
 {
     if (node.Attributes.GetNamedItem("indent") != null)
     {
         Int32.TryParse(node.Attributes.GetNamedItem("indent").Value, out this.indent);
     }
     this.name            = node.Attributes.GetNamedItem("name").Value;
     this.injectedProcess = comp.CurrentProcess;
     this.current         = this.injectedProcess.Objects.IndexOf(this);
     this.before          = this.after = this.current;
     // si je suis dans un squelette
     if (this.injectedProcess.Name.StartsWith("Skeleton:"))
     {
         this.skeleton = this.injectedProcess.Name.Substring(9) + "/";
     }
     else
     {
         this.skeleton = "";
     }
 }
예제 #19
0
 /// <summary>
 /// Load object from xml node
 /// </summary>
 /// <param name="comp">this compiler</param>
 /// <param name="node">xml node object</param>
 public void Load(ICompilateurInstance comp, System.Xml.XmlNode node)
 {
     if (node.Attributes.GetNamedItem("indent") != null)
     {
         Int32.TryParse(node.Attributes.GetNamedItem("indent").Value, out this.indent);
     }
     this.language = node.Attributes.GetNamedItem("language").Value;
     this.name     = node.Attributes.GetNamedItem("name").Value;
     this.legendes.Load(node.SelectSingleNode("legendes"));
     this.refs.Clear();
     foreach (XmlNode paramNode in node.SelectNodes("references/ref"))
     {
         if (!this.refs.Contains(paramNode.InnerText))
         {
             this.refs.Add(paramNode.InnerText);
         }
     }
     this.xmlCode = node.SelectSingleNode("code").InnerXml;
     // on en a besoin pour la conversion
     this.cachedComp = comp;
 }
예제 #20
0
 public Texte(ICompilateurInstance comp, IProcessInstance proc)
 {
     this.cachedComp = comp;
     this.cachedProc = proc;
 }
예제 #21
0
 public void Inject(Injector injector, ICompilateurInstance comp, System.Xml.XmlNode node, string modifier)
 {
     this.Load(comp, node);
 }
예제 #22
0
 public Affectation(ICompilateurInstance comp)
 {
     this.cachedComp = comp;
 }
예제 #23
0
 public void Load(ICompilateurInstance comp, System.Xml.XmlNode node)
 {
     this.localeName = node.InnerText;
     this.enc        = comp.EncodedFile;
 }
예제 #24
0
        public static void IsolatedFunction(ICompilateurInstance comp, IProcessInstance proc, ICodeConverter converter, IsolatedFunctionDelegate d)
        {
            if (converter.CurrentFunction.IsStaticControlFlow)
            {
                Dictionary <string, IParameter>             varNames, leftNames;
                Action <KeyValuePair <string, IParameter> > action;
                TypedVariable tv;

                IFunction prec     = converter.CurrentFunction;
                IFunction thisFunc = new Function();
                thisFunc.IndentSize = prec.IndentSize;
                thisFunc.IsVisible  = true;
                thisFunc.StrictName = "inner_" + comp.Unique.ComputeNewString();
                thisFunc.PropagateControlFlow(prec);

                // ajoute la fonction dans la liste
                converter.ImplementedFunctions.Add(thisFunc);
                // change la fonction courante
                converter.SetCurrentFunction(thisFunc);

                d();

                // retourne à la fonction précédente pour traiter le changement de type
                converter.SetCurrentFunction(prec);

                // supprime la fonction de la liste
                converter.ImplementedFunctions.Remove(thisFunc);

                leftNames = new Dictionary <string, IParameter>();
                // élimine les variables passées en paramètre qui n'ont pas changé de type
                thisFunc.Parameters.ForEach(new Action <IParameter>(delegate(IParameter par)
                {
                    if (!leftNames.ContainsKey(par.VariableName) && par.Order != EnumParameterOrder.E_NEW)
                    {
                        leftNames.Add(par.VariableName, par);
                    }
                }));
                // enregistre le nom distinct des variables passées en paramètre qui soient mutable et initiale
                varNames = new Dictionary <string, IParameter>();
                thisFunc.Parameters.ForEach(new Action <IParameter>(delegate(IParameter par)
                {
                    if (!varNames.ContainsKey(par.VariableName) && leftNames.ContainsKey(par.VariableName) && par.IsMutableParameter && par.Order == EnumParameterOrder.E_NEW)
                    {
                        varNames.Add(par.VariableName, par);
                    }
                }));
                // modifie toutes les variables en SimpleType
                action = new Action <KeyValuePair <string, IParameter> >(delegate(KeyValuePair <string, IParameter> kv)
                {
                    Regex reg       = new Regex(@"\$\[([^:]*):([a-z]+_" + kv.Key + @")\]");
                    thisFunc.Source = reg.Replace(thisFunc.Source, new MatchEvaluator(delegate(Match m)
                    {
                        string type   = m.Groups[1].Value;
                        string name   = m.Groups[2].Value;
                        int pos       = name.IndexOf('_');
                        string result = String.Empty;
                        if (pos != -1)
                        {
                            result = "$[" + type + ":st_" + name.Substring(pos + 1) + "]";
                        }
                        else
                        {
                            result = "$[" + type + ":st_" + name + "]";
                        }
                        return(result);
                    }));
                    tv = new TypedVariable(kv.Value.VariableName, kv.Value.FormalParameter, kv.Value.DataType, EnumDataType.E_SIMPLETYPE);
                    tv.MoveType(converter, proc.CurrentScope);
                });
                foreach (KeyValuePair <string, IParameter> kv in varNames.Except(leftNames))
                {
                    action(kv);
                }
                // copie de l'implémentation de cette fonction dans la fonction en cours
                prec.Source += thisFunc.Source;
                // copies des variables locales de cette fonction dans la fonction en cours
                thisFunc.LocalVariables.ForEach(new Action <IStructure>(delegate(IStructure loc)
                {
                    if (!converter.CurrentFunction.LocalVariables.Exists(new Predicate <IStructure>(delegate(IStructure cur)
                    {
                        return(cur.PrefixedFieldName == loc.PrefixedFieldName);
                    })))
                    {
                        converter.CurrentFunction.LocalVariables.Add(loc);
                    }
                }));
                // mettre à jour les paramètres
                foreach (KeyValuePair <string, IParameter> kv in varNames.Except(leftNames))
                {
                    List <IParameter> pars = thisFunc.Parameters.FindAll(new Predicate <IParameter>(delegate(IParameter par)
                    {
                        return(par.VariableName == kv.Key);
                    }));
                    if (pars.Count > 1)
                    {
                        pars.ForEach(new Action <IParameter>(delegate(IParameter update)
                        {
                            if (update.Order == EnumParameterOrder.E_LAST)
                            {
                                tv = new TypedVariable(update.VariableName, update.FormalParameter, EnumDataType.E_SIMPLETYPE, update.DataType);
                                tv.MoveType(converter, proc.CurrentScope);
                            }
                        }));
                    }
                    else if (pars.Count == 1)
                    {
                        tv = new TypedVariable(pars[0].VariableName, pars[0].FormalParameter, EnumDataType.E_SIMPLETYPE, pars[0].DataType);
                        tv.MoveType(converter, proc.CurrentScope);
                    }
                }
            }
            else
            {
                d();
            }
        }
예제 #25
0
        public void ConvertToParallel(ICodeConverter converter, ICompilateurInstance comp, IProcessInstance previousProc, FinalFile file)
        {
            EndJobs ej = new EndJobs();

            this.cachedComp         = comp;
            this.cachedPreviousFunc = converter.ImplementedFunctions.FindLast(new Predicate <IFunction>(delegate(IFunction search)
            {
                return(search.StrictName == previousProc.FunctionName);
            }));

            // première instruction
            this.Statements[0].Convert(converter, previousProc, file);

            // implémenter les fonctions job_xxx
            for (int index = 1; index < this.Statements.Count - 1; ++index)
            {
                ICompiler tache = this.Statements[index];
                // Check if it's a call job (blindage)
                if (tache is CallJob)
                {
                    CallJob cj = this.Statements[index] as CallJob;
                    ej.Jobs.Add(cj);

                    this.cachedProc = this.cachedComp.GetJobProcess(cj.ProcessName);
                    // Ecriture du code de la fonction
                    IFunction newFunc = Helper.MakeNewMethod(converter, this.cachedProc);
                    Helper.FillNewMethod(comp, this.cachedProc, converter, newFunc, file);
                    newFunc.IsJob = true;
                    //if (this.cachedProc.HasChanged) previousProc.HasChanged = true;

                    // aller chercher les variables exterieures au processus appellé
                    this.cachedFunc = converter.ImplementedFunctions.FindLast(new Predicate <IFunction>(delegate(IFunction func) { return(func.IsJob && func.StrictName == cj.ProcessName); }));
                    if (!converter.CallingFunctions.Exists(new Predicate <IFunction>(delegate(IFunction func) { return(func.IsJob && func.StrictName == cj.ProcessName && func.InstanceNumber == this.cachedFunc.InstanceNumber); })))
                    {
                        converter.CallingFunctions.Add(this.cachedFunc);
                    }

                    // convertir pour le parallèllisme
                    if (!this.alreadyInstantiated)
                    {
                        // create a new structure to contain all external values
                        string structTypeName = this.cachedComp.Unique.ComputeNewString();
                        ++converter.CurrentFunction.PrivateVariableCounter;
                        string structInstanceName = structTypeName + converter.CurrentFunction.PrivateVariableCounter.ToString();

                        // Construit une structure et indique que l'instance doit être mutable
                        this.structRef = converter.CreateNewField(structTypeName, structInstanceName, true);
                    }

                    // ajoute une instance de la structure déclarée dans la fonction en cours
                    if (converter.IsStronglyTyped)
                    {
                        this.cachedFunc.InstancesStructure.Add(this.Structure.PrefixedFieldName, this.Structure.StructureType);
                    }
                    else
                    {
                        this.cachedFunc.InstancesStructure.Add(this.Structure.FieldName, this.Structure.StructureType);
                    }

                    // créer un nouveau paramètre et y inscrire tous les autres paramètres
                    Converters.Parameter parStructure = new Parameter();
                    parStructure.EffectiveParameter = this.Structure.PrefixedFieldName;
                    parStructure.FormalParameter    = this.Structure.PrefixedFieldName;
                    parStructure.VariableName       = this.Structure.FieldName;
                    parStructure.IsComputable       = false;
                    parStructure.IsMutableParameter = true;
                    // stocker tous les paramètres dans le nouveau paramètre de type structure
                    List <IStructure> newParams = this.GetElements(this.structList, converter, this.cachedFunc).ToList();
                    parStructure.StructureReferences.AddRange(newParams);
                    this.structList       = newParams;
                    parStructure.DataType = EnumDataType.E_STRUCTURE;

                    this.cachedFunc.Parameters.Clear();
                    this.cachedFunc.Parameters.Add(parStructure);
                    this.alreadyInstantiated = true;
                }
            }

            // ajout de la structure
            converter.Convert(this);

            // création des instructions en parallèle
            // appels des fonctions job_xxx
            for (int index = 1; index < this.Statements.Count - 1; ++index)
            {
                ICompiler tache = this.Statements[index];
                // Check if it's a call job (blindage)
                if (tache is CallJob)
                {
                    CallJob cj = tache as CallJob;
                    cj.StructureReference = this.Structure;
                    this.cachedProc       = this.cachedComp.GetJobProcess(cj.ProcessName);
                    this.cachedProc.MakeOneInstance(previousProc, new RunInnerInstanceProcess(delegate(IProcessInstance previous, IProcessInstance i)
                    {
                        cj.Convert(converter, i, file);
                    }));
                }
            }

            // attendre la fin de toutes les tâches
            ej.WaitForAllJobs(converter);

            // dernière instruction
            this.Statements[this.Statements.Count - 1].Convert(converter, previousProc, file);
        }
예제 #26
0
 public void Load(ICompilateurInstance comp, System.Xml.XmlNode node)
 {
 }
예제 #27
0
 public CallJob(ICompilateurInstance comp)
 {
     this.cachedComp = comp;
 }