예제 #1
0
 /// <summary>
 /// Define a primitive, taking a variable number of arguments.
 /// Creates a Primitive and puts it in the environment associated 
 ///    with the given name.
 /// </summary>
 /// <param name="name">The primitive name.</param>
 /// <param name="description">An array of strings describing the primitive.</param>
 /// <param name="operation">The operation to perform.</param>
 /// <param name="argsInfo">Information about primitive args.</param>
 /// <returns>A refernce to the environment.</returns>
 public IPrimitiveEnvironment DefinePrimitive(Symbol name, string[] description, Operation operation, ArgsInfo argsInfo)
 {
     this.Define(name, new Primitive(name.SymbolName, operation, description, argsInfo));
     return this;
 }
예제 #2
0
 /// <summary>
 /// Initializes a new instance of the Primitive class.
 /// </summary>
 /// <param name="name">The primitive name.</param>
 /// <param name="operation">The code to carry out the operation.</param>
 /// <param name="description">The primitive description.</param>
 /// <param name="argsInfo">Information about primitive args.</param>
 public Primitive(string name, Operation operation, string[] description, ArgsInfo argsInfo)
     : base(name, argsInfo)
 {
     this.operation = operation;
     this.description = description;
     this.argTypes = argsInfo.ArgTypes;
     if (argsInfo.MaxArgs > 0 && argTypes.Length == 0)
     {
         throw new ErrorHandlers.SchemeException(string.Format(@"Invalid primitive definition ""{0}""", operation));
     }
 }