Пример #1
0
        /// <summary>
        /// Provides the changes performed by this statement
        /// </summary>
        /// <param name="context">The context on which the changes should be computed</param>
        /// <param name="changes">The list to fill with the changes</param>
        /// <param name="explanation">The explanatino to fill, if any</param>
        /// <param name="apply">Indicates that the changes should be applied immediately</param>
        public override void GetChanges(InterpretationContext context, ChangeList changes, ExplanationPart explanation, bool apply)
        {
            if (Call != null)
            {
                InterpretationContext ctxt      = getContext(context);
                Functions.Procedure   procedure = Call.getProcedure(ctxt);
                if (procedure != null)
                {
                    ExplanationPart part = new ExplanationPart(Root);
                    part.Message = procedure.FullName;
                    explanation.SubExplanations.Add(part);

                    int token = ctxt.LocalScope.PushContext();
                    foreach (KeyValuePair <Variables.Actual, Values.IValue> pair in Call.AssignParameterValues(context, procedure, true))
                    {
                        ctxt.LocalScope.setVariable(pair.Key, pair.Value);
                    }

                    foreach (Rules.Rule rule in Rules)
                    {
                        ApplyRule(rule, changes, ctxt, part);
                    }

                    ctxt.LocalScope.PopContext(token);
                }
                else
                {
                    AddError("Cannot determine the called procedure for " + ToString());
                }
            }
            else
            {
                AddError("Expression " + ToString() + " is not a valid procedure call");
            }
        }
Пример #2
0
 /// <summary>
 /// Adds a model element in this model element
 /// </summary>
 /// <param name="copy"></param>
 public override void AddModelElement(Utils.IModelElement element)
 {
     {
         Range item = element as Range;
         if (item != null)
         {
             appendRanges(item);
         }
     }
     {
         Enum item = element as Enum;
         if (item != null)
         {
             appendEnumerations(item);
         }
     }
     {
         Structure item = element as Structure;
         if (item != null)
         {
             appendStructures(item);
         }
     }
     {
         Collection item = element as Collection;
         if (item != null)
         {
             appendCollections(item);
         }
     }
     {
         Functions.Function item = element as Functions.Function;
         if (item != null)
         {
             appendFunctions(item);
         }
     }
     {
         Functions.Procedure item = element as Functions.Procedure;
         if (item != null)
         {
             appendProcedures(item);
         }
     }
     {
         Rules.Rule item = element as Rules.Rule;
         if (item != null)
         {
             appendRules(item);
         }
     }
     {
         Variables.Variable item = element as Variables.Variable;
         if (item != null)
         {
             appendVariables(item);
         }
     }
 }
Пример #3
0
 /// <summary>
 /// Checks the statement for semantical errors
 /// </summary>
 public void CheckStatement(InterpretationContext context)
 {
     Call.checkExpression();
     if (Call != null)
     {
         Functions.Procedure procedure = Call.getProcedure(context);
         if (procedure != null)
         {
         }
         else
         {
             Root.AddError("Cannot determine called procedure (2)");
         }
     }
     else
     {
         Root.AddError("Cannot determine called procedure (1)");
     }
 }
Пример #4
0
        /// <summary>
        /// The procedure which is called by this call statement
        /// </summary>
        public Functions.Procedure getProcedure(InterpretationContext context)
        {
            Functions.Procedure retVal = getCalled(context) as Functions.Procedure;

            return(retVal);
        }
Пример #5
0
        /// <summary>
        /// Indicates that this rule has been defined in a procedure
        /// </summary>
        /// <returns></returns>
        public bool BelongsToAProcedure()
        {
            Functions.Procedure procedure = Utils.EnclosingFinder <Functions.Procedure> .find(this);

            return(procedure != null);
        }