Ejemplo n.º 1
0
            public override bool Accept(FunctionDeclaration element, int data)
            {
                if (functions.ContainsKey(element.name))
                {
                    throw new NotSupportedException("fucntion redefenition/overloading is ont supported");
                }
                if (currentFunction != null)
                {
                    throw new NotSupportedException("Nested functions are not supported");
                }
                currentFunction = element;

                functions[element.name] = typeBuilder.DefineMethod(element.name, MethodAttributes.Public | MethodAttributes.Static, element.hasReturn ? typeof(long) : typeof(void), element.GetArgumentTypes());
                if (!element.block.Accept(this, 0) && element.hasReturn)
                {
                    throw new InvalidOperationException("Not all paths of execution return value");
                }

                currentFunction = null;
                return(true);
            }