示例#1
0
		internal override ExprSingle CompileCore (XQueryASTCompiler compiler)
		{
			if (Content != null)
				for (int i = 0; i < Content.Count; i++)
					Content [i] = Content [i].Compile (compiler);
			return this;
		}
示例#2
0
 internal override void Compile(XQueryASTCompiler compiler)
 {
     schemaType = compiler.ResolveSchemaType(TypeName);
     if (schemaType == null)
     {
         throw new XmlQueryCompileException("Specified schema type was not found.");
     }
 }
示例#3
0
        private void CompileProlog()
        {
            Prolog p = module.Prolog;

            // resolve external modules
            // FIXME: check if external queries are allowed by default.
            // FIXME: check recursion
            XmlUrlResolver res = new XmlUrlResolver();

            foreach (ModuleImport modimp in p.ModuleImports)
            {
                foreach (string uri in modimp.Locations)
                {
                    Stream s = res.GetEntity(res.ResolveUri(null, uri), null, typeof(Stream)) as Stream;
                    XQueryLibraryModule ext = Mono.Xml.XQuery.Parser.Parser.Parse(new StreamReader(s)) as XQueryLibraryModule;
                    if (ext == null)
                    {
                        throw new XmlQueryCompileException(String.Format("External module {0} is resolved as a main module, while it should be a library module."));
                    }
                    XQueryStaticContext sctx = new XQueryASTCompiler(ext, options, compileContext, evidence, commandImpl).Compile();
                    libModuleContexts.Add(sctx);
                }
            }

            // resolve and compile in-scope schemas
            foreach (SchemaImport xsimp in p.SchemaImports)
            {
                foreach (string uri in xsimp.Locations)
                {
                    XmlSchema schema = inScopeSchemas.Add(xsimp.Namespace, uri);
                    compileContext.InEffectSchemas.Add(schema);
                }
            }
            inScopeSchemas.Compile();

            CheckReferences();

            ResolveVariableReferences();

            // compile FunctionDeclaration into XQueryFunction
            foreach (FunctionDeclaration func in p.Functions.Values)
            {
                XQueryFunction cfunc = CompileFunction(func);
                localFunctions.Add(cfunc);
            }
        }
示例#4
0
		internal override void CheckReference (XQueryASTCompiler compiler)
		{
			Content.CheckReference (compiler);
		}
示例#5
0
		internal override void Compile (XQueryASTCompiler compiler)
		{
		}
示例#6
0
		internal override void Compile (XQueryASTCompiler compiler)
		{
			schemaType = compiler.ResolveSchemaType (TypeName);
			if (schemaType == null)
				throw new XmlQueryCompileException ("Specified schema type was not found.");
		}
示例#7
0
		internal virtual void Compile (XQueryASTCompiler compiler)
		{
		}
示例#8
0
		/*
		internal static DefaultFunctionCall Create (
			XmlQualifiedName name,
			ExprSingle [] args,
			XQueryStaticContext ctx)
		{
			switch (name.Namespace) {
			case XQueryFunction.Namespace:
				switch (name.Name) {
				case "node-name":
					return new FnNodeNameCall (ctx, args);
				case "nilled":
					return new FnNilledCall (ctx, args);
				case "string":
					return new FnStringCall (ctx, args);
				case "data":
					return new FnDataCall (ctx, args);
				case "base-uri":
					return new FnBaseUriCall (ctx, args);
				case "document-uri":
					return new FnDocumentUriCall (ctx, args);
				case "error":
					return new FnErrorCall (ctx, args);
				case "trace":
					return new FnTraceCall (ctx, args);
				case "abs":
					return new FnAbsCall (ctx, args);
				case "ceiling":
					return new FnCeilingCall (ctx, args);
				case "floor":
					return new FnFloorCall (ctx, args);
				case "round":
					return new FnRoundCall (ctx, args);
				case "round-half-to-even":
					return new FnRoundHalfToEvenCall (ctx, args);
				case "codepoints-to-string":
					return new FnCodepointsToStringCall (ctx, args);
				case "string-to-codepoints":
					return new FnStringCallToCodepointsCall (ctx, args);
				}
				goto default;
			case InternalPool.XdtNamespace:
			case XmlSchema.Namespace:
				XmlSchemaType type = XmlSchemaType.GetBuiltInSimpleType (name);
				if (type != null)
					return new AtomicConstructorCall (ctx, SequenceType.Create (type, Occurence.One), args);
				type = XmlSchemaType.GetBuiltInComplexType (name);
				if (type == null)
					goto default;
				return null;
			default:
				XQueryFunction func = ctx.CompileContext.InEffectFunctions [name];
				if (func != null)
					return new CustomFunctionCallExpression (ctx, args, func);
				return null;
			}
		}
		*/

		internal void CheckArguments (XQueryASTCompiler compiler)
		{
			if (args.Count < MinArgs || args.Count > MaxArgs)
				// FIXME: add more info
				throw new XmlQueryCompileException (String.Format ("{0} is invalid for the number of {1} function argument. MinArgs = {2}, MaxArgs = {3}.", args.Count, name, MinArgs, MaxArgs));
		}
