예제 #1
0
            internal static DataType CreateParameter([NotNull] CallSiteParameter p, CodeModel.SymbolTable table)
            {
                if (p.IsOmitted)
                {
                    return(DataType.Omitted);
                }

                DataType type      = null;
                var      parameter = p.StorageAreaOrValue;

                if (parameter != null)
                {
                    if (parameter.IsLiteral)
                    {
                        if (parameter.NumericValue != null)
                        {
                            type = DataType.Numeric;
                        }
                        else
                        if (parameter.AlphanumericValue != null)
                        {
                            type = DataType.Alphanumeric;
                        }
                        else
                        {
                            type = DataType.Unknown;
                        }
                    }
                    else
                    {
                        if (table != null)
                        {
                            var found = table.GetVariables(parameter);
                            foreach (var item in found)
                            {
                                var data = item as Nodes.DataDescription;
                                if (data == null)
                                {
                                    type = DataType.Unknown;
                                }
                                else if (type == null)
                                {
                                    type = data.DataType;
                                }
                                else if (type != data.DataType)
                                {
                                    type = DataType.Unknown;
                                }
                            }
                        }

                        if (type == null)
                        {
                            type = DataType.Unknown;
                        }
                    }
                    return(type);
                }
                return(DataType.Unknown);
            }
예제 #2
0
        /// <summary>
        /// Get the String representation of an parameter with a Sharing Mode.
        /// Rule: TCCODEGEN_FUNCALL_PARAMS
        /// </summary>
        /// <param name="parameter">The Parameter</param>
        /// <param name="table">The Symbol table</param>
        /// <param name="mode">Argument mode Input, InOut, Output, etc...</param>
        /// <param name="previousSharingMode">The previous Sharing Mode</param>
        /// <param name="previousSpan">The previous marging span</param>
        /// <returns>The String representation of the Sharing Mode paramaters</returns>
        private string ToString(TypeCobol.Compiler.CodeElements.CallSiteParameter parameter, Compiler.CodeModel.SymbolTable table, ArgMode mode,
                                ref TypeCobol.Compiler.CodeElements.ParameterSharingMode previousSharingMode, ref int previousSpan)
        {
            Variable variable    = parameter.StorageAreaOrValue;
            var      name        = variable.ToString(true);
            string   share_mode  = "";
            int      defaultSpan = string.Intern("by reference ").Length;

            if (parameter.SharingMode.Token != null)
            {
                if (previousSharingMode != parameter.SharingMode.Value)
                {
                    share_mode          = "by " + parameter.SharingMode.Token.Text;
                    share_mode         += new string(' ', defaultSpan - share_mode.Length);
                    previousSharingMode = parameter.SharingMode.Value;
                }
            }
            else
            {
                if (mode == ArgMode.InOut || mode == ArgMode.Output)
                {
                    if (previousSharingMode != TypeCobol.Compiler.CodeElements.ParameterSharingMode.ByReference)
                    {
                        share_mode          = string.Intern("by reference ");
                        previousSharingMode = TypeCobol.Compiler.CodeElements.ParameterSharingMode.ByReference;
                    }
                }
            }
            if (share_mode.Length == 0)
            {
                share_mode = new string(' ', previousSpan == 0 ? defaultSpan : previousSpan);
            }
            else
            {
                previousSpan = share_mode.Length;
            }

            if (variable.IsLiteral)
            {
                return(share_mode + name);
            }
            var found = table.GetVariable(variable);

            if (found.Count < 1) //this can happens for special register : LENGTH OF, ADDRESS OF
            {
                return(share_mode + variable.ToCobol85());
            }
//		if (found.Count > 1) return "?AMBIGUOUS?";
            var data = found[0] as Compiler.Nodes.DataDescription;

            if (data.DataType == DataType.Boolean)
            {
                name += "-value";
            }
            return(share_mode + name);
        }
예제 #3
0
            internal static DataType CreateParameter([NotNull] CallSiteParameter p, Node node)
            {
                if (p.IsOmitted)
                {
                    return(DataType.Omitted);
                }

                DataType type      = null;
                var      parameter = p.StorageAreaOrValue;

                if (parameter != null)
                {
                    if (parameter.IsLiteral)
                    {
                        if (parameter.NumericValue != null)
                        {
                            type = DataType.Numeric;
                        }
                        else
                        if (parameter.AlphanumericValue != null)
                        {
                            type = DataType.Alphanumeric;
                        }
                        else
                        {
                            type = DataType.Unknown;
                        }
                    }
                    else
                    {
                        if (node != null)
                        {
                            var found = node.GetDataDefinitionFromStorageAreaDictionary(parameter.StorageArea);
                            var data  = found as DataDescription;
                            type = data == null ? DataType.Unknown : data.DataType;
                        }

                        if (type == null)
                        {
                            type = DataType.Unknown;
                        }
                    }
                    return(type);
                }
                return(DataType.Unknown);
            }
