diff options
author | Adrian Thurston <thurston@complang.org> | 2015-04-01 10:24:42 -0400 |
---|---|---|
committer | Adrian Thurston <thurston@complang.org> | 2015-04-01 10:24:42 -0400 |
commit | 24e144ea5fd1275bf6c864455b2dd4d96e589363 (patch) | |
tree | 5c35d484904e32626a862bd5784b882a4f27d4b8 /src/declare.cc | |
parent | 03e0f380a472db828c3bd5ae481a6b1c10fed3d0 (diff) | |
download | colm-24e144ea5fd1275bf6c864455b2dd4d96e589363.tar.gz |
first cut of C extensions
Diffstat (limited to 'src/declare.cc')
-rw-r--r-- | src/declare.cc | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/declare.cc b/src/declare.cc index 6ecf6335..676631d3 100644 --- a/src/declare.cc +++ b/src/declare.cc @@ -1379,6 +1379,30 @@ void Compiler::makeFuncVisible( Function *func, bool isUserIter ) func->objMethod = objMethod; } +void Compiler::makeInHostVisible( Function *func ) +{ + /* Set up the parameters. */ + for ( ParameterList::Iter param = *func->paramList; param.lte(); param++ ) { + if ( func->localFrame->rootScope->findField( param->name ) != 0 ) + error(param->loc) << "parameter " << param->name << " redeclared" << endp; + + func->localFrame->rootScope->insertField( param->name, param ); + } + + /* Insert the function into the global function map. */ + ObjectMethod *objMethod = new ObjectMethod( func->typeRef, func->name, + IN_HOST, IN_HOST, + func->paramList->length(), 0, func->paramList, false ); + objMethod->funcId = func->funcId; + objMethod->useFuncId = true; + objMethod->useCallObj = false; + objMethod->func = func; + + globalObjectDef->methodMap->insert( func->name, objMethod ); + + func->objMethod = objMethod; +} + /* * Type Declaration Root. */ @@ -1391,6 +1415,9 @@ void Compiler::declarePass() for ( FunctionList::Iter f = functionList; f.lte(); f++ ) makeFuncVisible( f, f->isUserIter ); + for ( FunctionList::Iter f = inHostList; f.lte(); f++ ) + makeInHostVisible( f ); + rootNamespace->declare( this ); /* Will fill in zero lels that were not declared. */ |