예제 #1
0
 public override void Visit(VariableDecAST variableDec)
 {
     if (variableDec.Type.ToString() == Enum.GetName(typeof(Keyword), Keyword.VOID).ToLower())
     {
         throw new Exception("Cannot declare variable of type void");
     }
 }
예제 #2
0
        public override void Visit(VariableDecAST variableDec)
        {
            var identInfo = new IdentifierInfo
            {
                name           = variableDec.Name,
                typeAST        = variableDec.Type,
                position       = _currentNodePosition,
                scopeId        = _currentScope.id,
                isFunctionType = variableDec.Type is FunctionTypeAST
            };

            AddIdentInfoToSymTable(identInfo);

            if (_currentScope.id != 0)
            {
                return;
            }

            GlobalIdentifiers.Add(variableDec.Name);
        }
예제 #3
0
        public override void Visit(VariableDecAST variableDec)
        {
            var variableDecIdentifier = _symTableManager.LookupIdentifierInfo(_currentFileName, variableDec.Name,
                                                                              _currentScopeId, _currentNodePosition);

            if (variableDecIdentifier.valueRef.Pointer != IntPtr.Zero)
            {
                return;
            }

            LLVMTypeRef type;

            if (variableDecIdentifier.isFunctionType)
            {
                type = LLVM.PointerType(IRTypesConverter.GetFunctionType(variableDecIdentifier.typeAST as FunctionTypeAST), 0);
            }
            else
            {
                type = IRTypesConverter.PrimitivesTypesDic[variableDecIdentifier.typeAST.ToString()];
            }

            variableDecIdentifier.valueRef = LLVM.BuildAlloca(_builder, type, variableDec.Name);
        }
예제 #4
0
 public virtual void Visit(VariableDecAST variableDec)
 {
 }