if (isMethodTrue() || isMethodFalse())
return;
Named<?> named = service.get( method.image );
if (named == null)
throw new ParseException( String.format(
"Authorize method name %s is not defined at %d",
method.image, lineno() ) );
if (!named.isMessage())
throw new ParseException( String.format(
"Authorize method name %s is not a method at %d",
method.image, lineno() ) );
Message authMsg = (Message) named;
if (authMsg.type().type().kind != EtchGrammarConstants.BOOLEAN)
throw new ParseException( String.format(
"Authorize method %s result type is not boolean at %d",
method.image, lineno() ) );
List<Parameter> authParams = authMsg.getParameters();
if (authParams.size() != argList.size())
throw new ParseException( String.format(
"Authorize method %s parameter list size does not match the number of supplied arguments at %d",
method.image, lineno() ) );
int n = argList.size();
for (int i = 0; i < n; i++)
{
Parameter param = authParams.get( i );
AuthArg aarg = argList.get( i );
aarg.setType( param.type() );
Token arg = aarg.value();
// System.out.printf( "auth method %s param %s = %s\n",
// method, param.name(), arg );
switch (arg.kind)
{
case EtchGrammarConstants.NULL:
// any parameter value may be specified as null...
break;
case EtchGrammarConstants.ID:
// arg is referencing either a parameter of msg or a
// service constant.
checkMsgParamOrServiceConst( msg, param, arg, i );
break;
case EtchGrammarConstants.QID:
// arg is referencing an enum item (enum.item) or
// could be trying to reference a field of a
// parameter of message (param(.field)+).
checkMsgParamFieldRefOrEnumItem( msg, param, arg, i );
break;
case EtchGrammarConstants.TRUE:
case EtchGrammarConstants.FALSE:
// arg is a boolean constant the parameter better be
// boolean, too.
checkBooleanConstant( param, arg, i );
break;
case EtchGrammarConstants.INTEGER:
// arg is an integer constant, the parameter better
// be an integral or floating type and arg better
// be the right size...
checkIntegerConstant( param, arg, i );
break;
case EtchGrammarConstants.OCTAL:
// arg is an octal constant, the parameter better
// be an integral or floating type and arg better
// be the right size...
checkOctalConstant( param, arg, i );
break;
case EtchGrammarConstants.HEX:
// arg is a hex constant, the parameter better
// be an integral or floating type and arg better
// be the right size...
checkHexConstant( param, arg, i );
break;
case EtchGrammarConstants.BINARY:
// arg is a binary constant, the parameter better
// be an integral or floating type and arg better
// be the right size...
checkBinaryConstant( param, arg, i );
break;
case EtchGrammarConstants.DECIMAL:
// arg is a decimal constant, the parameter better
// be a floating type and arg better be the right
// size...
checkDecimalConstant( param, arg, i );
break;
case EtchGrammarConstants.STR:
// arg is a string constant the parameter better be
// string, too.
checkStringConstant( param, arg, i );
break;
default:
throw new ParseException( String.format(
"Authorize method %s arg %d unsupported kind (%s) at line %d",
method.image, i+1, arg, lineno() ) );
}
}
}