public override void Visit(VariableNameAST variableName) { var ident = _symTableManager.LookupIdentifierInfo(_currentFileName, variableName.Name, _currentScopeId, _currentNodePosition); if (ident.isFnParam) { _currentValue = LLVM.GetParam(_currentFunction, (uint)ident.paramIndex); } }
private TypeAST GetVariableType(VariableNameAST variableName, bool isConstant = false) { var variableInfo = _symTableManager. LookupIdentifierInfo(_stateInfo.currentFile, variableName.Name, _stateInfo.scopeId, _stateInfo.position, isConstant); if (variableInfo == null && !_stateInfo.lookForEnum) { throw new Exception(string.Format("Undeclared {0} variable {1} in file {2}", isConstant ? "constant" : "", variableName.Name, _stateInfo.currentFile)); } if (variableInfo == null) { var isEnum = _symTableManager.LookupTypeInfo(_stateInfo.currentFile, variableName.Name); if (isEnum == null || isEnum.kind != TypeKind.ENUM) { throw new Exception(string.Format("Undeclared {0} variable {1} in file {2}", isConstant ? "constant" : "", variableName.Name, _stateInfo.currentFile)); } return(isEnum.type); } if (variableInfo.typeAST == null) { Debug.Assert(_getVariableTypeFunc != null); var previousStateInfo = _stateInfo; variableInfo.typeAST = _getVariableTypeFunc(variableInfo); _stateInfo = previousStateInfo; } return(variableInfo.typeAST); }
public override void Visit(VariableNameAST variableName) { if (_stateInfo.structOrEnum != null) { if (_stateInfo.isConst) { throw new Exception("Expression must be constant"); } if (_stateInfo.structOrEnum.kind == TypeKind.ENUM) { _stateInfo.currentType = _stateInfo.structOrEnum.type; } else { _stateInfo.currentType = _stateInfo.structOrEnum.memberNameType[variableName.Name]; } return; } _stateInfo.currentType = GetVariableType(variableName, _stateInfo.isConst); }
public virtual void Visit(VariableNameAST variableName) { }