Beispiel #1
0
 public override bool Visit(CallableDeclaration node)
 {
     Visit((Declaration)node);
     TraverseSetParent(node, node.Type);
     TraverseSetParent(node, node.Directives);
     return(true);
 }
Beispiel #2
0
        public override bool Visit(DeclarationList node)
        {
            CallableDeclaration insideFunction = declEnv.GetDeclaringRoutine();
            Section             outside        = insideFunction.declaringSection;

            for (int i = node.nodes.Count - 1; i >= 0; i--)
            {
                if (insideFunction != null && node.nodes[i] is CallableDeclaration)
                {
                    string name = node.nodes[i].ToString();
                    Console.WriteLine("Nesting: " + name);
                    CallableDeclaration decl = node.nodes[i] as CallableDeclaration;

                    string oldname = decl.name;
                    string newname = insideFunction.name + "_" + decl.name;
                    replacements[oldname] = newname;
                    decl.name             = newname;

                    node.nodes.RemoveAt(i);
                    if (!outside.decls.Contains(decl))
                    {
                        outside.decls.AddStart(decl);
                    }

                    traverse(decl);

                    //replacements.Remove(oldname);
                }
                else
                {
                    traverse(node.nodes[i]);
                }
            }
            return(true);
        }
Beispiel #3
0
        public override bool Visit(CallableDeclaration node)
        {
            ProceduralType pp = node.type as ProceduralType;

            traverse(pp.funcret);
            string name = node.name as string;

            outputCode(name, false, false);
            outputCode("(", false, false);

            DeclarationList p = [email protected];
            int             i = 0;

            foreach (ParamDeclaration pd in p)
            {
                if (i > 0)
                {
                    outputCode(", ", false, false);
                }
                traverse(pd);
                i++;
            }
            outputCode(")", false, true);
            traverse(node.Directives);
            return(true);
        }
Beispiel #4
0
        public SerializedType VisitCallableDeclaration(CallableDeclaration cd)
        {
            var dtRet = cd.ReturnType != null
                ? cd.ReturnType.Accept(this)
                : new VoidType_v1();

            var parameters = new List <Argument_v1>();

            foreach (var pc in cd.Parameters)
            {
                if (pc.Type == null)
                {
                    parameters.Add(new Argument_v1 {
                        Name = "..."
                    });
                }
                else
                {
                    var dt = pc.Type.Accept(this);
                    if (pc.ByReference)
                    {
                        dt = new ReferenceType_v1 {
                            Referent = dt, Size = 4
                        };
                    }
                    foreach (var n in pc.ParameterNames)
                    {
                        var p = new Argument_v1 {
                            Name = n, Type = dt
                        };
                        parameters.Add(p);
                    }
                }
            }
            return(new SerializedSignature
            {
                Arguments = parameters.ToArray(),
                ReturnValue = new Argument_v1 {
                    Type = dtRet
                }
            });
        }
 public virtual T Visit(CallableDeclaration node)
 {
     return(Visit((Declaration)node));
 }
Beispiel #6
0
 public Constant VisitCallableDeclaration(CallableDeclaration cd)
 {
     throw new NotImplementedException();
 }
Beispiel #7
0
 public SerializedType VisitCallableDeclaration(CallableDeclaration cd)
 {
     return(DoCallableType(cd.Parameters, cd.ReturnType));
 }