public object VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration, object data)
        {
            B.Constructor m = new B.Constructor(GetLexicalInfo(constructorDeclaration));
            m.Modifiers = ConvertModifier(constructorDeclaration, B.TypeMemberModifiers.Private);
            ConvertAttributes(constructorDeclaration.Attributes, m.Attributes);
            if (currentType != null)
            {
                currentType.Members.Add(m);
            }
            ConvertParameters(constructorDeclaration.Parameters, m.Parameters);
            m.EndSourceLocation = GetEndLocation((INode)constructorDeclaration.Body ?? constructorDeclaration);
            m.Body = ConvertMethodBlock(constructorDeclaration.Body);
            ConstructorInitializer ci = constructorDeclaration.ConstructorInitializer;

            if (ci != null && !ci.IsNull)
            {
                B.Expression initializerBase;
                if (ci.ConstructorInitializerType == ConstructorInitializerType.Base)
                {
                    initializerBase = new B.SuperLiteralExpression();
                }
                else
                {
                    initializerBase = new B.SelfLiteralExpression();
                }
                B.MethodInvocationExpression initializer = new B.MethodInvocationExpression(initializerBase);
                ConvertExpressions(ci.Arguments, initializer.Arguments);
                m.Body.Insert(0, new B.ExpressionStatement(initializer));
            }
            return(m);
        }
Exemplo n.º 2
0
        public override void OnSuperLiteralExpression(SuperLiteralExpression node)
        {
            base.OnSuperLiteralExpression(node);

            if (node.IsTargetOfMethodInvocation())
            {
                OnExpression(node);
            }
        }
        override public object Clone()
        {
            SuperLiteralExpression clone = new SuperLiteralExpression();

            clone._lexicalInfo       = _lexicalInfo;
            clone._endSourceLocation = _endSourceLocation;
            clone._documentation     = _documentation;
            clone._isSynthetic       = _isSynthetic;
            clone._entity            = _entity;
            if (_annotations != null)
            {
                clone._annotations = (Hashtable)_annotations.Clone();
            }
            clone._expressionType = _expressionType;
            return(clone);
        }
Exemplo n.º 4
0
        override public object Clone()
        {
            SuperLiteralExpression clone = (SuperLiteralExpression)FormatterServices.GetUninitializedObject(typeof(SuperLiteralExpression));

            clone._lexicalInfo       = _lexicalInfo;
            clone._endSourceLocation = _endSourceLocation;
            clone._documentation     = _documentation;
            clone._entity            = _entity;
            if (_annotations != null)
            {
                clone._annotations = (Hashtable)_annotations.Clone();
            }

            clone._expressionType = _expressionType;
            return(clone);
        }
Exemplo n.º 5
0
		override public void OnSuperLiteralExpression(SuperLiteralExpression node)
		{
			var externalSelf = CodeBuilder.CreateReference(node.LexicalInfo, ExternalEnumeratorSelf());
			if (AstUtil.IsTargetOfMethodInvocation(node)) // super(...)
				ReplaceCurrentNode(CodeBuilder.CreateMemberReference(externalSelf, (IMethod)GetEntity(node)));
			else // super.Method(...)
				ReplaceCurrentNode(externalSelf);
		}
Exemplo n.º 6
0
 public override void OnSuperLiteralExpression(SuperLiteralExpression node)
 {
     _il.Emit(OpCodes.Ldarg_0);
     if (node.ExpressionType.IsValueType)
     {
         _il.Emit(OpCodes.Ldobj, GetSystemType(node.ExpressionType));
     }
     PushType(node.ExpressionType);
 }
Exemplo n.º 7
0
        //throws RecognitionException, TokenStreamException
        protected SuperLiteralExpression super_literal()
        {
            SuperLiteralExpression e;

            IToken  t = null;
            e = null;

            try {      // for error handling
            t = LT(1);
            match(SUPER);
            if (0==inputState.guessing)
            {
                e = new SuperLiteralExpression(SourceLocationFactory.ToLexicalInfo(t));
            }
            }
            catch (RecognitionException ex)
            {
            if (0 == inputState.guessing)
            {
                reportError(ex);
                recover(ex,tokenSet_36_);
            }
            else
            {
                throw ex;
            }
            }
            return e;
        }
Exemplo n.º 8
0
		override public void OnSuperLiteralExpression(SuperLiteralExpression node)
		{
			LoadSelf(node);
		}
Exemplo n.º 9
0
		public override void OnSuperLiteralExpression(SuperLiteralExpression node)
		{
			if (callingClass == null)
				ClearResult();
			else
				MakeResult(callingClass.BaseType);
		}
