示例#1
0
 public void Convert(Converters.ICodeConverter converter, IProcessInstance proc, FinalFile file)
 {
     if (proc.CurrentScope.Exists(proc.DefaultWriter))
     {
         this.defaultWriter = proc.DefaultWriter;
         converter.Convert(this);
     }
 }
 public void Convert(Converters.ICodeConverter converter, IProcessInstance proc, FinalFile file)
 {
     this.cachedProc = proc;
     if (converter.ImplementedFunctions.Exists(new Predicate <IFunction>(delegate(IFunction f) { return(f.StrictName == CallSkeleton.SpecialChars(this.name)); })))
     {
         converter.Convert(this);
     }
     else
     {
         throw new Exception("Pour convertir le programme, les processus doivent être déclarés auparavant; le processus '" + this.name + "' n'a pas été déclaré auparavant");
     }
 }
示例#3
0
        public void Convert(Converters.ICodeConverter converter, IProcessInstance proc, FinalFile file)
        {
            o2Mate.Expression expr = new o2Mate.Expression();
            this.directories = new List <string>();
            for (int index = 0; index < this.filePath.Count - 1; ++index)
            {
                string expression = this.filePath[index];
                string path       = Helper.ConvertNewExpression(this.cachedComp, proc, converter, expression, EnumDataType.E_STRING_OBJECT);
                this.directories.Add(path);
            }
            this.fileName = new List <string>();
            {
                string   expression = this.filePath[this.filePath.Count - 1];
                string[] split      = expression.Split('.');
                foreach (string s in split)
                {
                    string path = Helper.ConvertNewExpression(this.cachedComp, proc, converter, s, EnumDataType.E_STRING_OBJECT);
                    this.fileName.Add(path);
                }
            }

            if (proc.CurrentScope.Exists(this.writerName))
            {
                this.newWriter = proc.CurrentScope.GetVariable(this.writerName);
                if (this.newWriter.TypeExists(EnumDataType.E_WRITER))
                {
                    proc.CurrentScope.Update(this.writerName, "", this.newWriter.PrefixInfo(EnumDataType.E_WRITER).BelongsTo, false, EnumDataType.E_WRITER);
                    this.cachedComp.UpdateParameters(converter, proc, this.writerName, true);
                }
                else
                {
                    this.newWriter = proc.CurrentScope.Update(this.writerName, "", proc.Name, false, EnumDataType.E_WRITER);
                    IStructure st = converter.CreateNewField(converter.RootStructureInstance, this.newWriter, false);
                    converter.CurrentFunction.LocalVariables.Add(st);
                }
            }
            else
            {
                this.newWriter = proc.CurrentScope.Add(this.writerName, "", proc.Name, false, EnumDataType.E_WRITER);
                IStructure st = converter.CreateNewField(converter.RootStructureInstance, this.newWriter, false);
                converter.CurrentFunction.LocalVariables.Add(st);
            }
            converter.Convert(this);
        }
示例#4
0
 /// <summary>
 /// Converts the object and write specific statements for an another programming language
 /// </summary>
 /// <param name="converter">the language converter</param>
 /// <param name="proc">current process</param>
 /// <param name="file">final file</param>
 public void Convert(Converters.ICodeConverter converter, IProcessInstance proc, FinalFile file)
 {
 }
 public void Convert(Converters.ICodeConverter converter, IProcessInstance proc, FinalFile file)
 {
     proc.DefaultWriter = this.varName;
 }