示例#9
0
 internal override void CheckReference(XQueryASTCompiler compiler)
 {
     compiler.CheckSchemaTypeName(typeName);
 }
示例#10
0
		internal override void CheckReference (XQueryASTCompiler compiler)
		{
			foreach (QuantifiedExprBody one in body) {
				if (one.Type != null)
					compiler.CheckSchemaType (one.Type);
				one.Expression.CheckReference (compiler);
			}
			Satisfies.CheckReference (compiler);
		}
示例#11
0
		internal void CheckReference (XQueryASTCompiler compiler)
		{
			if (type != null)
				compiler.CheckSchemaType (type);
			expr.CheckReference (compiler);
		}
示例#12
0
		internal override ExprSingle CompileCore (XQueryASTCompiler compiler)
		{
			foreach (ForLetClause flc in ForLetClauses) {
				foreach (ForLetSingleBody flsb in flc) {
					flsb.Expression = flsb.Expression.Compile (compiler);
					if (flsb.ReturnType != null)
						compiler.CheckType (flsb.Expression, flsb.ReturnType);
				}
			}
			if (WhereClause != null)
				whereClause = whereClause.Compile (compiler);
			if (OrderBy != null)
				foreach (OrderSpec os in OrderBy)
					os.Expression = os.Expression.Compile (compiler);
			ReturnExpr = ReturnExpr.Compile (compiler);

			return this;
		}
示例#13
0
		// ExprSingle Overrides

		internal override void CheckReference (XQueryASTCompiler compiler)
		{
			foreach (ForLetClause flc in fl)
				foreach (ForLetSingleBody single in flc)
					single.CheckReference (compiler);
			if (whereClause != null)
				whereClause.CheckReference (compiler);
			if (orderBy != null)
				foreach (OrderSpec os in orderBy)
					os.Expression.CheckReference (compiler);
			ret.CheckReference (compiler);
		}
示例#14
0
		internal override ExprSingle CompileCore (XQueryASTCompiler compiler)
		{
			for (int i = 0; i < Expr.Count; i++)
				Expr [i] = Expr [i].Compile (compiler);
			return this;
		}
示例#15
0
		internal override ExprSingle CompileCore (XQueryASTCompiler compiler)
		{
			// resolve function
			function = compiler.ResolveFunction (Name);
			CheckArguments (compiler);
			for (int i = 0; i < Args.Count; i++)
				Args [i] = Args [i].Compile (compiler);
			return this;
		}
示例#16
0
 internal virtual void Compile(XQueryASTCompiler compiler)
 {
 }
示例#17
0
		internal override ExprSingle CompileCore (XQueryASTCompiler compiler)
		{
			Satisfies = Satisfies.Compile (compiler);
			for (int i = 0; i < BodyList.Count; i++) {
				BodyList [i].Expression = BodyList [i].Expression.Compile (compiler);
				if (BodyList [i].Type != null)
					compiler.CheckType (BodyList [i].Expression, BodyList [i].Type);
			}
			return this;
		}
示例#18
0
 internal override void CheckReference(XQueryASTCompiler compiler)
 {
 }
示例#19
0
		internal void CheckReference (XQueryASTCompiler compiler)
		{
			foreach (ExprSingle expr in List)
				expr.CheckReference (compiler);
		}
