本文整理汇总了C++中ASTType::getTypeArguments方法的典型用法代码示例。如果您正苦于以下问题:C++ ASTType::getTypeArguments方法的具体用法?C++ ASTType::getTypeArguments怎么用?C++ ASTType::getTypeArguments使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ASTType
的用法示例。
在下文中一共展示了ASTType::getTypeArguments方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: visit
void SymbolCheckVisitor::visit(ASTNew& ast)
{
switch ( ast.getKind() )
{
case ASTNew::eObject:
{
ASTType before = mCurrentType;
ASTSignature signature;
ASTNodes& arguments = ast.getArguments();
for ( int index = 0; index < arguments.size(); index++ )
{
ASTExpression& expr = dynamic_cast<ASTExpression&>(arguments[index]);
expr.accept(*this);
signature.append(mCurrentType.clone());
}
checkUnknown(ast.getType());
if ( ast.getType().hasObjectClass() )
{
const ASTClass& newclass = ast.getType().getObjectClass();
const ASTFunction* pfunction = newclass.findBestMatch(newclass.getName(), signature, before.getTypeArguments());
if ( pfunction == NULL )
{
String arguments = UTEXT("(") + signature.toString() + ')';
error(E0029, UTEXT("No matching constructor ") + newclass.getFullName() + arguments + UTEXT(" defined."), ast);
}
else
{
ast.setConstructor(*pfunction);
}
}
mCurrentType = ast.getType();
}
break;
case ASTNew::eArray:
{
ASTNodes& arguments = ast.getArguments();
for ( int index = 0; index < arguments.size(); index++ )
{
ASTExpression& expr = dynamic_cast<ASTExpression&>(arguments[index]);
expr.accept(*this);
if ( !mCurrentType.isInt() )
{
error(E0030, UTEXT("Array size expression should be of type int."), ast);
}
}
mCurrentType = ast.getType();
}
break;
case ASTNew::eInvalid:
error(E0001, UTEXT("Invalid compiler state!"), ast);
break;
}
}
示例2: visit
void CodeGeneratorVisitor::visit(const ASTAccess& ast)
{
switch ( ast.getKind() )
{
case ASTAccess::eVariable:
{
switch ( ast.getAccess() )
{
case ASTAccess::eField:
case ASTAccess::eRefField:
{
const ASTField& field = ast.getField();
if ( ast.getAccess() == ASTAccess::eField && !field.getVariable().getModifiers().isStatic() )
{
// only emit loading this for current fields
// with reference the object is already there
mBuilder.emit(CIL_ldarg, 0);
}
handleField(field);
}
break;
case ASTAccess::eArgument:
case ASTAccess::eLocal:
{
const ASTVariable& var = ast.getVariable();
handleVariable(var);
}
break;
default:
break;
}
const ASTType& type = ast.getVariable().getType();
if ( mCurrentType.isValid() && type.isGeneric() )
{
const ASTTypeVariable& typevariable = type.getTypeVariable();
if ( ast.getTypeArguments().size() > 0 )
{
mCurrentType = ast.getTypeArguments()[typevariable.getIndex()];
}
else
{
mCurrentType = mCurrentType.getTypeArguments()[typevariable.getIndex()];
}
}
else
mCurrentType = type;
}
break;
case ASTAccess::eArray:
{
// the array object is now on top of the stack
mExpr = 1;
ASTType before = mCurrentType;
// add indices on stack
reverseVisitChildren(ast);
mBuilder.emit(CIL_ldelem, ast.getArguments().size());
}
break;
case ASTAccess::eFunction:
{
const ASTFunction& function = ast.getFunction();
if ( !mCurrentType.isValid() )
{
mBuilder.emit(CIL_ldarg, 0); // this
}
ASTType before = mCurrentType;
visitChildren(ast);
if ( mWasSuper )
{
String name = function.getClass().getFullName() + '.' + function.getPrototype();
mBuilder.emit(CIL_call, name);
mWasSuper = false;
}
else if ( function.getModifiers().isPureNative() )
{
const String qualifiedname = function.getClass().getFullName() + '.' + function.getPrototype();
mBuilder.emit(CIL_call_native, qualifiedname);
}
else if ( function.getModifiers().isStatic() ) // first check for static so native statics are possible as well
{
String name = (before.isValid() ? before.getObjectClass().getFullName() : mpClass->getFullName()) + '.' + function.getPrototype();
mBuilder.emit(CIL_call, name);
}
else
{
if ( before.isObject() && before.getObjectClass().getKind() == ASTClass::eInterface )
{
//.........这里部分代码省略.........
示例3: checkFunctionAccess
void SymbolCheckVisitor::checkFunctionAccess(const ASTClass& klass, ASTAccess& access, bool isstatic)
{
ASTType before = mCurrentType;
ASTSignature signature;
ASTNodes& arguments = access.getArguments();
for ( int index = 0; index < arguments.size(); index++ )
{
ASTExpression& expr = dynamic_cast<ASTExpression&>(arguments[index]);
expr.accept(*this);
signature.append(mCurrentType.clone());
}
const ASTTypeList* ptypelist = NULL;
if ( access.hasTypeArguments() )
ptypelist = &access.getTypeArguments();
else
ptypelist = &before.getTypeArguments();
const ASTFunction* pfunction = klass.findBestMatch(access.getName(), signature, *ptypelist);
if ( pfunction != NULL )
{
const ASTSignature& funcsig = pfunction->getSignature();
// check if cast is required
for ( int index = 0; index < signature.size(); index++ )
{
const ASTType& type = signature[index];
const ASTType& fnctype = funcsig[index];
if ( !fnctype.isGeneric() && !type.equals(fnctype) )
{
ASTCast* pcast = new ASTCast();
pcast->setType(fnctype.clone());
pcast->setNode(&access.getArguments()[index]);
access.replaceArgument(index, pcast);
}
}
if ( isstatic && !pfunction->getModifiers().isStatic() )
{
error(E0047, UTEXT("Can not call non static function ") + pfunction->getName(), access);
}
access.setFunction(*pfunction);
const ASTType& type = pfunction->getType();
if ( type.isGeneric() )
{
const ASTTypeVariable& typevariable = type.getTypeVariable();
mCurrentType = before.getTypeArguments()[typevariable.getIndex()];
}
else if ( !type.getTypeArguments().empty() )
{
mCurrentType = pfunction->getType();
// if we get a generic type argument, replace it with the actual variable.
const ASTType& arg = type.getTypeArguments()[0];
if ( arg.isGeneric() )
{
const ASTTypeVariable* pvariable = klass.getTypeVariables().find(arg.getObjectName());
if ( pvariable != NULL )
{
mCurrentType.replaceArgument(before.getTypeArguments()[pvariable->getIndex()]);
}
}
}
else
{
mCurrentType = pfunction->getType();
}
}
else
{
String arguments = UTEXT("(") + signature.toString() + ')';
error(E0048, UTEXT("No matching function ") + klass.getName() + '.' + access.getName() + arguments + UTEXT(" defined."), access);
}
}