示例#6
0
        /// <summary>
        /// Converts this statement for a particular programming language destination
        /// </summary>
        /// <param name="converter">converter object</param>
        /// <param name="proc">process object</param>
        /// <param name="file">final file</param>
        public void Convert(Converters.ICodeConverter converter, IProcessInstance proc, FinalFile file)
        {
            string        name         = null;
            List <string> skeletonPath = null;
            string        modifier     = null;

            if (this.ParseCommand(this.command, out name, out skeletonPath, out modifier))
            {
                // rechercher le MOP source
                CreateMOP mopSrc = this.cachedComp.GetMOP(this.language, name);

                // charge l'extrait de code du mop
                XmlDocument doc = new XmlDocument();
                doc.PreserveWhitespace = false;
                doc.LoadXml("<code>" + mopSrc.XmlCode + "</code>");

                if (skeletonPath.Count == 0 || String.IsNullOrEmpty(modifier))
                {
                    // cas lorsque l'on insère dans le processus en cours

                    // fabrication d'un processus
                    Process subProcess = new Process();
                    subProcess.Name = this.MOPToFunctionName(mopSrc.Language + "_" + mopSrc.Name);

                    // ajouter les affectations pour chaque paramètre
                    string[] tab;
                    if (!String.IsNullOrEmpty(this.expression))
                    {
                        tab = this.expression.Split(',');
                    }
                    else
                    {
                        tab = new string[0];
                    }
                    int index = 0;
                    Dictionary <string, string> values = new Dictionary <string, string>();
                    while (index < mopSrc.References.Count)
                    {
                        if (index < tab.Length)
                        {
                            values.Add(mopSrc.References[index], tab[index]);
                        }
                        ++index;
                    }
                    if (index < tab.Length && mopSrc.References.Count > 0)
                    {
                        values[mopSrc.References[mopSrc.References.Count - 1]] += "array(" + String.Join(",", tab, index, tab.Length - index) + ")";
                    }
                    foreach (KeyValuePair <string, string> kv in values)
                    {
                        Converters.Parameter param = new Parameter();
                        param.FormalParameter      = kv.Key.Trim();
                        param.ReplacementParameter = kv.Value.Trim();
                        o2Mate.Expression expr = new o2Mate.Expression();
                        o2Mate.IData      res  = expr.Evaluate(kv.Value.Trim(), proc.CurrentScope);
                        param.EffectiveParameter = res.ValueString;
                        param.IsComputable       = res.IsComputable;
                        subProcess.Replacements.Add(param);
                    }

                    if (this.localInjector != null)
                    {
                        // on recherche le début de l'injection
                        this.localInjector.InjectedProcess.Remove(this.localInjector.Current, this.localInjector.After - 1);
                        this.localInjector.InjectedProcess.Remove(this.localInjector.Before, this.localInjector.Current - 1);
                        this.localInjector.Current = this.localInjector.Before;
                        this.localInjector.After   = this.localInjector.Before + 1;
                    }
                    else
                    {
                        this.localInjector                 = new Injector();
                        this.localInjector.Current         = this.localInjector.Before = proc.Objects.IndexOf(this);
                        this.localInjector.After           = this.localInjector.Before + 1;
                        this.localInjector.InjectedProcess = proc;
                    }
                    this.cachedComp.Injection(this.localInjector, doc.DocumentElement, "after");

                    // on implémente une fonction avec ce processus
                    Call c = new Call(this.cachedComp, proc);
                    c.ProcessName = subProcess.Name;
                    c.Convert(converter, proc, file);
                }
                else
                {
                    // cas d'utilisation d'un inserteur

                    string insert = String.Empty;
                    bool   first  = true;
                    foreach (string path in skeletonPath)
                    {
                        if (!first)
                        {
                            insert += "/";
                        }
                        else
                        {
                            first = false;
                        }
                        insert += path;
                    }
                    Injector j = this.cachedComp.GetInjector(insert);

                    // lorsque l'injecteur a déjà été utilisé
                    if (!j.IsEmpty && modifier == "replace")
                    {
                        // on efface tout
                        // on recherche le début de l'injection
                        j.InjectedProcess.Remove(j.Current, j.After - 1);
                        j.InjectedProcess.Remove(j.Before, j.Current - 1);
                        j.Current = j.Before;
                        j.After   = j.Before + 1;
                    }

                    // ajouter les affectations pour chaque paramètre
                    string[] tab;
                    if (!String.IsNullOrEmpty(this.expression))
                    {
                        tab = this.expression.Split(',');
                    }
                    else
                    {
                        tab = new string[0];
                    }
                    int index = 0;
                    Dictionary <string, string> values = new Dictionary <string, string>();
                    while (index < mopSrc.References.Count)
                    {
                        if (index < tab.Length)
                        {
                            values.Add(mopSrc.References[index], tab[index]);
                        }
                        ++index;
                    }
                    if (index < tab.Length && mopSrc.References.Count > 0)
                    {
                        values[mopSrc.References[mopSrc.References.Count - 1]] += "array(" + String.Join(",", tab, index, tab.Length - index) + ")";
                    }

                    j.InjectedProcess.Replacements.Clear();
                    foreach (KeyValuePair <string, string> kv in values)
                    {
                        Converters.Parameter param = new Parameter();
                        param.FormalParameter      = kv.Key.Trim();
                        param.ReplacementParameter = kv.Value.Trim();
                        o2Mate.Expression expr = new o2Mate.Expression();
                        o2Mate.IData      res  = expr.Evaluate(kv.Value.Trim(), proc.CurrentScope);
                        param.EffectiveParameter = res.ValueString;
                        param.IsComputable       = res.IsComputable;
                        j.InjectedProcess.Replacements.Add(param);
                    }

                    this.cachedComp.Injection(j, doc.DocumentElement, modifier);
                    // le processus a été modifié
                    j.InjectedProcess.HasChanged = true;
                }
            }
            else
            {
                throw new FormatException("Format de la commande '" + this.command + "' inattendue");
            }
        }
示例#7
0
 public void Convert(Converters.ICodeConverter converter, IProcessInstance proc, FinalFile file)
 {
     this.defaultWriter = proc.DefaultWriter;
     converter.Convert(this);
 }