use of php.runtime.common.HintType in project jphp by jphp-compiler.
the class FunctionGenerator method processArgument.
@SuppressWarnings("unchecked")
protected ArgumentStmtToken processArgument(ListIterator<Token> iterator) {
boolean isReference = false;
boolean isVariadic = false;
VariableExprToken variable = null;
ExprStmtToken value = null;
Token next = nextToken(iterator);
if (next instanceof CommaToken || isClosedBrace(next, BraceExprToken.Kind.SIMPLE))
return null;
NameToken hintTypeClass = null;
HintType hintType = null;
if (next instanceof SelfExprToken) {
if (analyzer.getClazz() == null) {
unexpectedToken(next);
}
next = analyzer.getClazz().getName();
}
if (next instanceof NameToken) {
String word = ((NameToken) next).getName().toLowerCase();
if (scalarTypeHints.contains(word))
hintType = HintType.of(word);
else {
hintType = jphp_scalarTypeHints.contains(word) ? null : HintType.of(word);
if (hintType == null)
hintTypeClass = analyzer.getRealName((NameToken) next);
}
next = nextToken(iterator);
}
if (next instanceof AmpersandRefToken) {
isReference = true;
next = nextToken(iterator);
}
if (next instanceof ArgumentUnpackExprToken) {
isVariadic = true;
next = nextToken(iterator);
}
if (next instanceof VariableExprToken) {
variable = (VariableExprToken) next;
} else
unexpectedToken(next);
next = nextToken(iterator);
if (next instanceof AssignExprToken) {
if (isVariadic) {
unexpectedToken(next);
}
value = analyzer.generator(SimpleExprGenerator.class).getToken(nextToken(iterator), iterator, true, BraceExprToken.Kind.SIMPLE);
} else {
if (next instanceof CommaToken || isClosedBrace(next, BraceExprToken.Kind.SIMPLE)) {
if (next instanceof BraceExprToken) {
iterator.previous();
} else {
if (isVariadic) {
unexpectedToken(next);
}
}
} else
unexpectedToken(next);
}
ArgumentStmtToken argument = new ArgumentStmtToken(variable.getMeta());
argument.setName(variable);
argument.setHintType(hintType);
argument.setHintTypeClass(hintTypeClass);
argument.setReference(isReference);
argument.setVariadic(isVariadic);
argument.setValue(value);
if (argument.isReference() && argument.getValue() != null)
analyzer.getFunction().variable(argument.getName()).setUsed(true);
return argument;
}
use of php.runtime.common.HintType in project jphp by jphp-compiler.
the class ParameterEntity method setType.
public void setType(String type) {
HintType _type = HintType.of(type);
this.typeChecker = _type == null ? null : TypeChecker.of(_type);
}
Aggregations