Ejemplo n.º 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;
 }
Ejemplo n.º 2
0
 public function __construct($scanner, $_symTable, $identifier)
 {
     $symbol = $_symTable->findRecursive($identifier->getValue());
     if ($symbol == null || !is_a($symbol, 'vendor\\SemanticParser\\Nodes\\SymVar')) {
         SemanticException::undeclared($scanner, $identifier->getValue());
     }
     $this->symbol = $symbol;
     $this->symType = $symbol->type;
     $this->identifier = $identifier;
 }
Ejemplo n.º 3
0
 public function __construct($scanner, $_symTable, $record)
 {
     $recType = $record->variable->symType;
     if (is_a($recType, 'vendor\\SemanticParser\\Nodes\\SymAliasType')) {
         $recType = $recType->getBase();
     }
     if (!is_a($recType, 'vendor\\SemanticParser\\Nodes\\SymRecordType')) {
         SemanticException::varAccessTypeMismatch($scanner, $recType, 'record');
     }
     if (!$scanner->get()->isIdentifier()) {
         parent::simpleException($scanner, ['<FIELD-DESIGNATOR>']);
     }
     $identifier = $scanner->get()->getValue();
     $designatorType = $recType->getFieldType($identifier);
     if ($designatorType == null) {
         SemanticException::undeclared($scanner, $identifier->getValue());
     }
     $this->symType = $designatorType;
     $this->record = $record;
     $this->designator = $scanner->get();
     $scanner->next();
 }