Exemplo n.º 1
0
 public void Visit(IdNode node)
 {
     if (!scope.IsDefined(node.text, out node.staticType))
     {
         errors.Add(ErrorSemantic.NotDeclaredVariable(node));
     }
 }
Exemplo n.º 2
0
        public void Visit(AssignNode node)
        {
            node.exprBody.Accept(this);

            if (!scope.IsDefined(node.Id.text, out TypeInfo type))
            {
                errors.Add(ErrorSemantic.NotDeclaredVariable(node.Id));
            }

            if (!(node.exprBody.staticType <= type))
            {
                errors.Add(ErrorSemantic.CannotConvert(node, node.exprBody.staticType, type));
            }

            node.staticType = node.exprBody.staticType;
        }