public static void AddVariant( string name, mysFunction variant, mysSymbolSpace global ) { mysSymbol symbol = new mysSymbol( name ); mysFunctionGroup fg; if ( !global.Defined( symbol ) ) { global.Define( symbol, new mysToken( new mysFunctionGroup() ) ); } fg = global .GetValue( new mysSymbol( name ) ) .Value as mysFunctionGroup ; fg.Variants.Add( variant ); }
bool judgeVariant( mysFunction variant, List<mysToken> arguments, Stack<mysSymbolSpace> spaceStack ) { // lh: make this a bit cleverer later to handle variadics. if ( variant.SignatureLength != arguments.Count ) { return false; } if ( variant.Signature .Zip( arguments, (type, token) => typeCheck( type, token, spaceStack ) ) // if the zip of our two collections is less than the count // we started with, at least one given token did not match // the sig, so we remove that variant from the potential // ones. .Where( p => p ) .Count() != arguments.Count ) { return false; } return true; }