Inheritance: IronRuby.Compiler.Ast.DefinitionExpression
Ejemplo n.º 1
0
        internal RubyMethodBody(MethodDeclaration/*!*/ ast, MSA.SymbolDocumentInfo document, RubyEncoding/*!*/ encoding) {
            Assert.NotNull(ast, encoding);

            _ast = ast;
            _document = document;
            _encoding = encoding;
        }
Ejemplo n.º 2
0
        internal RubyMethodBody(MethodDeclaration /*!*/ ast, MSA.SymbolDocumentInfo document, RubyEncoding /*!*/ encoding)
        {
            Assert.NotNull(ast, encoding);

            _ast      = ast;
            _document = document;
            _encoding = encoding;
        }
Ejemplo n.º 3
0
		protected override void Walk(MethodDefinition node)
		{
			if (IsInitializeComponentMethod(node)) {
				Type type = GetComponentType();
				component = componentCreator.CreateComponent(type, componentName);
				
				IResourceReader reader = componentCreator.GetResourceReader(CultureInfo.InvariantCulture);
				if (reader != null) {
					reader.Dispose();
				}

				WalkMethodStatements(node.Body.Statements);
			}
		}
Ejemplo n.º 4
0
 public override void Exit(MethodDefinition/*!*/ node)
 {
     _outerName.RemoveAt(_outerName.Count - 1);
     _outerMethods.Pop();
 }
Ejemplo n.º 5
0
        public override bool Enter(MethodDefinition/*!*/ node)
        {
            var outerModule = _outerModules.Peek();

            string targetName;
            bool isSelfSingleton =
                !outerModule.IsSingleton && IsSelfModuleReference(node.Target, out targetName) ||
                outerModule.IsSingleton && node.Target == null;

            var entry = new MethodEntry(node, isSelfSingleton);

            // add to the outer method:
            if (_outerMethods.Count > 0) {
                var outerMethod = _outerMethods.Peek();
                if (outerMethod != null) {
                    outerMethod.AddNested(entry);
                }
            }

            // add to the outer module:
            // TODO: lookup target name...
            if (isSelfSingleton || node.Target == null) {
                outerModule.AddMethod(entry);
            }

            _outerName.Add(null);
            _outerMethods.Push(entry);
            return true;
        }
Ejemplo n.º 6
0
 public MethodEntry(MethodDefinition/*!*/ definition, bool isSingleton)
     : base(definition.Name, definition)
 {
     _isSingleton = isSingleton;
 }
Ejemplo n.º 7
0
		static bool IsInitializeComponentMethod(MethodDefinition node)
		{
			string name = node.Name.ToLowerInvariant();
			return name == "initializecomponent" || name == "initializecomponents";
		}
Ejemplo n.º 8
0
 public virtual void Exit(MethodDefinition/*!*/ node) { }
Ejemplo n.º 9
0
 public virtual bool Enter(MethodDefinition/*!*/ node) { return true; }
Ejemplo n.º 10
0
 public MethodScopeNode(MethodDefinition method)
 {
     _method = method;
 }
Ejemplo n.º 11
0
		SourceLocation GetParametersEndLocationBasedOnMethodNameEnd(MethodDefinition methodDef)
		{
			const int methodParenthesesLength = 2;
			const int spaceLength = 1;
			int methodDefinitionLength = methodDef.Name.Length + MethodDefinitionLength + methodParenthesesLength + spaceLength;
			SourceLocation methodStartLocation = methodDef.Location.Start;
			int index = methodStartLocation.Index + methodDefinitionLength;
			int column = methodStartLocation.Column + methodDefinitionLength;
			int line = methodStartLocation.Line;
			return new SourceLocation(index, line, column);
 		}
Ejemplo n.º 12
0
		SourceLocation GetParametersEndLocation(MethodDefinition methodDef)
		{
 			SourceLocation parametersEndLocation = methodDef.Parameters.Location.End;
			if (parametersEndLocation.IsValid) {
				if (ParametersEndLocationNeedsCorrecting(parametersEndLocation)) {
					parametersEndLocation = CorrectParametersEndLocation(parametersEndLocation);
				}
			} else {
				return GetParametersEndLocationBasedOnMethodNameEnd(methodDef);
 			}
			return parametersEndLocation;
		}
Ejemplo n.º 13
0
		/// <summary>
		/// Gets the region of a method. This does not include the body.
		/// </summary>
		DomRegion GetMethodRegion(MethodDefinition methodDef)
		{
			SourceLocation parametersEndLocation = GetParametersEndLocation(methodDef);
			return CreateRegion(methodDef.Location.Start, parametersEndLocation);
		}
Ejemplo n.º 14
0
		protected override void Walk(MethodDefinition methodDef)
		{
			IClass c = currentClass;
			if (currentClass == null) {
				// Walking a global method.
				CreateGlobalClass();
				c = globalClass;
			}
			
			// Create method.
			string methodName = methodDef.Name;
			DomRegion region = GetMethodRegion(methodDef);
			DomRegion bodyRegion = GetMethodBodyRegion(methodDef.Body.Location, region);
			
			DefaultMethod method;
			if (methodName == "initialize") {
				method = new Constructor(ModifierEnum.Public, region, bodyRegion, c);
			} else {
				method = new DefaultMethod(methodName, new DefaultReturnType(c), ModifierEnum.Public, region, bodyRegion, c);
			}
			foreach (IParameter parameter in ConvertParameters(methodDef.Parameters)) {
				method.Parameters.Add(parameter);
			}
			c.Methods.Add(method);
		}
Ejemplo n.º 15
0
		/// <summary>
		/// Gets the region of a method. This does not include the body.
		/// </summary>
		DomRegion GetMethodRegion(MethodDefinition methodDef)
		{
			SourceLocation parametersEndLocation = methodDef.Parameters.Location.End;
			if (ParametersEndLocationNeedsCorrecting(parametersEndLocation)) {
				parametersEndLocation = CorrectParametersEndLocation(parametersEndLocation);
			}
			return CreateRegion(methodDef.Location.Start, parametersEndLocation);
		}