public dynamic Visit(FuncImplementation impl)
 {
     impl.CodeGenMethod = _currentMethod;
     foreach (var param in impl.Parameters)
     {
         _currentMethod.Parameter(param.Value.CodeGenType(), param.Key);
     }
     foreach (var param in impl.Parameters)
     {
         impl.Namespace.Symbols
         .SingleOrDefault(x => x.Name == param.Key)
         .CodeGenField = _codeGen.Arg(param.Key);
     }
     if (impl.ReturnExpression != null)
     {
         _codeGen.Return(Visit((dynamic)impl.ReturnExpression));
     }
     if (impl.Code != null)
     {
         foreach (var statement in impl.Code.Statements)
         {
             Visit((dynamic)statement);
         }
     }
     return(null);
 }
		public MethodGen RemoveMethod(string parameterName)
		{
			if (remover == null)
			{
				remover = new MethodGen(owner, "remove_" + name, attrs | MethodAttributes.SpecialName, typeof(void), 0);
				remover.Parameter(type, parameterName);
				eb.SetRemoveOnMethod(remover.GetMethodBuilder());
			}

			return remover;
		}
		public MethodGen AddMethod(string parameterName)
		{
			if (adder == null)
			{
				adder = new MethodGen(owner, "add_" + name, attrs | MethodAttributes.SpecialName, typeof(void), 0);
				adder.Parameter(type, parameterName);
				eb.SetAddOnMethod(adder.GetMethodBuilder());
			}

			return adder;
		}
Exemple #4
0
        private KeyValuePair <string, MethodGen> GenerateMethodSignature(TypeGen classDeclaration, BaseSymbol nonTerm, AssemblyGen ag)
        {
            Token             typeMethodDeclSimple;
            Token             methodName;
            List <BaseSymbol> formalParametersList;

            NonTermFactory.GetMethodSignature(nonTerm, out typeMethodDeclSimple, out methodName, out formalParametersList);

            Type      methodReturnType = GetVariableType(typeMethodDeclSimple);
            MethodGen method           = classDeclaration.Public.Method(methodReturnType, methodName.Value);

            foreach (BaseSymbol symbol in formalParametersList)
            {
                Token type;
                Token id;
                NonTermFactory.GetFormalArgumentDeclaration(symbol, out type, out id);
                method.Parameter(GetVariableType(type), id.Value);
            }

            //_compilerLogger.PrintAddtFormalArgumentList(formalParametersList.Select(s => s.Symbols[1].Value).ToList());

            return(new KeyValuePair <string, MethodGen>(methodName.Value, method));
        }
Exemple #5
0
		public MethodGen AddMethod(string parameterName)
		{
			if (_adder == null)
			{
			    LockSignature();
				_adder = new MethodGen(_owner, "add_" + Name, _attrs | MethodAttributes.SpecialName, TypeMapper.MapType(typeof(void)), 0);
			    _adder.ImplementedInterface = ImplementedInterface;
				_adder.Parameter(_type, parameterName);
				_eb.SetAddOnMethod(_adder.GetMethodBuilder());
			}

			return _adder;
		}