示例#20
0
		private void CompileProlog ()
		{
			Prolog p = module.Prolog;

			// resolve external modules
			// FIXME: check if external queries are allowed by default.
			// FIXME: check recursion
			XmlUrlResolver res = new XmlUrlResolver ();
			foreach (ModuleImport modimp in p.ModuleImports) {
				foreach (string uri in modimp.Locations) {
					Stream s = res.GetEntity (res.ResolveUri (null, uri), null, typeof (Stream)) as Stream;
					XQueryLibraryModule ext = Mono.Xml.XQuery.Parser.Parser.Parse (new StreamReader (s)) as XQueryLibraryModule;
					if (ext == null)
						throw new XmlQueryCompileException (String.Format ("External module {0} is resolved as a main module, while it should be a library module."));
					XQueryStaticContext sctx = new XQueryASTCompiler (ext, options, compileContext, evidence, commandImpl).Compile ();
					libModuleContexts.Add (sctx);
				}
			}

			// resolve and compile in-scope schemas
			foreach (SchemaImport xsimp in p.SchemaImports) {
				foreach (string uri in xsimp.Locations) {
					XmlSchema schema = inScopeSchemas.Add (xsimp.Namespace, uri);
					compileContext.InEffectSchemas.Add (schema);
				}
			}
			inScopeSchemas.Compile ();

			CheckReferences ();

			ResolveVariableReferences ();

			// compile FunctionDeclaration into XQueryFunction
			foreach (FunctionDeclaration func in p.Functions.Values) {
				XQueryFunction cfunc = CompileFunction (func);
				localFunctions.Add (cfunc);
			}
		}
示例#21
0
		internal override void CheckReference (XQueryASTCompiler compiler)
		{
			switchExpr.CheckReference (compiler);
			foreach (CaseClause cc in caseList) {
				compiler.CheckSchemaType (cc.Type);
				cc.Expr.CheckReference (compiler);
			}
			defaultReturn.CheckReference (compiler);
		}
示例#22
0
		internal virtual void CheckReference (XQueryASTCompiler compiler)
		{
		}
示例#23
0
		internal override ExprSingle CompileCore (XQueryASTCompiler compiler)
		{
			for (int i = 0; i < SwitchExpr.Count; i++)
				SwitchExpr [i] = SwitchExpr [i].Compile (compiler);
			foreach (CaseClause cc in Cases)
				cc.Expr = cc.Expr.Compile (compiler);
			DefaultReturn = DefaultReturn.Compile (compiler);
			return this;
		}
示例#24
0
		internal override void CheckReference (XQueryASTCompiler compiler)
		{
			compiler.CheckSchemaTypeName (typeName);
		}
示例#25
0
		internal abstract void CheckReference (XQueryASTCompiler compiler);
示例#26
0
		internal override void CheckReference (XQueryASTCompiler compiler)
		{
		}
示例#27
0
		internal override void CheckReference (XQueryASTCompiler compiler)
		{
			condition.CheckReference (compiler);
			trueExpr.CheckReference (compiler);
			falseExpr.CheckReference (compiler);
		}
示例#28
0
 public void Compile(TextReader input, Evidence evidence, object xqueryCommand)
 {
     staticContext      = XQueryASTCompiler.Compile(Mono.Xml.XQuery.Parser.Parser.Parse(input), null, evidence, this);
     this.xqueryCommand = xqueryCommand;
     // FIXME: generate executable assembly, and load it with evidence.
 }
示例#29
0
		internal override ExprSingle CompileCore (XQueryASTCompiler compiler)
		{
			condition = condition.Compile (compiler);
			// FIXME: check if condition is constant, and returns trueExpr or falseExpr
			TrueExpr = TrueExpr.Compile (compiler);
			FalseExpr = FalseExpr.Compile (compiler);
			return this;
		}
示例#30
0
		internal override void CheckReference (XQueryASTCompiler compiler)
		{
			if (nameExpr != null)
				nameExpr.CheckReference (compiler);
			if (Content != null)
				Content.CheckReference (compiler);
		}
示例#31
0
		internal ExprSingle Compile (XQueryASTCompiler compiler)
		{
			this.ctx = ctx;
			return CompileCore (compiler);
		}
示例#32
0
 internal virtual void CheckReference(XQueryASTCompiler compiler)
 {
 }
示例#33
0
		internal override void CheckReference (XQueryASTCompiler compiler)
		{
			left.CheckReference (compiler);
			right.CheckReference (compiler);
		}
示例#34
0
 internal override void CheckReference(XQueryASTCompiler compiler)
 {
     content.CheckReference(compiler);
 }
示例#35
0
		internal override ExprSingle CompileCore (XQueryASTCompiler compiler)
		{
			Left = Left.Compile (compiler);
			Right = Right.Compile (compiler);
			return this;
		}
示例#36
0
		// If internal&&protected is available in C#, it is the best signature.
		internal abstract ExprSingle CompileCore (XQueryASTCompiler compiler);
示例#37
0
		internal override ExprSingle CompileCore (XQueryASTCompiler compiler)
		{
			base.CompileCore (compiler);
			// FIXME: check constant value and return true or false
			return this;
		}
示例#38
0
 internal override void Compile(XQueryASTCompiler compiler)
 {
 }
示例#39
0
		internal override void CheckReference (XQueryASTCompiler compiler)
		{
			compiler.CheckFunctionName (name);
		}