Esempio n. 1
0
        /// <summary>
        /// Helper for checking procedure calls.
        /// Type checks the input, type checks the output.
        /// Throws an exception when an error is found.
        /// </summary>
        /// <param name="seqCompProcCall">The procedure call to check</param>
        /// <param name="ownerType">Gives the owner type of the procedure method call, in case this is a method call, otherwise null</param>
        private void CheckProcedureCallBase(SequenceComputationProcedureCall seqCompProcCall, GrGenType ownerType)
        {
            CheckInputParameters(seqCompProcCall, seqCompProcCall.ArgumentExpressions, ownerType);
            CheckOutputParameters(seqCompProcCall, seqCompProcCall.ReturnVars, ownerType);

            // ok, this is a well-formed invocation
        }
Esempio n. 2
0
        /// <summary>
        /// pre-run for emitting the needed entities before emitting the real code
        /// - emits sequence variable declarations (only once for every variable, declaration only possible at assignment targets)
        /// </summary>
        private void EmitNeededVarEntities(SequenceComputation seqComp, SourceBuilder source)
        {
            source.AppendFront(COMP_HELPER.DeclareResultVar(seqComp));

            switch (seqComp.SequenceComputationType)
            {
            case SequenceComputationType.Assignment:
            {
                SequenceComputationAssignment assign = (SequenceComputationAssignment)seqComp;
                EmitNeededVarEntities(assign.Target, source);
                if (assign.SourceValueProvider is SequenceComputationAssignment)
                {
                    EmitNeededVarEntities(assign.SourceValueProvider, source);
                }
                break;
            }

            case SequenceComputationType.ProcedureCall:
            {
                SequenceComputationProcedureCall seqProc = (SequenceComputationProcedureCall)seqComp;
                // no handling for the input arguments seqProc.ArgumentExpressions needed
                // because there can only be variable uses
                for (int i = 0; i < seqProc.ReturnVars.Length; ++i)
                {
                    EmitVarIfNew(seqProc.ReturnVars[i], source);
                }
                break;
            }

            case SequenceComputationType.BuiltinProcedureCall:
            {
                SequenceComputationBuiltinProcedureCall seqProc = (SequenceComputationBuiltinProcedureCall)seqComp;
                // no handling for the input arguments seqProc.ArgumentExpressions needed
                // because there can only be variable uses
                for (int i = 0; i < seqProc.ReturnVars.Count; ++i)
                {
                    EmitVarIfNew(seqProc.ReturnVars[i], source);
                }
                break;
            }

            default:
                foreach (SequenceComputation childSeqComp in seqComp.Children)
                {
                    EmitNeededVarEntities(childSeqComp, source);
                }
                break;
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Helper for checking procedure calls.
 /// Type checks the input, type checks the output.
 /// Throws an exception when an error is found.
 /// </summary>
 /// <param name="seqCompProcCall">The procedure call to check</param>
 public void CheckProcedureCall(SequenceComputationProcedureCall seqCompProcCall)
 {
     CheckProcedureCallBase(seqCompProcCall, null);
 }