Example #1
0
 public function __construct($identifier, $paramList, $_symTable, $isFunc = true)
 {
     $symFunc = $_symTable->findRecursive($identifier->getValue());
     if ($isFunc) {
         if ($symFunc == null || !is_a($symFunc, 'vendor\\SemanticParser\\Nodes\\SymFunc')) {
             //TODO: Throw exceptions like identifier <$identifier> is not a function
             SemanticException::undeclared(null, $identifier->getValue());
         }
     }
     $symFuncArgs = $symFunc->getArgs();
     if (count($paramList->params) != count($symFuncArgs)) {
         SemanticException::invalidArgCount($identifier->getValue());
     }
     for ($i = 0; $i < count($paramList->params); $i++) {
         $class = get_class($symFuncArgs[$i]->type);
         if (!$class::equal($symFuncArgs[$i]->type, $paramList->params[$i]->symType)) {
             $paramList->params[$i] = new TypeCast($paramList->params[$i], $symFuncArgs[$i]->type);
         }
     }
     if ($isFunc) {
         $this->symType = $symFunc->returnType;
     }
     $this->symbol = $symFunc;
     $this->identifier = $identifier;
     $this->paramList = $paramList;
 }