1. -- 
  2. -- Copyright (c) 2012 Kevin Wellwood 
  3. -- All rights reserved. 
  4. -- 
  5. -- This source code is distributed under the Modified BSD License. For terms and 
  6. -- conditions, see license.txt. 
  7. -- 
  8.  
  9. private with Ada.Strings.Unbounded; 
  10.  
  11. package Scripting.Expressions.Functions is 
  12.  
  13.     -- A Function is a call into the host application to perform an operation, 
  14.     -- given a set of arguments. Any type of value may be returned by the 
  15.     -- function when it is evaluated (ie: executed). 
  16.     type Function_Call is new Expression with private; 
  17.     type A_Function is access all Function_Call'Class; 
  18.  
  19.     -- Creates a new Function from a Token, representing the function name. 
  20.     function Create_Function( name : not null A_Identifier_Token ) return A_Function; 
  21.     pragma Postcondition( Create_Function'Result /= null ); 
  22.  
  23.     -- todo: make this private. 
  24.     -- this is public as a workaround for a 6.2.0w OSX compiler bug 
  25.     function Evaluate( this    : access Function_Call; 
  26.                        context : not null A_Eval_Context ) return Value_Ptr; 
  27.  
  28.     -- Returns the function's name. This should match with the definition of an 
  29.     -- identifier in the scripting language. 
  30.     function Get_Name( this : not null access Function_Call'Class ) return String; 
  31.  
  32.     -- Sets the arguments to the function as a list of Expressions. 'arguments' 
  33.     -- will be consumed. 
  34.     procedure Set_Arguments( this      : not null access Function_Call'Class; 
  35.                              arguments : in out Expression_Lists.List ); 
  36.  
  37. private 
  38.  
  39.     use Ada.Strings.Unbounded; 
  40.  
  41.     type Function_Call is new Expression with 
  42.         record 
  43.             name      : Unbounded_String; 
  44.             arguments : Expression_Lists.List; 
  45.         end record; 
  46.  
  47.     procedure Construct( this : access Function_Call; 
  48.                          loc  : Token_Location; 
  49.                          name : String ); 
  50.  
  51.     procedure Delete( this : in out Function_Call ); 
  52.  
  53. end Scripting.Expressions.Functions;