Add support for function pointers.
Both uniform and varying function pointers are supported; when a function is called through a varying function pointer, each unique function pointer value across the running program instances is called once for the set of active program instances that want to call it.
This commit is contained in:
9
decl.cpp
9
decl.cpp
@@ -91,6 +91,7 @@ Declarator::Declarator(Symbol *s, SourcePos p)
|
||||
functionArgs = NULL;
|
||||
isFunction = false;
|
||||
initExpr = NULL;
|
||||
pointerCount = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -104,6 +105,14 @@ Declarator::AddArrayDimension(int size) {
|
||||
void
|
||||
Declarator::InitFromDeclSpecs(DeclSpecs *ds) {
|
||||
sym->type = GetType(ds);
|
||||
for (int i = 0; i < pointerCount; ++i) {
|
||||
// Only function pointers for now...
|
||||
if (dynamic_cast<const FunctionType *>(sym->type) == NULL)
|
||||
Error(pos, "Only pointers to functions are currently allowed, "
|
||||
"not pointers to \"%s\".", sym->type->GetString().c_str());
|
||||
else
|
||||
sym->type = new PointerType(sym->type, true, false);
|
||||
}
|
||||
sym->storageClass = ds->storageClass;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user