Exemplo n.º 10
0
 public override void OnSuperLiteralExpression(SuperLiteralExpression node)
 {
     if (AstUtil.IsTargetOfMethodInvocation(node)) return;
     if (AstUtil.IsTargetOfMemberReference(node)) return;
     Error(CompilerErrorFactory.InvalidSuper(node));
 }
Exemplo n.º 11
0
		public override void OnSuperLiteralExpression(SuperLiteralExpression node)
		{
			_expression = new CodeBaseReferenceExpression();
		}
Exemplo n.º 12
0
 public override void OnSuperLiteralExpression(SuperLiteralExpression node)
 {
     WriteKeyword("super");
 }
Exemplo n.º 13
0
		override public object Clone()
		{
		
			SuperLiteralExpression clone = new SuperLiteralExpression();
			clone._lexicalInfo = _lexicalInfo;
			clone._endSourceLocation = _endSourceLocation;
			clone._documentation = _documentation;
			clone._isSynthetic = _isSynthetic;
			clone._entity = _entity;
			if (_annotations != null) clone._annotations = (Hashtable)_annotations.Clone();
			clone._expressionType = _expressionType;
			return clone;


		}
Exemplo n.º 14
0
 public SuperLiteralExpression CreateSuperReference(IType super)
 {
     SuperLiteralExpression expression = new SuperLiteralExpression();
     expression.ExpressionType = super;
     return expression;
 }
Exemplo n.º 15
0
 public SuperLiteralExpression super_literal()
 {
     SuperLiteralExpression expression = null;
     IToken token = null;
     try
     {
         token = this.LT(1);
         this.match(0x27);
         if (base.inputState.guessing == 0)
         {
             expression = new SuperLiteralExpression(ToLexicalInfo(token));
         }
     }
     catch (RecognitionException exception)
     {
         if (base.inputState.guessing != 0)
         {
             throw;
         }
         this.reportError(exception);
         this.recover(exception, tokenSet_20_);
         return expression;
     }
     return expression;
 }
Exemplo n.º 16
0
	protected SuperLiteralExpression  super_literal() //throws RecognitionException, TokenStreamException
{
		SuperLiteralExpression e;
		
		IToken  t = null;
		e = null;
		
		try {      // for error handling
			t = LT(1);
			match(SUPER);
			if (0==inputState.guessing)
			{
				e = new SuperLiteralExpression(ToLexicalInfo(t));
			}
		}
		catch (RecognitionException ex)
		{
			if (0 == inputState.guessing)
			{
				reportError(ex, "super_literal");
				recover(ex,tokenSet_44_);
			}
			else
			{
				throw ex;
			}
		}
		return e;
	}
Exemplo n.º 17
0
        public override void OnSuperLiteralExpression(SuperLiteralExpression node)
        {
            if (!AstUtil.IsTargetOfMethodInvocation(node))
            {
                node.ExpressionType = _currentMethod.DeclaringType.BaseType;
                return;
            }

            if (EntityType.Constructor == _currentMethod.EntityType)
            {
                // TODO: point to super ctor
                node.Entity = _currentMethod;
                return;
            }

            if (null == _currentMethod.Overriden)
            {
                Error(node,
                CompilerErrorFactory.MethodIsNotOverride(node, _currentMethod));
                return;
            }

            node.Entity = _currentMethod.Overriden;
        }
		public object VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration, object data)
		{
			B.Constructor m = new B.Constructor(GetLexicalInfo(constructorDeclaration));
			m.Modifiers = ConvertModifier(constructorDeclaration, B.TypeMemberModifiers.Private);
			ConvertAttributes(constructorDeclaration.Attributes, m.Attributes);
			if (currentType != null) currentType.Members.Add(m);
			ConvertParameters(constructorDeclaration.Parameters, m.Parameters);
			m.EndSourceLocation = GetEndLocation((INode)constructorDeclaration.Body ?? constructorDeclaration);
			m.Body = ConvertMethodBlock(constructorDeclaration.Body);
			ConstructorInitializer ci = constructorDeclaration.ConstructorInitializer;
			if (ci != null && !ci.IsNull) {
				B.Expression initializerBase;
				if (ci.ConstructorInitializerType == ConstructorInitializerType.Base)
					initializerBase = new B.SuperLiteralExpression();
				else
					initializerBase = new B.SelfLiteralExpression();
				B.MethodInvocationExpression initializer = new B.MethodInvocationExpression(initializerBase);
				ConvertExpressions(ci.Arguments, initializer.Arguments);
				m.Body.Insert(0, new B.ExpressionStatement(initializer));
			}
			return m;
		}