예제 #4
0
 public UserDefinedFunctionCall(SymbolReference functionName, CallSiteParameter[] arguments)
     : base(FunctionCallType.UserDefinedFunctionCall, arguments)
 {
     UserDefinedFunctionName = functionName;
 }
예제 #5
0
 public IntrinsicFunctionCall(ExternalName intrinsicFunctionName, CallSiteParameter[] arguments)
     : base(FunctionCallType.IntrinsicFunctionCall, arguments)
 {
     IntrinsicFunctionName = intrinsicFunctionName;
 }
예제 #6
0
 internal static DataType CreateParameter(CallSiteParameter p, CodeModel.SymbolTable table)
 {
     DataType type = null;
     var parameter = p.StorageAreaOrValue;
     if (parameter.IsLiteral) {
     if (parameter.NumericValue != null)
          type = DataType.Numeric;
     else
     if (parameter.AlphanumericValue != null)
          type = DataType.Alphanumeric;
     else type = DataType.Unknown;
     } else {
     var found = table.GetVariable(new URI(parameter.ToString()));
     foreach(var item in found) {
         var data = item as Nodes.DataDescription;
         if (type == null) type = data.DataType;
         else if (type != data.DataType) type = DataType.Unknown;
     }
     if (type == null) type = DataType.Unknown;
     }
     return type;
 }
예제 #7
0
 public FunctionCall(FunctionCallType type, CallSiteParameter[] arguments)
 {
     Type = type;
     Arguments = arguments;
 }
예제 #8
0
        /// <summary>
        /// Get the String representation of an parameter with a Sharing Mode.
        /// Rule: TCCODEGEN_FUNCALL_PARAMS
        /// </summary>
        /// <param name="parameter">The Parameter</param>
        /// <param name="node">The node</param>
        /// <param name="mode">Argument mode Input, InOut, Output, etc...</param>
        /// <param name="previousSharingMode">The previous Sharing Mode</param>
        /// <param name="previousSpan">The previous marging span</param>
        /// <returns>The String representation of the Sharing Mode paramaters</returns>
        private string ToString(TypeCobol.Compiler.CodeElements.CallSiteParameter parameter, Node node, ArgMode mode,
                                ref TypeCobol.Compiler.CodeElements.ParameterSharingMode previousSharingMode, ref int previousSpan)
        {
            Variable variable  = parameter.StorageAreaOrValue;
            bool     bTypeBool = false;

            if (variable != null)
            {//We must detect a boolean variable
                if (!variable.IsLiteral)
                {
                    var found = node.GetDataDefinitionFromStorageAreaDictionary(variable.StorageArea);
                    if (found != null)
                    {
                        var data = found as DataDescription;
                        bTypeBool = (data != null && data.DataType == DataType.Boolean);
                    }
                }
            }

            var name = parameter.IsOmitted ? "omitted" : variable.ToString(true, bTypeBool);

            string share_mode  = "";
            int    defaultSpan = string.Intern("by reference ").Length;

            if (parameter.SharingMode.Token != null)
            {
                if (previousSharingMode != parameter.SharingMode.Value)
                {
                    share_mode          = "by " + parameter.SharingMode.Token.Text;
                    share_mode         += new string(' ', defaultSpan - share_mode.Length);
                    previousSharingMode = parameter.SharingMode.Value;
                }
            }
            else
            {
                if (mode == ArgMode.InOut || mode == ArgMode.Output)
                {
                    if (previousSharingMode != TypeCobol.Compiler.CodeElements.ParameterSharingMode.ByReference)
                    {
                        share_mode          = string.Intern("by reference ");
                        previousSharingMode = TypeCobol.Compiler.CodeElements.ParameterSharingMode.ByReference;
                    }
                }
            }
            if (share_mode.Length == 0)
            {
                share_mode = new string(' ', previousSpan == 0 ? defaultSpan : previousSpan);
            }
            else
            {
                previousSpan = share_mode.Length;
            }

            if (variable != null)
            {
                if (variable.IsLiteral)
                {
                    return(share_mode + name);
                }
                var found = node.GetDataDefinitionFromStorageAreaDictionary(variable.StorageArea);
                if (found == null) //this can happens for special register : LENGTH OF, ADDRESS OF
                {
                    return(share_mode + variable.ToCobol85());
                }
            }
            return(share_mode + name);
        }
예제 #9
0
 private CallSiteParameter[] CreateArguments(CodeElementsParser.ArgumentContext[] argumentContext)
 {
     CallSiteParameter[] arguments = new CallSiteParameter[argumentContext.Length];
     for(int i = 0; i < argumentContext.Length; i++) {
         var variableOrExpression = CreateSharedVariableOrExpression(argumentContext[i].sharedVariableOrExpression1());
         if (variableOrExpression != null) {
             arguments[i] = new CallSiteParameter() { StorageAreaOrValue = variableOrExpression };
         }
     }
     return arguments;
 }
예제 #10
0
 public virtual bool Visit(CallSiteParameter callSiteParameter)
 {
     return(true);
 }