/// <summary>
		/// Generates a function call
		/// </summary>
		/// <param name="functionName">The name of the function to call</param>
		/// <param name="syntaxTree">The syntax tree</param>
		/// <param name="generatorData">The generator data for the syntax tree</param>
		public void GenerateFunctionCall(string functionName, SyntaxTrees syntaxTree, SyntaxTreeGeneratorData generatorData)
		{
			if (this.Methods.ContainsKey(functionName))
			{
				MethodInfo calledMethod = this.Methods[functionName];

				generatorData.ILGenerator.EmitCall(OpCodes.Call, calledMethod, null);

				//Because the language is expression based, when we call functions that return void we return 0
				if (calledMethod.ReturnType == typeof(void))
				{
					generatorData.ILGenerator.Emit(OpCodes.Ldc_R8, 0.0);
				}
			}
			else
			{
				throw new CodeGeneratorException("Function '" + functionName + "' not found.", syntaxTree);
			}
		}
Example #2
0
        /// <summary>
        /// Generates a function call
        /// </summary>
        /// <param name="functionName">The name of the function to call</param>
        /// <param name="syntaxTree">The syntax tree</param>
        /// <param name="generatorData">The generator data for the syntax tree</param>
        public void GenerateFunctionCall(string functionName, SyntaxTrees syntaxTree, SyntaxTreeGeneratorData generatorData)
        {
            if (this.Methods.ContainsKey(functionName))
            {
                MethodInfo calledMethod = this.Methods[functionName];

                generatorData.ILGenerator.EmitCall(OpCodes.Call, calledMethod, null);

                //Because the language is expression based, when we call functions that return void we return 0
                if (calledMethod.ReturnType == typeof(void))
                {
                    generatorData.ILGenerator.Emit(OpCodes.Ldc_R8, 0.0);
                }
            }
            else
            {
                throw new CodeGeneratorException("Function '" + functionName + "' not found.", syntaxTree);
            }
        }
Example #3
0
 /// <summary>
 /// Creates a new code generator exception
 /// </summary>
 /// <param name="message">The error message</param>
 /// <param name="syntaxTree">The syntax tree that caused the exception</param>
 public CodeGeneratorException(string message, SyntaxTrees syntaxTree)
     : base(message)
 {
     this.SyntaxTree = syntaxTree;
 }
		/// <summary>
		/// Creates a new code generator exception
		/// </summary>
		/// <param name="message">The error message</param>
		/// <param name="syntaxTree">The syntax tree that caused the exception</param>
		public CodeGeneratorException(string message, SyntaxTrees syntaxTree)
			: base(message)
		{
			this.SyntaxTree = syntaxTree;
		}