├── .vscode ├── launch.json ├── settings.json └── tasks.json ├── CHANGELOG.md ├── README.md ├── client ├── package-lock.json ├── package.json ├── resources │ ├── html-templates │ │ ├── echarts.common.min.js │ │ ├── jquery.min.js │ │ └── temp-plot-shots.html │ └── qrunesScripts │ │ ├── Error.py │ │ ├── QcodeUtil.py │ │ ├── Symbol.py │ │ ├── SymbolTable.py │ │ ├── SymtabTree.py │ │ ├── TraverseEngine.py │ │ ├── TraverseEngineCpp.py │ │ ├── __pycache__ │ │ ├── Error.cpython-36.pyc │ │ ├── QcodeUtil.cpython-36.pyc │ │ ├── Symbol.cpython-36.pyc │ │ ├── SymbolTable.cpython-36.pyc │ │ ├── TraverseEngine.cpython-36.pyc │ │ ├── TraverseEngineCpp.cpython-36.pyc │ │ ├── generationFileUtils.cpython-36.pyc │ │ ├── qcodeCppVisitorHandle.cpython-36.pyc │ │ ├── qcodeHandle.cpython-36.pyc │ │ ├── qcodeHandleUtils.cpython-36.pyc │ │ ├── qcodePythonVisitorHandle.cpython-36.pyc │ │ └── qcodeVisitorHandle.cpython-36.pyc │ │ ├── generationFile.py │ │ ├── generationFileUtils.py │ │ ├── include │ │ ├── Core │ │ │ ├── QPanda.h │ │ │ ├── QuantumCircuit │ │ │ │ ├── CExprFactory.h │ │ │ │ ├── ClassicalConditionInterface.h │ │ │ │ ├── ClassicalProgram.h │ │ │ │ ├── ControlFlow.h │ │ │ │ ├── OriginClassicalExpression.h │ │ │ │ ├── QCircuit.h │ │ │ │ ├── QGate.h │ │ │ │ ├── QGlobalVariable.h │ │ │ │ ├── QNode.h │ │ │ │ ├── QProgram.h │ │ │ │ ├── QuantumGate.h │ │ │ │ └── QuantumMeasure.h │ │ │ ├── QuantumMachine │ │ │ │ ├── CBitFactory.h │ │ │ │ ├── CMemFactory.h │ │ │ │ ├── Factory.h │ │ │ │ ├── OriginQuantumMachine.h │ │ │ │ ├── PartialAmplitudeQVM.h │ │ │ │ ├── PhysicalQubitFactory.h │ │ │ │ ├── QCloudMachine.h │ │ │ │ ├── QResultFactory.h │ │ │ │ ├── QVec.h │ │ │ │ ├── QuantumMachineFactory.h │ │ │ │ ├── QuantumMachineInterface.h │ │ │ │ ├── QubitFactory.h │ │ │ │ ├── QubitPoolFactory.h │ │ │ │ ├── QubitReference.h │ │ │ │ └── SingleAmplitudeQVM.h │ │ │ ├── Utilities │ │ │ │ ├── CSVIostream.h │ │ │ │ ├── ComplexMatrix.h │ │ │ │ ├── ComplexVector.h │ │ │ │ ├── ConfigMap.h │ │ │ │ ├── GraphDijkstra.h │ │ │ │ ├── MetadataValidity.h │ │ │ │ ├── Micro-architecture │ │ │ │ │ └── instructions.h │ │ │ │ ├── OriginCollection.h │ │ │ │ ├── QNodeDeepCopy.h │ │ │ │ ├── QPandaException.h │ │ │ │ ├── QPandaNamespace.h │ │ │ │ ├── QStatMatrix.h │ │ │ │ ├── QString.h │ │ │ │ ├── QuantumMetadata.h │ │ │ │ ├── ReadWriteLock.h │ │ │ │ ├── TranformQGateTypeStringAndEnum.h │ │ │ │ ├── Transform │ │ │ │ │ ├── QGateCompare.h │ │ │ │ │ ├── QGateCounter.h │ │ │ │ │ ├── QProgClockCycle.h │ │ │ │ │ ├── QProgDataParse.h │ │ │ │ │ ├── QProgStored.h │ │ │ │ │ ├── QProgToQASM.h │ │ │ │ │ ├── QProgToQRunes.h │ │ │ │ │ ├── QProgToQuil.h │ │ │ │ │ ├── QProgTransform.h │ │ │ │ │ ├── QRunesToQProg.h │ │ │ │ │ └── TransformDecomposition.h │ │ │ │ ├── Traversal.h │ │ │ │ ├── Uinteger.h │ │ │ │ ├── Utilities.h │ │ │ │ ├── XMLConfigParam.h │ │ │ │ └── base64.hpp │ │ │ └── VirtualQuantumProcessor │ │ │ │ ├── CPUImplQPU.h │ │ │ │ ├── CPUImplQPUSingleThread.h │ │ │ │ ├── GPUGates │ │ │ │ ├── GPUGates.h │ │ │ │ ├── GPUGatesWrapper.h │ │ │ │ └── GPUStruct.h │ │ │ │ ├── GPUImplQPU.h │ │ │ │ ├── NoiseQPU │ │ │ │ ├── NoiseCPUImplQPU.h │ │ │ │ └── NoiseModel.h │ │ │ │ ├── PartialAmplitude │ │ │ │ ├── MergeMap.h │ │ │ │ └── TraversalQProg.h │ │ │ │ ├── QError.h │ │ │ │ ├── QPUImpl.h │ │ │ │ ├── QuantumGateParameter.h │ │ │ │ ├── RandomEngine │ │ │ │ └── RandomEngine.h │ │ │ │ └── SingleAmplitude │ │ │ │ ├── QuantumGates.h │ │ │ │ ├── TensorEngine.h │ │ │ │ └── TensorNode.h │ │ ├── QAlg │ │ │ ├── Components │ │ │ │ ├── HamiltonianSimulation │ │ │ │ │ └── HamiltonianSimulation.h │ │ │ │ ├── MaxCutProblemGenerator │ │ │ │ │ └── MaxCutProblemGenerator.h │ │ │ │ ├── Operator │ │ │ │ │ ├── FermionOperator.h │ │ │ │ │ └── PauliOperator.h │ │ │ │ └── Optimizer │ │ │ │ │ ├── AbstractOptimizer.h │ │ │ │ │ ├── OptimizerFactory.h │ │ │ │ │ ├── OriginNelderMead.h │ │ │ │ │ └── OriginPowell.h │ │ │ ├── DataStruct.h │ │ │ ├── Utils │ │ │ │ ├── RJson │ │ │ │ │ └── RJson.h │ │ │ │ └── Utilities.h │ │ │ └── marco.h │ │ ├── QPandaConfig.h │ │ ├── QPandaVersion.h │ │ ├── ThirdParty │ │ │ ├── Eigen │ │ │ │ ├── Cholesky │ │ │ │ ├── CholmodSupport │ │ │ │ ├── Core │ │ │ │ ├── Dense │ │ │ │ ├── Eigen │ │ │ │ ├── Eigenvalues │ │ │ │ ├── Geometry │ │ │ │ ├── Householder │ │ │ │ ├── IterativeLinearSolvers │ │ │ │ ├── Jacobi │ │ │ │ ├── LU │ │ │ │ ├── MetisSupport │ │ │ │ ├── OrderingMethods │ │ │ │ ├── PaStiXSupport │ │ │ │ ├── PardisoSupport │ │ │ │ ├── QR │ │ │ │ ├── QtAlignedMalloc │ │ │ │ ├── SPQRSupport │ │ │ │ ├── SVD │ │ │ │ ├── Sparse │ │ │ │ ├── SparseCholesky │ │ │ │ ├── SparseCore │ │ │ │ ├── SparseLU │ │ │ │ ├── SparseQR │ │ │ │ ├── StdDeque │ │ │ │ ├── StdList │ │ │ │ ├── StdVector │ │ │ │ ├── SuperLUSupport │ │ │ │ ├── UmfPackSupport │ │ │ │ └── src │ │ │ │ │ ├── Cholesky │ │ │ │ │ ├── LDLT.h │ │ │ │ │ ├── LLT.h │ │ │ │ │ └── LLT_LAPACKE.h │ │ │ │ │ ├── CholmodSupport │ │ │ │ │ └── CholmodSupport.h │ │ │ │ │ ├── Core │ │ │ │ │ ├── Array.h │ │ │ │ │ ├── ArrayBase.h │ │ │ │ │ ├── ArrayWrapper.h │ │ │ │ │ ├── Assign.h │ │ │ │ │ ├── AssignEvaluator.h │ │ │ │ │ ├── Assign_MKL.h │ │ │ │ │ ├── BandMatrix.h │ │ │ │ │ ├── Block.h │ │ │ │ │ ├── BooleanRedux.h │ │ │ │ │ ├── CommaInitializer.h │ │ │ │ │ ├── ConditionEstimator.h │ │ │ │ │ ├── CoreEvaluators.h │ │ │ │ │ ├── CoreIterators.h │ │ │ │ │ ├── CwiseBinaryOp.h │ │ │ │ │ ├── CwiseNullaryOp.h │ │ │ │ │ ├── CwiseTernaryOp.h │ │ │ │ │ ├── CwiseUnaryOp.h │ │ │ │ │ ├── CwiseUnaryView.h │ │ │ │ │ ├── DenseBase.h │ │ │ │ │ ├── DenseCoeffsBase.h │ │ │ │ │ ├── DenseStorage.h │ │ │ │ │ ├── Diagonal.h │ │ │ │ │ ├── DiagonalMatrix.h │ │ │ │ │ ├── DiagonalProduct.h │ │ │ │ │ ├── Dot.h │ │ │ │ │ ├── EigenBase.h │ │ │ │ │ ├── ForceAlignedAccess.h │ │ │ │ │ ├── Fuzzy.h │ │ │ │ │ ├── GeneralProduct.h │ │ │ │ │ ├── GenericPacketMath.h │ │ │ │ │ ├── GlobalFunctions.h │ │ │ │ │ ├── IO.h │ │ │ │ │ ├── Inverse.h │ │ │ │ │ ├── Map.h │ │ │ │ │ ├── MapBase.h │ │ │ │ │ ├── MathFunctions.h │ │ │ │ │ ├── MathFunctionsImpl.h │ │ │ │ │ ├── Matrix.h │ │ │ │ │ ├── MatrixBase.h │ │ │ │ │ ├── NestByValue.h │ │ │ │ │ ├── NoAlias.h │ │ │ │ │ ├── NumTraits.h │ │ │ │ │ ├── PermutationMatrix.h │ │ │ │ │ ├── PlainObjectBase.h │ │ │ │ │ ├── Product.h │ │ │ │ │ ├── ProductEvaluators.h │ │ │ │ │ ├── Random.h │ │ │ │ │ ├── Redux.h │ │ │ │ │ ├── Ref.h │ │ │ │ │ ├── Replicate.h │ │ │ │ │ ├── ReturnByValue.h │ │ │ │ │ ├── Reverse.h │ │ │ │ │ ├── Select.h │ │ │ │ │ ├── SelfAdjointView.h │ │ │ │ │ ├── SelfCwiseBinaryOp.h │ │ │ │ │ ├── Solve.h │ │ │ │ │ ├── SolveTriangular.h │ │ │ │ │ ├── SolverBase.h │ │ │ │ │ ├── StableNorm.h │ │ │ │ │ ├── Stride.h │ │ │ │ │ ├── Swap.h │ │ │ │ │ ├── Transpose.h │ │ │ │ │ ├── Transpositions.h │ │ │ │ │ ├── TriangularMatrix.h │ │ │ │ │ ├── VectorBlock.h │ │ │ │ │ ├── VectorwiseOp.h │ │ │ │ │ ├── Visitor.h │ │ │ │ │ ├── arch │ │ │ │ │ │ ├── AVX │ │ │ │ │ │ │ ├── Complex.h │ │ │ │ │ │ │ ├── MathFunctions.h │ │ │ │ │ │ │ ├── PacketMath.h │ │ │ │ │ │ │ └── TypeCasting.h │ │ │ │ │ │ ├── AVX512 │ │ │ │ │ │ │ ├── MathFunctions.h │ │ │ │ │ │ │ └── PacketMath.h │ │ │ │ │ │ ├── AltiVec │ │ │ │ │ │ │ ├── Complex.h │ │ │ │ │ │ │ ├── MathFunctions.h │ │ │ │ │ │ │ └── PacketMath.h │ │ │ │ │ │ ├── CUDA │ │ │ │ │ │ │ ├── Complex.h │ │ │ │ │ │ │ ├── Half.h │ │ │ │ │ │ │ ├── MathFunctions.h │ │ │ │ │ │ │ ├── PacketMath.h │ │ │ │ │ │ │ ├── PacketMathHalf.h │ │ │ │ │ │ │ └── TypeCasting.h │ │ │ │ │ │ ├── Default │ │ │ │ │ │ │ ├── ConjHelper.h │ │ │ │ │ │ │ └── Settings.h │ │ │ │ │ │ ├── NEON │ │ │ │ │ │ │ ├── Complex.h │ │ │ │ │ │ │ ├── MathFunctions.h │ │ │ │ │ │ │ └── PacketMath.h │ │ │ │ │ │ ├── SSE │ │ │ │ │ │ │ ├── Complex.h │ │ │ │ │ │ │ ├── MathFunctions.h │ │ │ │ │ │ │ ├── PacketMath.h │ │ │ │ │ │ │ └── TypeCasting.h │ │ │ │ │ │ └── ZVector │ │ │ │ │ │ │ ├── Complex.h │ │ │ │ │ │ │ ├── MathFunctions.h │ │ │ │ │ │ │ └── PacketMath.h │ │ │ │ │ ├── functors │ │ │ │ │ │ ├── AssignmentFunctors.h │ │ │ │ │ │ ├── BinaryFunctors.h │ │ │ │ │ │ ├── NullaryFunctors.h │ │ │ │ │ │ ├── StlFunctors.h │ │ │ │ │ │ ├── TernaryFunctors.h │ │ │ │ │ │ └── UnaryFunctors.h │ │ │ │ │ ├── products │ │ │ │ │ │ ├── GeneralBlockPanelKernel.h │ │ │ │ │ │ ├── GeneralMatrixMatrix.h │ │ │ │ │ │ ├── GeneralMatrixMatrixTriangular.h │ │ │ │ │ │ ├── GeneralMatrixMatrixTriangular_BLAS.h │ │ │ │ │ │ ├── GeneralMatrixMatrix_BLAS.h │ │ │ │ │ │ ├── GeneralMatrixVector.h │ │ │ │ │ │ ├── GeneralMatrixVector_BLAS.h │ │ │ │ │ │ ├── Parallelizer.h │ │ │ │ │ │ ├── SelfadjointMatrixMatrix.h │ │ │ │ │ │ ├── SelfadjointMatrixMatrix_BLAS.h │ │ │ │ │ │ ├── SelfadjointMatrixVector.h │ │ │ │ │ │ ├── SelfadjointMatrixVector_BLAS.h │ │ │ │ │ │ ├── SelfadjointProduct.h │ │ │ │ │ │ ├── SelfadjointRank2Update.h │ │ │ │ │ │ ├── TriangularMatrixMatrix.h │ │ │ │ │ │ ├── TriangularMatrixMatrix_BLAS.h │ │ │ │ │ │ ├── TriangularMatrixVector.h │ │ │ │ │ │ ├── TriangularMatrixVector_BLAS.h │ │ │ │ │ │ ├── TriangularSolverMatrix.h │ │ │ │ │ │ ├── TriangularSolverMatrix_BLAS.h │ │ │ │ │ │ └── TriangularSolverVector.h │ │ │ │ │ └── util │ │ │ │ │ │ ├── BlasUtil.h │ │ │ │ │ │ ├── Constants.h │ │ │ │ │ │ ├── DisableStupidWarnings.h │ │ │ │ │ │ ├── ForwardDeclarations.h │ │ │ │ │ │ ├── MKL_support.h │ │ │ │ │ │ ├── Macros.h │ │ │ │ │ │ ├── Memory.h │ │ │ │ │ │ ├── Meta.h │ │ │ │ │ │ ├── NonMPL2.h │ │ │ │ │ │ ├── ReenableStupidWarnings.h │ │ │ │ │ │ ├── StaticAssert.h │ │ │ │ │ │ └── XprHelper.h │ │ │ │ │ ├── Eigenvalues │ │ │ │ │ ├── ComplexEigenSolver.h │ │ │ │ │ ├── ComplexSchur.h │ │ │ │ │ ├── ComplexSchur_LAPACKE.h │ │ │ │ │ ├── EigenSolver.h │ │ │ │ │ ├── GeneralizedEigenSolver.h │ │ │ │ │ ├── GeneralizedSelfAdjointEigenSolver.h │ │ │ │ │ ├── HessenbergDecomposition.h │ │ │ │ │ ├── MatrixBaseEigenvalues.h │ │ │ │ │ ├── RealQZ.h │ │ │ │ │ ├── RealSchur.h │ │ │ │ │ ├── RealSchur_LAPACKE.h │ │ │ │ │ ├── SelfAdjointEigenSolver.h │ │ │ │ │ ├── SelfAdjointEigenSolver_LAPACKE.h │ │ │ │ │ └── Tridiagonalization.h │ │ │ │ │ ├── Geometry │ │ │ │ │ ├── AlignedBox.h │ │ │ │ │ ├── AngleAxis.h │ │ │ │ │ ├── EulerAngles.h │ │ │ │ │ ├── Homogeneous.h │ │ │ │ │ ├── Hyperplane.h │ │ │ │ │ ├── OrthoMethods.h │ │ │ │ │ ├── ParametrizedLine.h │ │ │ │ │ ├── Quaternion.h │ │ │ │ │ ├── Rotation2D.h │ │ │ │ │ ├── RotationBase.h │ │ │ │ │ ├── Scaling.h │ │ │ │ │ ├── Transform.h │ │ │ │ │ ├── Translation.h │ │ │ │ │ ├── Umeyama.h │ │ │ │ │ └── arch │ │ │ │ │ │ └── Geometry_SSE.h │ │ │ │ │ ├── Householder │ │ │ │ │ ├── BlockHouseholder.h │ │ │ │ │ ├── Householder.h │ │ │ │ │ └── HouseholderSequence.h │ │ │ │ │ ├── IterativeLinearSolvers │ │ │ │ │ ├── BasicPreconditioners.h │ │ │ │ │ ├── BiCGSTAB.h │ │ │ │ │ ├── ConjugateGradient.h │ │ │ │ │ ├── Eigen.lnk │ │ │ │ │ ├── IncompleteCholesky.h │ │ │ │ │ ├── IncompleteLUT.h │ │ │ │ │ ├── IterativeSolverBase.h │ │ │ │ │ ├── LeastSquareConjugateGradient.h │ │ │ │ │ └── SolveWithGuess.h │ │ │ │ │ ├── Jacobi │ │ │ │ │ └── Jacobi.h │ │ │ │ │ ├── LU │ │ │ │ │ ├── Determinant.h │ │ │ │ │ ├── FullPivLU.h │ │ │ │ │ ├── InverseImpl.h │ │ │ │ │ ├── PartialPivLU.h │ │ │ │ │ ├── PartialPivLU_LAPACKE.h │ │ │ │ │ └── arch │ │ │ │ │ │ └── Inverse_SSE.h │ │ │ │ │ ├── MetisSupport │ │ │ │ │ └── MetisSupport.h │ │ │ │ │ ├── OrderingMethods │ │ │ │ │ ├── Amd.h │ │ │ │ │ ├── Eigen_Colamd.h │ │ │ │ │ └── Ordering.h │ │ │ │ │ ├── PaStiXSupport │ │ │ │ │ └── PaStiXSupport.h │ │ │ │ │ ├── PardisoSupport │ │ │ │ │ └── PardisoSupport.h │ │ │ │ │ ├── QR │ │ │ │ │ ├── ColPivHouseholderQR.h │ │ │ │ │ ├── ColPivHouseholderQR_LAPACKE.h │ │ │ │ │ ├── CompleteOrthogonalDecomposition.h │ │ │ │ │ ├── FullPivHouseholderQR.h │ │ │ │ │ ├── HouseholderQR.h │ │ │ │ │ └── HouseholderQR_LAPACKE.h │ │ │ │ │ ├── SPQRSupport │ │ │ │ │ └── SuiteSparseQRSupport.h │ │ │ │ │ ├── SVD │ │ │ │ │ ├── BDCSVD.h │ │ │ │ │ ├── JacobiSVD.h │ │ │ │ │ ├── JacobiSVD_LAPACKE.h │ │ │ │ │ ├── SVDBase.h │ │ │ │ │ └── UpperBidiagonalization.h │ │ │ │ │ ├── SparseCholesky │ │ │ │ │ ├── SimplicialCholesky.h │ │ │ │ │ └── SimplicialCholesky_impl.h │ │ │ │ │ ├── SparseCore │ │ │ │ │ ├── AmbiVector.h │ │ │ │ │ ├── CompressedStorage.h │ │ │ │ │ ├── ConservativeSparseSparseProduct.h │ │ │ │ │ ├── MappedSparseMatrix.h │ │ │ │ │ ├── SparseAssign.h │ │ │ │ │ ├── SparseBlock.h │ │ │ │ │ ├── SparseColEtree.h │ │ │ │ │ ├── SparseCompressedBase.h │ │ │ │ │ ├── SparseCwiseBinaryOp.h │ │ │ │ │ ├── SparseCwiseUnaryOp.h │ │ │ │ │ ├── SparseDenseProduct.h │ │ │ │ │ ├── SparseDiagonalProduct.h │ │ │ │ │ ├── SparseDot.h │ │ │ │ │ ├── SparseFuzzy.h │ │ │ │ │ ├── SparseMap.h │ │ │ │ │ ├── SparseMatrix.h │ │ │ │ │ ├── SparseMatrixBase.h │ │ │ │ │ ├── SparsePermutation.h │ │ │ │ │ ├── SparseProduct.h │ │ │ │ │ ├── SparseRedux.h │ │ │ │ │ ├── SparseRef.h │ │ │ │ │ ├── SparseSelfAdjointView.h │ │ │ │ │ ├── SparseSolverBase.h │ │ │ │ │ ├── SparseSparseProductWithPruning.h │ │ │ │ │ ├── SparseTranspose.h │ │ │ │ │ ├── SparseTriangularView.h │ │ │ │ │ ├── SparseUtil.h │ │ │ │ │ ├── SparseVector.h │ │ │ │ │ ├── SparseView.h │ │ │ │ │ └── TriangularSolver.h │ │ │ │ │ ├── SparseLU │ │ │ │ │ ├── SparseLU.h │ │ │ │ │ ├── SparseLUImpl.h │ │ │ │ │ ├── SparseLU_Memory.h │ │ │ │ │ ├── SparseLU_Structs.h │ │ │ │ │ ├── SparseLU_SupernodalMatrix.h │ │ │ │ │ ├── SparseLU_Utils.h │ │ │ │ │ ├── SparseLU_column_bmod.h │ │ │ │ │ ├── SparseLU_column_dfs.h │ │ │ │ │ ├── SparseLU_copy_to_ucol.h │ │ │ │ │ ├── SparseLU_gemm_kernel.h │ │ │ │ │ ├── SparseLU_heap_relax_snode.h │ │ │ │ │ ├── SparseLU_kernel_bmod.h │ │ │ │ │ ├── SparseLU_panel_bmod.h │ │ │ │ │ ├── SparseLU_panel_dfs.h │ │ │ │ │ ├── SparseLU_pivotL.h │ │ │ │ │ ├── SparseLU_pruneL.h │ │ │ │ │ └── SparseLU_relax_snode.h │ │ │ │ │ ├── SparseQR │ │ │ │ │ └── SparseQR.h │ │ │ │ │ ├── StlSupport │ │ │ │ │ ├── StdDeque.h │ │ │ │ │ ├── StdList.h │ │ │ │ │ ├── StdVector.h │ │ │ │ │ └── details.h │ │ │ │ │ ├── SuperLUSupport │ │ │ │ │ └── SuperLUSupport.h │ │ │ │ │ ├── UmfPackSupport │ │ │ │ │ └── UmfPackSupport.h │ │ │ │ │ ├── misc │ │ │ │ │ ├── Image.h │ │ │ │ │ ├── Kernel.h │ │ │ │ │ ├── RealSvd2x2.h │ │ │ │ │ ├── blas.h │ │ │ │ │ ├── lapack.h │ │ │ │ │ ├── lapacke.h │ │ │ │ │ └── lapacke_mangling.h │ │ │ │ │ └── plugins │ │ │ │ │ ├── ArrayCwiseBinaryOps.h │ │ │ │ │ ├── ArrayCwiseUnaryOps.h │ │ │ │ │ ├── BlockMethods.h │ │ │ │ │ ├── CommonCwiseBinaryOps.h │ │ │ │ │ ├── CommonCwiseUnaryOps.h │ │ │ │ │ ├── MatrixCwiseBinaryOps.h │ │ │ │ │ └── MatrixCwiseUnaryOps.h │ │ │ ├── TinyXML │ │ │ │ ├── tinystr.h │ │ │ │ └── tinyxml.h │ │ │ ├── bplus-tree │ │ │ │ └── include │ │ │ │ │ ├── bplus.h │ │ │ │ │ └── private │ │ │ │ │ ├── errors.h │ │ │ │ │ ├── pages.h │ │ │ │ │ ├── tree.h │ │ │ │ │ ├── utils.h │ │ │ │ │ ├── values.h │ │ │ │ │ └── writer.h │ │ │ └── rapidjson │ │ │ │ ├── allocators.h │ │ │ │ ├── cursorstreamwrapper.h │ │ │ │ ├── document.h │ │ │ │ ├── encodedstream.h │ │ │ │ ├── encodings.h │ │ │ │ ├── error │ │ │ │ ├── en.h │ │ │ │ └── error.h │ │ │ │ ├── filereadstream.h │ │ │ │ ├── filewritestream.h │ │ │ │ ├── fwd.h │ │ │ │ ├── internal │ │ │ │ ├── biginteger.h │ │ │ │ ├── diyfp.h │ │ │ │ ├── dtoa.h │ │ │ │ ├── ieee754.h │ │ │ │ ├── itoa.h │ │ │ │ ├── meta.h │ │ │ │ ├── pow10.h │ │ │ │ ├── regex.h │ │ │ │ ├── stack.h │ │ │ │ ├── strfunc.h │ │ │ │ ├── strtod.h │ │ │ │ └── swap.h │ │ │ │ ├── istreamwrapper.h │ │ │ │ ├── memorybuffer.h │ │ │ │ ├── memorystream.h │ │ │ │ ├── msinttypes │ │ │ │ ├── inttypes.h │ │ │ │ └── stdint.h │ │ │ │ ├── ostreamwrapper.h │ │ │ │ ├── pointer.h │ │ │ │ ├── prettywriter.h │ │ │ │ ├── rapidjson.h │ │ │ │ ├── reader.h │ │ │ │ ├── schema.h │ │ │ │ ├── stream.h │ │ │ │ ├── stringbuffer.h │ │ │ │ └── writer.h │ │ └── Variational │ │ │ ├── DataType.h │ │ │ ├── Optimizer.h │ │ │ ├── VarFermionOperator.h │ │ │ ├── VarPauliOperator.h │ │ │ ├── expression.h │ │ │ ├── utils.h │ │ │ └── var.h │ │ ├── lib_linux │ │ ├── libQAlg.a │ │ ├── libQPanda2.0.a │ │ └── libTinyXML.a │ │ ├── lib_windows │ │ ├── libBplusTree.a │ │ ├── libQAlg.a │ │ ├── libQPanda2.a │ │ ├── libTinyXML.a │ │ ├── libVariational.a │ │ ├── libgtest.a │ │ ├── libpyQPanda.dll.a │ │ └── libpyQPandaPauliOperator.dll.a │ │ ├── qcode │ │ ├── qcode.interp │ │ ├── qcode.tokens │ │ ├── qcodeLexer.interp │ │ ├── qcodeLexer.py │ │ ├── qcodeLexer.tokens │ │ ├── qcodeListener.py │ │ ├── qcodeParser.py │ │ └── qcodeVisitor.py │ │ ├── qcodeCppVisitorHandle.py │ │ ├── qcodeHandle.py │ │ ├── qcodeHandleUtils.py │ │ ├── qcodePythonVisitorHandle.py │ │ ├── qcodeVisitorHandle.py │ │ ├── qcodes.p │ │ ├── qcodes.q │ │ └── sh.bat ├── src │ ├── activationUtils.ts │ ├── commandExecutor.ts │ ├── configuration.ts │ ├── dependencies │ │ ├── dependency.ts │ │ └── dependencyMgr.ts │ ├── extension.ts │ ├── interfaces.ts │ ├── logger.ts │ ├── packages │ │ ├── packageManager.ts │ │ └── types.ts │ ├── pip │ │ ├── packageInfoParser.ts │ │ ├── pipCommandExecutor.ts │ │ ├── pipExecutor.ts │ │ └── pypiExecutor.ts │ ├── resultProvider.ts │ ├── utils.ts │ ├── version.ts │ ├── visualizations.ts │ └── visualizations │ │ ├── __mocks__ │ │ └── renderBuilder.ts │ │ ├── deviceStatusVisualization.ts │ │ ├── histogramRenderer.ts │ │ ├── preformattedRenderer.ts │ │ ├── renderBuilder.ts │ │ └── types.ts └── tsconfig.json ├── docs ├── Makefile ├── conf.py ├── images │ ├── Jump_definition.gif │ ├── autoComplete.gif │ ├── autoCompletion.png │ ├── checkDependencies.png │ ├── checkSuccess.png │ ├── demo.png │ ├── execute-sample.gif │ ├── extension.png │ ├── highlight.png │ ├── hover.gif │ ├── languageChange.gif │ ├── qurator_test.png │ ├── result.png │ ├── run.gif │ ├── runQRunes.png │ ├── runQRunes2.png │ ├── run_1.png │ ├── run_2.png │ ├── run_3.png │ ├── run_4.png │ ├── snippet.gif │ └── validation.gif ├── index.rst ├── make.bat └── source │ ├── changeLog.rst │ ├── functionDetail.rst │ ├── prerequisites.rst │ └── quickStart.rst ├── icon.png ├── index.md ├── package-lock.json ├── package.json ├── qrunes-configuration.json ├── server ├── QPandaSDK.json ├── package-lock.json ├── package.json ├── pyQpandaSDK.json ├── qcodeSDK.json ├── src │ ├── qrunesModes │ │ ├── embeddedModeImpl │ │ │ ├── commonCompiler │ │ │ │ ├── multiScopeSymbolTable.ts │ │ │ │ ├── scope.ts │ │ │ │ ├── symbols.ts │ │ │ │ ├── types.ts │ │ │ │ └── variableDefinition.ts │ │ │ ├── compilation.ts │ │ │ ├── compilationPython.ts │ │ │ ├── cpp │ │ │ │ ├── antlr │ │ │ │ │ ├── .antlr │ │ │ │ │ │ ├── CPP14.interp │ │ │ │ │ │ ├── CPP14.tokens │ │ │ │ │ │ ├── CPP14Lexer.interp │ │ │ │ │ │ ├── CPP14Lexer.java │ │ │ │ │ │ ├── CPP14Lexer.tokens │ │ │ │ │ │ └── CPP14Parser.java │ │ │ │ │ ├── CPP14.g4 │ │ │ │ │ ├── CPP14.tokens │ │ │ │ │ ├── CPP14Lexer.tokens │ │ │ │ │ ├── CPP14Lexer.ts │ │ │ │ │ ├── CPP14Listener.ts │ │ │ │ │ ├── CPP14Parser.ts │ │ │ │ │ └── CPP14Visitor.ts │ │ │ │ ├── ast │ │ │ │ │ ├── treeFolder.ts │ │ │ │ │ └── types.ts │ │ │ │ ├── parser.ts │ │ │ │ ├── suggester.ts │ │ │ │ └── suggestions │ │ │ │ │ ├── methodsDictionary.ts │ │ │ │ │ ├── suggestionsCalculator.ts │ │ │ │ │ └── suggestionsDictionary.ts │ │ │ ├── python │ │ │ │ ├── antlr │ │ │ │ │ ├── .antlr │ │ │ │ │ │ ├── Python3.interp │ │ │ │ │ │ ├── Python3.tokens │ │ │ │ │ │ ├── Python3Lexer.interp │ │ │ │ │ │ ├── Python3Lexer.java │ │ │ │ │ │ ├── Python3Lexer.tokens │ │ │ │ │ │ └── Python3Parser.java │ │ │ │ │ ├── Python3.g4 │ │ │ │ │ ├── Python3.tokens │ │ │ │ │ ├── Python3Lexer.tokens │ │ │ │ │ ├── Python3Lexer.ts │ │ │ │ │ ├── Python3Listener.ts │ │ │ │ │ ├── Python3Parser.ts │ │ │ │ │ └── Python3Visitor.ts │ │ │ │ ├── ast │ │ │ │ │ ├── importsAnalyzer.ts │ │ │ │ │ ├── semanticAnalyzer.ts │ │ │ │ │ ├── symbolTableGenerator.ts │ │ │ │ │ ├── tools │ │ │ │ │ │ └── errorBuilder.ts │ │ │ │ │ ├── treeFolder.ts │ │ │ │ │ └── types.ts │ │ │ │ ├── compiler │ │ │ │ │ ├── qpandaSymbolTableBuilder.ts │ │ │ │ │ ├── scope.ts │ │ │ │ │ ├── symbols.ts │ │ │ │ │ └── tools │ │ │ │ │ │ └── errorMessages.ts │ │ │ │ ├── libs │ │ │ │ │ └── PyQpandaSDK.ts │ │ │ │ ├── parser.ts │ │ │ │ ├── suggester.ts │ │ │ │ └── suggestions │ │ │ │ │ ├── methodsDictionary.ts │ │ │ │ │ ├── suggestionsCalculator.ts │ │ │ │ │ └── suggestionsDictionary.ts │ │ │ ├── qcodes │ │ │ │ ├── antlr │ │ │ │ │ ├── .antlr │ │ │ │ │ │ ├── qcode.interp │ │ │ │ │ │ ├── qcode.tokens │ │ │ │ │ │ ├── qcodeLexer.interp │ │ │ │ │ │ ├── qcodeLexer.java │ │ │ │ │ │ ├── qcodeLexer.tokens │ │ │ │ │ │ └── qcodeParser.java │ │ │ │ │ ├── qcode.g4 │ │ │ │ │ ├── qcode.tokens │ │ │ │ │ ├── qcodeLexer.tokens │ │ │ │ │ ├── qcodeLexer.ts │ │ │ │ │ ├── qcodeListener.ts │ │ │ │ │ ├── qcodeParser.ts │ │ │ │ │ └── qcodeVisitor.ts │ │ │ │ ├── compiler │ │ │ │ │ ├── qcodesSyntacticParser.ts │ │ │ │ │ ├── semanticAnalyzer.ts │ │ │ │ │ ├── symbolTable.ts │ │ │ │ │ ├── symbolTableGenerator.ts │ │ │ │ │ ├── tools │ │ │ │ │ │ └── errorMessages.ts │ │ │ │ │ ├── types.ts │ │ │ │ │ └── validations │ │ │ │ │ │ └── validations.ts │ │ │ │ ├── libs │ │ │ │ │ └── qcodeSDK.ts │ │ │ │ ├── parser.ts │ │ │ │ ├── suggester.ts │ │ │ │ └── suggestions │ │ │ │ │ ├── atomFinder.ts │ │ │ │ │ ├── methodsDictionary.ts │ │ │ │ │ ├── suggestionsCalculator.ts │ │ │ │ │ └── suggestionsDictionary.ts │ │ │ ├── settings │ │ │ │ ├── antlr │ │ │ │ │ ├── .antlr │ │ │ │ │ │ ├── setting.interp │ │ │ │ │ │ ├── setting.tokens │ │ │ │ │ │ ├── settingLexer.interp │ │ │ │ │ │ ├── settingLexer.java │ │ │ │ │ │ ├── settingLexer.tokens │ │ │ │ │ │ └── settingParser.java │ │ │ │ │ ├── setting.g4 │ │ │ │ │ ├── setting.tokens │ │ │ │ │ ├── settingLexer.tokens │ │ │ │ │ ├── settingLexer.ts │ │ │ │ │ ├── settingListener.ts │ │ │ │ │ ├── settingParser.ts │ │ │ │ │ └── settingVisitor.ts │ │ │ │ ├── compiler │ │ │ │ │ ├── settingsSyntacticParser.ts │ │ │ │ │ ├── symbolTable.ts │ │ │ │ │ ├── symbolTableGenerator.ts │ │ │ │ │ ├── tools │ │ │ │ │ │ └── errorMessages.ts │ │ │ │ │ └── validations │ │ │ │ │ │ └── validations.ts │ │ │ │ ├── parser.ts │ │ │ │ └── suggester.ts │ │ │ ├── tools │ │ │ │ ├── errorBuilder.ts │ │ │ │ ├── errorListener.ts │ │ │ │ ├── positionAdapter.ts │ │ │ │ ├── suggestionSymbolAdapter.ts │ │ │ │ └── treePrinter.ts │ │ │ └── types.ts │ │ ├── embeddedSupport.ts │ │ ├── languageModelCache.ts │ │ ├── languageModes.ts │ │ ├── modes │ │ │ ├── hostLanguageModes │ │ │ │ ├── cppScriptMode.ts │ │ │ │ └── pyScriptMode.ts │ │ │ ├── qrunesMode │ │ │ │ └── qrunesMode.ts │ │ │ ├── quantumMode │ │ │ │ └── qcodesMode.ts │ │ │ └── settingMode │ │ │ │ └── settingsMode.ts │ │ └── qrunesService │ │ │ ├── parser │ │ │ ├── qrunesParser.ts │ │ │ ├── qrunesScanner.ts │ │ │ └── qrunesTags.ts │ │ │ ├── qrunesLanguageService.ts │ │ │ ├── qrunesLanguageTypes.ts │ │ │ └── qrunesServiceImpl │ │ │ ├── qrunesCompletion.ts │ │ │ ├── qrunesHighlighting.ts │ │ │ ├── qrunesHover.ts │ │ │ └── tagProviders.ts │ ├── server.ts │ └── tools │ │ ├── arrays.ts │ │ ├── runner.ts │ │ └── strings.ts └── tsconfig.json ├── snippets └── qrunes-snippets.json ├── syntaxes └── qrunes-grammars.json ├── themes ├── qrunes-dark.json └── qrunes-light.json └── tsconfig.base.json /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | //QRunes launch configuration 2 | { 3 | "version": "0.2.0", 4 | "configurations": [ 5 | { 6 | "type": "extensionHost", 7 | "request": "launch", 8 | "name": "Launch Client", 9 | "runtimeExecutable": "${execPath}", 10 | "args": ["--extensionDevelopmentPath=${workspaceRoot}"], 11 | "outFiles": ["${workspaceRoot}/client/out/**/*.js"], 12 | "preLaunchTask": "npm: watch:client" 13 | }, 14 | { 15 | "type": "node", 16 | "request": "attach", 17 | "name": "Attach to Server", 18 | "port": 6009, 19 | "restart": true, 20 | "outFiles": ["${workspaceRoot}/server/out/**/*.js"] 21 | } 22 | ], 23 | "compounds": [ 24 | { 25 | "name": "Client + Server", 26 | "configurations": ["Launch Client", "Attach to Server"] 27 | } 28 | ] 29 | } 30 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "html.suggest.angular1": false, 3 | "html.suggest.ionic": false, 4 | "git.ignoreLimitWarning": true 5 | } 6 | -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "compile", 6 | "dependsOn": [ 7 | { 8 | "type": "npm", 9 | "script": "compile:client" 10 | }, 11 | { 12 | "type": "npm", 13 | "script": "compile:server" 14 | } 15 | ], 16 | "problemMatcher": [] 17 | }, 18 | { 19 | "type": "npm", 20 | "script": "compile:client", 21 | "group": "build", 22 | "presentation": { 23 | "panel": "dedicated", 24 | "reveal": "never" 25 | }, 26 | "problemMatcher": [ 27 | "$tsc" 28 | ] 29 | }, 30 | { 31 | "type": "npm", 32 | "script": "compile:server", 33 | "group": "build", 34 | "presentation": { 35 | "panel": "dedicated", 36 | "reveal": "never" 37 | }, 38 | "problemMatcher": [ 39 | "$tsc" 40 | ] 41 | }, 42 | { 43 | "label": "watch", 44 | "dependsOn": [ 45 | { 46 | "type": "npm", 47 | "script": "watch:client" 48 | }, 49 | { 50 | "type": "npm", 51 | "script": "watch:server" 52 | } 53 | ], 54 | "group": { 55 | "kind": "build", 56 | "isDefault": true 57 | }, 58 | "problemMatcher": [] 59 | }, 60 | { 61 | "type": "npm", 62 | "script": "watch:client", 63 | "isBackground": true, 64 | "group": "build", 65 | "presentation": { 66 | "panel": "dedicated", 67 | "reveal": "never" 68 | }, 69 | "problemMatcher": [ 70 | "$tsc-watch" 71 | ] 72 | }, 73 | { 74 | "type": "npm", 75 | "script": "watch:server", 76 | "isBackground": true, 77 | "group": "build", 78 | "presentation": { 79 | "panel": "dedicated", 80 | "reveal": "never" 81 | }, 82 | "problemMatcher": [ 83 | "$tsc-watch" 84 | ] 85 | } 86 | ] 87 | } -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## 0.1.4 (27 August 2019) 4 | 5 | ### Enhancements 6 | 7 | 1. Adding Definition Jump. 8 | 2. Adding vscode terminal calls. 9 | 3. Support while loop. 10 | 4. Added logic gate dagger and control operation. 11 | 12 | ### Fixes 13 | 14 | 1. Modifying grammatical rules. 15 | 16 | ## 0.1.3 (9 May 2019) 17 | 18 | ### Fixes 19 | 20 | 1. Modify the specified version of pyqpanda package. 21 | 22 | ## 0.1.2 (24 April 2019) 23 | 24 | ### Enhancements 25 | 26 | 1. Added WebView command to display result window. 27 | 28 | ### Fixes 29 | 30 | 1. Removing the vscode.previewHtml command. 31 | 2. Fixed the validation of the @settings section. 32 | 33 | ## 0.1.1 (1 Mar 2019) 34 | 35 | ### Enhancements 36 | 37 | 1. Added support for Ubuntu. 38 | 2. Added support for auto completion and hover of C++. 39 | 3. Updated snippets function. 40 | 4. Added support for highlighting of some keywords. 41 | 5. Added Qurator User Manual. 42 | 43 | ### Fixes 44 | 45 | 1. Fixed auto completion for python with different encodings. 46 | 2. Fixed the messy code of QCode hint. 47 | 3. Fixed validation for wrong qrunes label(@settings,@qcode and @script). 48 | 49 | -------------------------------------------------------------------------------- /client/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "qurator-vscode", 3 | "description": "A general purpose quantum programming language.", 4 | "author": "Qurator", 5 | "version": "0.1.0", 6 | "publisher": "Qurator", 7 | "engines": { 8 | "vscode": "^1.27.0" 9 | }, 10 | "scripts": { 11 | "update-vscode": "vscode-install", 12 | "postinstall": "vscode-install" 13 | }, 14 | "dependencies": { 15 | "@types/nunjucks": "^3.1.0", 16 | "compile": "0.0.2", 17 | "eslint": "^5.7.0", 18 | "nunjucks": "^3.1.3", 19 | "q": "^1.4.1", 20 | "typed-rest-client": "^1.0.9", 21 | "typescript": "^3.1.1", 22 | "vscode": "^1.1.21", 23 | "vscode-languageclient": "^5.1.1", 24 | "winston": "^3.1.0" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/Error.py: -------------------------------------------------------------------------------- 1 | from enum import Enum 2 | 3 | 4 | class ErrorCode(Enum): 5 | UNEXPECTED_TOKEN = 'Unexpected token' 6 | ID_NOT_FOUND = 'Identifier not found' 7 | DUPLICATE_ID = 'Duplicate id found' 8 | 9 | 10 | class Error(Exception): 11 | def __init__(self, error_code=None, token=None, message=None): 12 | self.error_code = error_code 13 | self.token = token 14 | # add exception class name before the message 15 | self.message = f'{self.__class__.__name__}: {message}' 16 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/SymbolTable.py: -------------------------------------------------------------------------------- 1 | 2 | from Symbol import * 3 | 4 | from Error import * 5 | 6 | 7 | class SymbolTable: 8 | def __init__(self, symtab_name, scope_level, enclosing_scope=None): 9 | self.symbols = {} 10 | self.symtab_name = symtab_name 11 | self.scope_level = scope_level 12 | self.enclosing_scope = enclosing_scope 13 | 14 | def init_builtins(self): 15 | self.insert(BuiltinTypeSymbol('let')) 16 | self.insert(BuiltinTypeSymbol('qubit')) 17 | 18 | def insert(self, symbol): 19 | self.symbols[symbol.name] = symbol 20 | 21 | def lookup(self, name): 22 | symbol = self.symbols.get(name) 23 | # 'symbol' is either an instance of the Symbol class or None 24 | if symbol is not None: 25 | print("find Symbol in symtab") 26 | return symbol 27 | else: 28 | print("not in any symtab") 29 | 30 | def search_all(self, name): 31 | # print("当前名字", scope.enclosing_scope.symbols) 32 | symbol = self.symbols.get(name) 33 | # 'symbol' is either an instance of the Symbol class or None 34 | if symbol is not None: 35 | return symbol 36 | if self.enclosing_scope is not None: 37 | return self.enclosing_scope.search_all(name) 38 | 39 | def __str__(self): 40 | h1 = 'Symbol Table' 41 | lines = ['\n', h1, '=' * len(h1)*2] 42 | for header_name, header_value in ( 43 | ('Symtab name', self.symtab_name), 44 | ('Scope level', self.scope_level), 45 | ('Enclosing scope', 46 | self.enclosing_scope.symtab_name if self.enclosing_scope else None 47 | ) 48 | ): 49 | lines.append('%-15s: %s' % (header_name, header_value)) 50 | h2 = '** Symbol Table Info **' 51 | lines.extend([h2, '-' * len(h2)*2]) 52 | lines.extend( 53 | ('%7s: %r' % (key, value)) 54 | for key, value in self.symbols.items() 55 | ) 56 | lines.append('\n') 57 | s = '\n'.join(lines) 58 | return s 59 | 60 | __repr__ = __str__ 61 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/SymtabTree.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | class Node: 4 | def __init__(self, elem=-1, children=None): 5 | self.elem = elem 6 | self.children = children 7 | 8 | 9 | class Tree(object): 10 | def __init__(self, root=None): 11 | self.root = root 12 | 13 | def add(self, elem): 14 | node = Node(elem) 15 | if self.root is None: 16 | self.root = node 17 | else: 18 | queue = [] 19 | queue.append(self.root) 20 | while queue: 21 | cur = queue.pop(0) 22 | if cur.lchild is None: 23 | cur.lchild is node 24 | return 25 | elif cur.rchild is None: 26 | cur.rchild is node 27 | return 28 | else: 29 | queue.append(cur.lchild) 30 | queue.append(cur.rchild) 31 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/__pycache__/Error.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/qurator-vscode/ddb73d09b6e4700cd45c9dcabd09ea3c2c432713/client/resources/qrunesScripts/__pycache__/Error.cpython-36.pyc -------------------------------------------------------------------------------- /client/resources/qrunesScripts/__pycache__/QcodeUtil.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/qurator-vscode/ddb73d09b6e4700cd45c9dcabd09ea3c2c432713/client/resources/qrunesScripts/__pycache__/QcodeUtil.cpython-36.pyc -------------------------------------------------------------------------------- /client/resources/qrunesScripts/__pycache__/Symbol.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/qurator-vscode/ddb73d09b6e4700cd45c9dcabd09ea3c2c432713/client/resources/qrunesScripts/__pycache__/Symbol.cpython-36.pyc -------------------------------------------------------------------------------- /client/resources/qrunesScripts/__pycache__/SymbolTable.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/qurator-vscode/ddb73d09b6e4700cd45c9dcabd09ea3c2c432713/client/resources/qrunesScripts/__pycache__/SymbolTable.cpython-36.pyc -------------------------------------------------------------------------------- /client/resources/qrunesScripts/__pycache__/TraverseEngine.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/qurator-vscode/ddb73d09b6e4700cd45c9dcabd09ea3c2c432713/client/resources/qrunesScripts/__pycache__/TraverseEngine.cpython-36.pyc -------------------------------------------------------------------------------- /client/resources/qrunesScripts/__pycache__/TraverseEngineCpp.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/qurator-vscode/ddb73d09b6e4700cd45c9dcabd09ea3c2c432713/client/resources/qrunesScripts/__pycache__/TraverseEngineCpp.cpython-36.pyc -------------------------------------------------------------------------------- /client/resources/qrunesScripts/__pycache__/generationFileUtils.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/qurator-vscode/ddb73d09b6e4700cd45c9dcabd09ea3c2c432713/client/resources/qrunesScripts/__pycache__/generationFileUtils.cpython-36.pyc -------------------------------------------------------------------------------- /client/resources/qrunesScripts/__pycache__/qcodeCppVisitorHandle.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/qurator-vscode/ddb73d09b6e4700cd45c9dcabd09ea3c2c432713/client/resources/qrunesScripts/__pycache__/qcodeCppVisitorHandle.cpython-36.pyc -------------------------------------------------------------------------------- /client/resources/qrunesScripts/__pycache__/qcodeHandle.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/qurator-vscode/ddb73d09b6e4700cd45c9dcabd09ea3c2c432713/client/resources/qrunesScripts/__pycache__/qcodeHandle.cpython-36.pyc -------------------------------------------------------------------------------- /client/resources/qrunesScripts/__pycache__/qcodeHandleUtils.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/qurator-vscode/ddb73d09b6e4700cd45c9dcabd09ea3c2c432713/client/resources/qrunesScripts/__pycache__/qcodeHandleUtils.cpython-36.pyc -------------------------------------------------------------------------------- /client/resources/qrunesScripts/__pycache__/qcodePythonVisitorHandle.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/qurator-vscode/ddb73d09b6e4700cd45c9dcabd09ea3c2c432713/client/resources/qrunesScripts/__pycache__/qcodePythonVisitorHandle.cpython-36.pyc -------------------------------------------------------------------------------- /client/resources/qrunesScripts/__pycache__/qcodeVisitorHandle.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/qurator-vscode/ddb73d09b6e4700cd45c9dcabd09ea3c2c432713/client/resources/qrunesScripts/__pycache__/qcodeVisitorHandle.cpython-36.pyc -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/Core/QuantumCircuit/OriginClassicalExpression.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017-2018 Origin Quantum Computing. All Right Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef ORIGIN_CLASSICAL_EXPRESSION_H 18 | #define ORIGIN_CLASSICAL_EXPRESSION_H 19 | #include "Core/QuantumMachine/CBitFactory.h" 20 | #include "Core/QuantumCircuit/CExprFactory.h" 21 | #include "Core/QuantumCircuit/QNode.h" 22 | USING_QPANDA 23 | 24 | class OriginCExpr :public CExpr 25 | { 26 | public: 27 | union content_u 28 | { 29 | CBit* cbit; 30 | int iOperatorSpecifier; 31 | cbit_size_t const_value; 32 | }; 33 | 34 | NodeType m_node_type; 35 | qmap_size_t m_postion; 36 | private: 37 | CExpr* leftExpr = nullptr; 38 | CExpr* rightExpr = nullptr; 39 | int contentSpecifier; 40 | content_u content; 41 | OriginCExpr(); 42 | public: 43 | OriginCExpr(CBit* cbit); 44 | OriginCExpr(CExpr* leftExpr, CExpr* rightExpr, int); 45 | OriginCExpr(cbit_size_t); 46 | CExpr * getLeftExpr() const; 47 | CExpr *getRightExpr() const; 48 | std::string getName() const; 49 | CBit* getCBit() const; 50 | void setLeftExpr(CExpr*); 51 | void setRightExpr(CExpr*); 52 | cbit_size_t eval() const; 53 | CExpr* deepcopy() const; 54 | bool checkValidity() const; 55 | 56 | NodeType getNodeType() const; 57 | qmap_size_t getPosition() const; 58 | void setPosition(qmap_size_t); 59 | int getContentSpecifier() const; 60 | ~OriginCExpr(); 61 | }; 62 | 63 | #endif -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/Core/QuantumMachine/QResultFactory.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017-2018 Origin Quantum Computing. All Right Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef QRESULT_FACTORY_H 18 | #define QRESULT_FACTORY_H 19 | 20 | #include 21 | #include 22 | #include 23 | #include "Core/Utilities/QPandaNamespace.h" 24 | QPANDA_BEGIN 25 | 26 | class QResult 27 | { 28 | // this class contains the result of the quantum measurement 29 | public: 30 | virtual std::map getResultMap() const = 0; 31 | virtual void append(std::pair) = 0; 32 | virtual ~QResult() {} 33 | }; 34 | 35 | #define REGISTER_QRES_NAME(classname) \ 36 | QResult* classname##_Constructor()\ 37 | {\ 38 | return new classname();\ 39 | }\ 40 | static QResultFactoryHelper _QRes_Factory_Helper_##classname(\ 41 | #classname,\ 42 | classname##_Constructor\ 43 | ) 44 | 45 | /* QResult Factory */ 46 | class QResultFactory 47 | { 48 | QResultFactory(); 49 | public: 50 | typedef std::function constructor_t; 51 | typedef std::map constructor_Map_t; 52 | constructor_Map_t _QResult_Constructor; 53 | QResult* GetEmptyQResult(); 54 | void registerclass(std::string &, constructor_t); 55 | static QResultFactory& GetFactoryInstance(); 56 | }; 57 | 58 | class QResultFactoryHelper 59 | { 60 | typedef QResultFactory::constructor_t 61 | constructor_t; 62 | public: 63 | QResultFactoryHelper(std::string, constructor_t _Constructor); 64 | }; 65 | 66 | QPANDA_END 67 | #endif -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/Core/QuantumMachine/QVec.h: -------------------------------------------------------------------------------- 1 | /*! \file QVec.h */ 2 | #ifndef _QVEC_H 3 | #define _QVEC_H 4 | #include 5 | #include "Core/QuantumMachine/QubitReference.h" 6 | QPANDA_BEGIN 7 | /** 8 | * @namespace QPanda 9 | */ 10 | 11 | /** 12 | * @class QVec 13 | * @brief Qubit vector basic class 14 | * @ingroup Core 15 | */ 16 | class QVec : public std::vector 17 | { 18 | typedef std::vector BaseClass; 19 | public: 20 | QVec(BaseClass::iterator iter_begin, BaseClass::iterator iter_end) 21 | { 22 | for (auto aiter = iter_begin; aiter != iter_end; aiter++) 23 | { 24 | push_back(*aiter); 25 | } 26 | } 27 | 28 | QVec(const std::initializer_list & args) 29 | { 30 | for (auto aiter: args) 31 | { 32 | push_back(aiter); 33 | } 34 | } 35 | QVec() {} 36 | 37 | QVec(const QVec & old) 38 | { 39 | for (auto aiter : old) 40 | { 41 | push_back(aiter); 42 | } 43 | } 44 | QVec(BaseClass &vector) 45 | { 46 | for (auto aiter = vector.begin(); aiter != vector.end(); aiter++) 47 | { 48 | push_back(*aiter); 49 | } 50 | } 51 | inline Qubit * operator[](ClassicalCondition & classical_cond) 52 | { 53 | std::vector qvec; 54 | for(auto aiter : *this) 55 | { 56 | qvec.push_back(aiter); 57 | } 58 | QubitReference *temp = new QubitReference(classical_cond,qvec); 59 | return temp; 60 | } 61 | 62 | inline Qubit * operator[](size_t pos) 63 | { 64 | if(pos > (cbit_size_t)size()) 65 | { 66 | QCERR("pos overflow"); 67 | throw std::invalid_argument("pos overflow"); 68 | } 69 | return BaseClass::operator[](pos); 70 | } 71 | 72 | inline QVec &operator<<(int) 73 | { 74 | return *this; 75 | } 76 | }; 77 | QPANDA_END 78 | 79 | #endif -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/Core/QuantumMachine/QubitFactory.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017-2018 Origin Quantum Computing. All Right Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef QUBIT_FACTORY_H 18 | #define QUBIT_FACTORY_H 19 | 20 | 21 | #include "Core/QuantumMachine/PhysicalQubitFactory.h" 22 | #include 23 | #include 24 | #include 25 | QPANDA_BEGIN 26 | 27 | class Qubit 28 | { 29 | // User use this Class 30 | 31 | public: 32 | virtual PhysicalQubit* getPhysicalQubitPtr() = 0; 33 | virtual bool getOccupancy() = 0; 34 | virtual ~Qubit() {} 35 | }; 36 | 37 | #define REGISTER_QUBIT(classname) \ 38 | Qubit* classname##_Constructor(PhysicalQubit* physQ)\ 39 | {\ 40 | return new classname(physQ);\ 41 | }\ 42 | QubitFactoryHelper _Qubit_Factory_Helper_##classname(\ 43 | #classname, \ 44 | classname##_Constructor\ 45 | ) 46 | 47 | 48 | /* 5. Qubit Factory */ 49 | class QubitFactory 50 | { 51 | QubitFactory(); 52 | public: 53 | static QubitFactory & GetFactoryInstance(); 54 | Qubit* GetInstance(PhysicalQubit*); 55 | typedef std::function constructor_t; 56 | typedef std::map constructor_Map_t; 57 | void registerclass(std::string &, constructor_t constructor); 58 | // the constructor stack 59 | constructor_Map_t _Qubit_Constructor; 60 | }; 61 | 62 | class QubitFactoryHelper 63 | { 64 | typedef QubitFactory::constructor_t constructor_t; 65 | public: 66 | QubitFactoryHelper(std::string, constructor_t); 67 | }; 68 | QPANDA_END 69 | #endif -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/Core/QuantumMachine/QubitReference.h: -------------------------------------------------------------------------------- 1 | #ifndef _QUBIT_REFERENCE_H 2 | #define _QUBIT_REFERENCE_H 3 | #include 4 | #include "Core/QuantumMachine/QubitFactory.h" 5 | #include "Core/QuantumCircuit/ClassicalConditionInterface.h" 6 | #include "Core/Utilities/QPandaNamespace.h" 7 | QPANDA_BEGIN 8 | class QubitReference :public Qubit 9 | { 10 | private: 11 | std::shared_ptr m_cepr; 12 | std::vector m_qvec; 13 | public: 14 | inline PhysicalQubit* getPhysicalQubitPtr() 15 | { 16 | auto temp = m_cepr->eval(); 17 | return m_qvec[temp]->getPhysicalQubitPtr(); 18 | } 19 | 20 | inline QubitReference(ClassicalCondition & cc,std::vector qvec) 21 | { 22 | m_cepr = cc.getExprPtr(); 23 | 24 | for(auto aiter : qvec) 25 | { 26 | m_qvec.push_back(aiter); 27 | } 28 | } 29 | 30 | inline bool getOccupancy() 31 | { 32 | return true; 33 | } 34 | 35 | inline QubitReference(const QubitReference & old) 36 | { 37 | m_cepr = old.m_cepr; 38 | m_qvec.clear(); 39 | for(auto aiter : m_qvec) 40 | { 41 | m_qvec.push_back(aiter); 42 | } 43 | } 44 | 45 | 46 | 47 | ~QubitReference() 48 | { 49 | m_cepr.reset(); 50 | } 51 | 52 | }; 53 | QPANDA_END 54 | #endif 55 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/Core/Utilities/CSVIostream.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017-2018 Origin Quantum Computing. All Right Reserved. 3 | Licensed under the Apache License 2.0 4 | 5 | CVSIotream.h 6 | Author: Wangjing 7 | Created in 2018-8-31 8 | 9 | Classes for write and read CVS file 10 | 11 | */ 12 | 13 | #ifndef IO_CSV_STREAM_H 14 | #define IO_CSV_STREAM_H 15 | 16 | #include "Core/Utilities/QPandaNamespace.h" 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | QPANDA_BEGIN 27 | 28 | class CSVOfstream 29 | { 30 | public: 31 | CSVOfstream(); 32 | CSVOfstream(const std::string &filename); 33 | void open(const std::string &filename); 34 | bool is_open(); 35 | 36 | CSVOfstream & operator<<(const std::vector> &container); 37 | CSVOfstream & operator<<(const std::list> &container); 38 | CSVOfstream & operator<<(const std::map &container); 39 | 40 | void close(); 41 | virtual ~CSVOfstream(); 42 | private: 43 | std::ofstream m_ofstream; 44 | }; 45 | 46 | class CSVIfstream 47 | { 48 | public: 49 | CSVIfstream(); 50 | CSVIfstream(const std::string &filename); 51 | void open(const std::string &filename); 52 | bool is_open(); 53 | 54 | CSVIfstream & operator>>(std::vector> &container); 55 | CSVIfstream & operator>>(std::list> &container); 56 | CSVIfstream & operator>>(std::map &container); 57 | 58 | void close(); 59 | virtual ~CSVIfstream(); 60 | private: 61 | std::ifstream m_ifstream; 62 | }; 63 | QPANDA_END 64 | #endif // IOCVSSTREAM_H 65 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/Core/Utilities/ConfigMap.h: -------------------------------------------------------------------------------- 1 | #ifndef _CONFIG_MAP_H 2 | #define _CONFIG_MAP_H 3 | #include 4 | #include 5 | #include "Core/Utilities/QPandaNamespace.h" 6 | #include "Core/Utilities/XMLConfigParam.h" 7 | 8 | QPANDA_BEGIN 9 | 10 | 11 | typedef std::pair CONFIGPAIR; 12 | class ConfigMap 13 | { 14 | public: 15 | static ConfigMap &getInstance(); 16 | ~ConfigMap(); 17 | std::string operator [](const char *); 18 | protected: 19 | ConfigMap(const std::string &filename = CONFIG_PATH); 20 | ConfigMap(const ConfigMap &); 21 | ConfigMap &operator=(const ConfigMap &); 22 | private: 23 | void insert(CONFIGPAIR); 24 | std::map m_configMap; 25 | }; 26 | QPANDA_END 27 | 28 | #endif // !_CONFIG_MAP_H 29 | 30 | 31 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/Core/Utilities/Micro-architecture/instructions.h: -------------------------------------------------------------------------------- 1 | #ifndef _INSTRUCTIONS_H_ 2 | #define _INSTRUCTIONS_H_ 3 | #include 4 | #include 5 | #include"Core/Utilities/XMLConfigParam.h" 6 | 7 | using config_map = std::map> ; 8 | 9 | uint32_t LOAD(uint32_t rs1, uint32_t rd, uint32_t imm); 10 | uint32_t STORE(uint32_t rs1, uint32_t rd, uint32_t imm); 11 | 12 | uint32_t BEQ(uint32_t rs1, uint32_t rs2, uint32_t imm); 13 | uint32_t BNE(uint32_t rs1, uint32_t rs2, uint32_t imm); 14 | uint32_t BLT(uint32_t rs1, uint32_t rs2, uint32_t imm); 15 | uint32_t BGT(uint32_t rs1, uint32_t rs2, uint32_t imm); 16 | 17 | uint32_t ADDI(uint32_t rs1, uint32_t rd, uint32_t imm); 18 | uint32_t ANDI(uint32_t rs1, uint32_t rd, uint32_t imm); 19 | uint32_t XORI(uint32_t rs1, uint32_t rd, uint32_t imm); 20 | uint32_t ORI(uint32_t rs1, uint32_t rd, uint32_t imm); 21 | 22 | uint32_t ADD(uint32_t rs1, uint32_t rs2, uint32_t rd); 23 | uint32_t AND(uint32_t rs1, uint32_t rs2, uint32_t rd); 24 | uint32_t XOR(uint32_t rs1, uint32_t rs2, uint32_t rd); 25 | uint32_t OR(uint32_t rs1, uint32_t rs2, uint32_t rd); 26 | 27 | uint32_t QWAITI(uint32_t imm); 28 | uint32_t FMR(uint32_t rs1, uint32_t rd); 29 | uint32_t SMIS(uint32_t rd, uint32_t imm); 30 | 31 | uint32_t QI(uint32_t rs1, uint32_t rs2, uint32_t PI, uint32_t opcode1, uint32_t opcode2); 32 | uint32_t MEASURE(uint32_t rs1, uint32_t PI); 33 | 34 | 35 | class Instructions 36 | { 37 | private: 38 | Instructions() 39 | { 40 | instructionConfig(); 41 | }; 42 | static void instructionConfig(); 43 | static Instructions *m_manager; 44 | public: 45 | static Instructions *getInstance(); 46 | }; 47 | 48 | #endif -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/Core/Utilities/QPandaNamespace.h: -------------------------------------------------------------------------------- 1 | /*! \file QPandaNamespace.h */ 2 | #ifndef QPANDA_NAMESPACE 3 | #define QPANDA_NAMESPACE 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | /** 12 | * @def QCERR 13 | * @brief QPanda2 cout error message 14 | * @ingroup Core 15 | */ 16 | #define QCERR(x) std::cerr<<__FILE__<<" " <<__LINE__<<" "<<__FUNCTION__<<" "\ 17 | <<(x)< qcomplex_t; 32 | typedef std::vector QStat; 33 | typedef std::vector Qnum; 34 | 35 | using prob_map = std::unordered_map; 36 | using stat_map = std::unordered_map; 37 | 38 | /** 39 | * @namespace QPanda 40 | * @brief QPanda2 base namespace 41 | * @ingroup Core 42 | */ 43 | #define QPANDA_BEGIN namespace QPanda { 44 | #define QPANDA_END } 45 | #define USING_QPANDA using namespace QPanda; 46 | #endif // !QPANDA_NAMESPACE 47 | 48 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/Core/Utilities/QStatMatrix.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017-2018 Origin Quantum Computing. All Right Reserved. 3 | Licensed under the Apache License 2.0 4 | 5 | QstatMatrix.h 6 | Author: Wangjing 7 | Created in 2018-8-31 8 | 9 | Classes for get the shortes path of graph 10 | 11 | */ 12 | 13 | 14 | 15 | #ifndef QSTATMATRIX_H 16 | #define QSTATMATRIX_H 17 | #include "Core/Utilities/QPandaNamespace.h" 18 | #include 19 | #include 20 | #include 21 | QPANDA_BEGIN 22 | 23 | bool isPerfectSquare(int number); 24 | QStat operator+(const QStat &matrix_left, const QStat &matrix_right); 25 | QStat operator+(const QStat &matrix_left, const qcomplex_t value); 26 | QStat operator+(const qcomplex_t value, const QStat &matrix_right); 27 | 28 | QStat operator-(const QStat &matrix_left, const QStat &matrix_right); 29 | QStat operator-(const QStat &matrix_left, const qcomplex_t &value); 30 | QStat operator-(const qcomplex_t &value, const QStat &matrix_right); 31 | 32 | QStat operator*(const QStat &matrix_left, const QStat &matrix_right); 33 | QStat operator*(const QStat &matrix_left, const qcomplex_t &value); 34 | QStat operator*(const qcomplex_t &value, const QStat &matrix_right); 35 | 36 | QPANDA_END 37 | #endif // QSTATMATRIX_H 38 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/Core/Utilities/QuantumMetadata.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017-2018 Origin Quantum Computing. All Right Reserved. 3 | Licensed under the Apache License 2.0 4 | 5 | QuantumMetadata.h 6 | Author: Wangjing 7 | Created in 2018-8-31 8 | 9 | Classes for get the shortes path of graph 10 | 11 | */ 12 | 13 | #ifndef QUBITCONFIG_H 14 | #define QUBITCONFIG_H 15 | 16 | #include "Core/Utilities/QPandaNamespace.h" 17 | #include "Core/QuantumCircuit/QGlobalVariable.h" 18 | #include "Core/Utilities/TranformQGateTypeStringAndEnum.h" 19 | #include "ThirdParty/TinyXML/tinyxml.h" 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include "Core/Utilities/XMLConfigParam.h" 25 | 26 | QPANDA_BEGIN 27 | 28 | 29 | /* 30 | Parse xml config and get metadata 31 | */ 32 | class QuantumMetadata 33 | { 34 | public: 35 | QuantumMetadata(const std::string & filename = CONFIG_PATH); 36 | QuantumMetadata & operator =(const QuantumMetadata &) = delete; 37 | 38 | bool getMetadata(int &qubit_num, std::vector> &matrix); 39 | bool getQGate(std::vector &single_gates, std::vector double_gates); 40 | bool getGateTime(std::map &gate_time_map); 41 | 42 | ~QuantumMetadata(); 43 | private: 44 | void insertGateTimeMap(const std::pair &gate_time, 45 | std::map &gate_time_map); 46 | XmlConfigParam m_config; 47 | bool m_is_config_exist; 48 | }; 49 | 50 | QPANDA_END 51 | #endif // QubitConfig_H 52 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/Core/Utilities/TranformQGateTypeStringAndEnum.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017-2018 Origin Quantum Computing. All Right Reserved. 3 | Licensed under the Apache License 2.0 4 | 5 | TranformQGateTypeStringAndEnum.h 6 | Author: Wangjing 7 | Created in 2018-10-15 8 | 9 | Classes for tranform gate type enum and std::string 10 | 11 | */ 12 | #ifndef TRANSFORM_QGATE_TYPE_STRING_ENUM_H 13 | #define TRANSFORM_QGATE_TYPE_STRING_ENUM_H 14 | 15 | #include 16 | #include 17 | #include 18 | #include "Core/QuantumCircuit/QGlobalVariable.h" 19 | #include "Core/Utilities/QPandaNamespace.h" 20 | 21 | QPANDA_BEGIN 22 | 23 | /* 24 | Classes for tranform gate type enum and std::string 25 | */ 26 | 27 | class TransformQGateType 28 | { 29 | public: 30 | static TransformQGateType &getInstance(); 31 | ~TransformQGateType() {}; 32 | std::string operator [](GateType); 33 | GateType operator [](std::string gate_name); 34 | private: 35 | std::map m_qgate_type_map; 36 | TransformQGateType &operator=(const TransformQGateType &); 37 | TransformQGateType(); 38 | TransformQGateType(const TransformQGateType &); 39 | }; 40 | 41 | 42 | 43 | 44 | 45 | QPANDA_END 46 | #endif // TRANSFORM_QGATE_TYPE_STRING_ENUM_H 47 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/Core/Utilities/Transform/TransformDecomposition.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/qurator-vscode/ddb73d09b6e4700cd45c9dcabd09ea3c2c432713/client/resources/qrunesScripts/include/Core/Utilities/Transform/TransformDecomposition.h -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/Core/Utilities/Utilities.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017-2019 Origin Quantum Computing. All Right Reserved. 3 | Licensed under the Apache License 2.0 4 | 5 | Traversal.h 6 | Author: doumenghan 7 | Created in 2019-4-16 8 | 9 | Classes for get the shortes path of graph 10 | 11 | */ 12 | #ifndef _UTILITIES_H 13 | #define _UTILITIES_H 14 | 15 | #include"QPandaNamespace.h" 16 | #include "Core/QuantumCircuit/QGate.h" 17 | #include "Core/QuantumCircuit/QCircuit.h" 18 | #include 19 | #include 20 | QPANDA_BEGIN 21 | std::string dec2bin(unsigned n, size_t size); 22 | double RandomNumberGenerator(); 23 | void add_up_a_map(std::map &meas_result, std::string key); 24 | 25 | void insertQCircuit(AbstractQGateNode * pGateNode, 26 | QCircuit & qCircuit, 27 | QNode * pParentNode); 28 | 29 | QPANDA_END 30 | 31 | #endif // !1 32 | 33 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/Core/Utilities/XMLConfigParam.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017-2018 Origin Quantum Computing. All Right Reserved. 3 | Licensed under the Apache License 2.0 4 | 5 | XMLConfigParam.h 6 | Author: Wangjing 7 | Created in 2018-8-31 8 | 9 | Classes for get the shortes path of graph 10 | 11 | */ 12 | #ifndef XMLCONFIGPARAM_H 13 | #define XMLCONFIGPARAM_H 14 | #include "Core/Utilities/QPandaNamespace.h" 15 | #include "ThirdParty/TinyXML/tinyxml.h" 16 | #include "Core/QuantumCircuit/QGlobalVariable.h" 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #define CONFIG_PATH "./QPandaConfig.xml" 23 | 24 | QPANDA_BEGIN 25 | 26 | 27 | class XmlConfigParam 28 | { 29 | public: 30 | XmlConfigParam() ; 31 | bool loadFile(const std::string &filename); 32 | bool getMetadataConfig(int &qubit_num, std::vector> &qubit_matrix); 33 | bool getClassNameConfig(std::map &class_names); 34 | 35 | bool getQuantumCloudConfig(std::map &cloud_config); 36 | bool getQGateConfig(std::vector &single_gates, std::vector &double_gates); 37 | bool getQGateTimeConfig(std::map &gate_time); 38 | bool getInstructionConfig(std::map> &); 39 | virtual ~XmlConfigParam() {}; 40 | private: 41 | TiXmlDocument m_doc; 42 | TiXmlElement *m_root_element; 43 | std::string m_filename; 44 | }; 45 | QPANDA_END 46 | #endif // XMLCONFIGPARAM_H 47 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/Core/VirtualQuantumProcessor/GPUGates/GPUGatesWrapper.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/qurator-vscode/ddb73d09b6e4700cd45c9dcabd09ea3c2c432713/client/resources/qrunesScripts/include/Core/VirtualQuantumProcessor/GPUGates/GPUGatesWrapper.h -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/Core/VirtualQuantumProcessor/GPUGates/GPUStruct.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPU_STRUCT_H 2 | #define _GPU_STRUCT_H 3 | 4 | #define QSIZE size_t 5 | #ifndef SQ2 6 | #define SQ2 (1 / 1.4142135623731) 7 | #endif 8 | 9 | #ifndef PI 10 | #define PI 3.14159265358979 11 | #endif 12 | 13 | #define THREADDIM (1024) 14 | #define STATE_T double 15 | 16 | namespace GATEGPU 17 | { 18 | struct probability 19 | { 20 | STATE_T prob; 21 | int state; 22 | }; 23 | 24 | struct QState 25 | { 26 | QState() : real(nullptr), imag(nullptr) {} 27 | STATE_T * real; 28 | STATE_T * imag; 29 | size_t qnum; 30 | }; 31 | } 32 | #endif // !_GPU_STRUCT_H 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/Core/VirtualQuantumProcessor/PartialAmplitude/MergeMap.h: -------------------------------------------------------------------------------- 1 | #ifndef _MERGEMAP_H_ 2 | #define _MERGEMAP_H_ 3 | #include "QPanda.h" 4 | #include "Core/VirtualQuantumProcessor/QPUImpl.h" 5 | #include "Core/VirtualQuantumProcessor/PartialAmplitude/TraversalQProg.h" 6 | QPANDA_BEGIN 7 | 8 | 9 | #define _SINGLE_GATE(NAME) \ 10 | void _##NAME(QGateNode &node, QPUImpl *pQGate)\ 11 | {\ 12 | pQGate->NAME(node.tar_qubit, node.isConjugate, 0);\ 13 | }\ 14 | 15 | #define _SINGLE_ANGLE_GATE(NAME) \ 16 | void _##NAME(QGateNode &node, QPUImpl *pQGate)\ 17 | {\ 18 | pQGate->NAME(node.tar_qubit,node.gate_parm,node.isConjugate, 0);\ 19 | }\ 20 | 21 | #define _DOUBLE_GATE(NAME) \ 22 | void _##NAME(QGateNode &node, QPUImpl *pQGate)\ 23 | {\ 24 | pQGate->NAME(node.ctr_qubit,node.tar_qubit,node.isConjugate, 0);\ 25 | }\ 26 | 27 | #define _DOUBLE_ANGLE_GATE(NAME) \ 28 | void _##NAME(QGateNode &node, QPUImpl *pQGate)\ 29 | {\ 30 | pQGate->NAME(node.ctr_qubit,node.tar_qubit,node.gate_parm,node.isConjugate, 0);\ 31 | }\ 32 | 33 | struct QGateNode 34 | { 35 | unsigned short gate_type; 36 | bool isConjugate; 37 | size_t tar_qubit; 38 | size_t ctr_qubit; 39 | double gate_parm; 40 | }; 41 | 42 | class MergeMap 43 | { 44 | public: 45 | size_t m_qubit_num; 46 | std::vector m_circuit; 47 | std::vector>> m_circuit_vec; 48 | MergeMap(); 49 | 50 | inline size_t getMapVecSize() noexcept 51 | { 52 | return m_circuit_vec.size(); 53 | } 54 | 55 | inline void clear() noexcept 56 | { 57 | m_circuit.clear(); 58 | m_circuit_vec.clear(); 59 | } 60 | void traversalMap(std::vector &, QPUImpl *, QuantumGateParam*); 61 | bool isCorssNode(size_t, size_t); 62 | void traversalQlist(std::vector &); 63 | void splitQlist(std::vector &); 64 | 65 | private: 66 | std::map m_key_map; 67 | std::map > m_GateFunc; 68 | }; 69 | 70 | QPANDA_END 71 | #endif 72 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/Core/VirtualQuantumProcessor/PartialAmplitude/TraversalQProg.h: -------------------------------------------------------------------------------- 1 | #ifndef _TRAVERSALQPROG_H_ 2 | #define _TRAVERSALQPROG_H_ 3 | #include "QPanda.h" 4 | QPANDA_BEGIN 5 | 6 | class TraversalQProg 7 | { 8 | public: 9 | size_t m_qubit_num; 10 | virtual ~TraversalQProg() {}; 11 | 12 | virtual void traversal(AbstractQuantumProgram*) final; 13 | virtual void traversal(AbstractQuantumCircuit*) final; 14 | virtual void traversal(QNode*) final; 15 | virtual void handleDaggerNode(QNode*, int) final; 16 | virtual void handleDaggerCircuit(QNode*) final; 17 | 18 | private: 19 | 20 | virtual void traversal(AbstractQGateNode *) = 0; 21 | virtual void traversalAll(AbstractQuantumProgram *) = 0; 22 | }; 23 | 24 | QPANDA_END 25 | #endif 26 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/Core/VirtualQuantumProcessor/QError.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017-2018 Origin Quantum Computing. All Right Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | /*! \file QError.h */ 17 | #ifndef _QERROR_H 18 | #define _QERROR_H 19 | /* 20 | * @enum QError 21 | * @brief quantum program error type 22 | * @ingroup QuantumMachine 23 | */ 24 | enum QError 25 | { 26 | qErrorNone = 2, /**< no error */ 27 | undefineError, /**< undefined error */ 28 | qParameterError, /** 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include "Core/QuantumMachine/QubitFactory.h" 26 | #include "Core/Utilities/QPandaNamespace.h" 27 | 28 | #define iunit qcomplex_t(0,1) 29 | /***************************************************************************************************************** 30 | QuantumGateParam:quantum gate param 31 | *****************************************************************************************************************/ 32 | class QuantumGateParam 33 | { 34 | public: 35 | size_t m_qubit_number; /* quantum bit number */ 36 | std::map m_return_value; /* MonteCarlo result */ 37 | bool m_is_dagger; 38 | std::vector m_control_qubit_vector; 39 | 40 | QuantumGateParam() 41 | { 42 | m_qubit_number = 0; 43 | m_is_dagger = false; 44 | } 45 | }; 46 | 47 | struct QGateParam 48 | { 49 | QGateParam() {}; 50 | QGateParam(int qn) :qVec(qn, 0), qstate(1ull << qn, 0), qubitnumber(qn) 51 | { 52 | for (auto i = 0; i < qubitnumber; i++) 53 | { 54 | qVec[i] = i; 55 | } 56 | qstate[0] = 1; 57 | } 58 | Qnum qVec; 59 | QStat qstate; 60 | int qubitnumber; 61 | bool enable = true; 62 | 63 | }; 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/Core/VirtualQuantumProcessor/SingleAmplitude/QuantumGates.h: -------------------------------------------------------------------------------- 1 | #ifndef QUANTUMGATES_H 2 | #define QUANTUMGATES_H 3 | #include "Core/VirtualQuantumProcessor/SingleAmplitude/TensorEngine.h" 4 | #include 5 | using std::complex; 6 | 7 | void H_Gate(QuantumProgMap &prog_map, qsize_t qubit, bool isDagger); 8 | void T_Gate(QuantumProgMap & prog_map, qsize_t qubit, bool isDagger); 9 | void S_Gate(QuantumProgMap & prog_map, qsize_t qubit, bool isDagger); 10 | void X_Gate(QuantumProgMap & prog_map, qsize_t qubit, bool isDagger); 11 | void Y_Gate(QuantumProgMap & prog_map, qsize_t qubit, bool isDagger); 12 | void Z_Gate(QuantumProgMap & prog_map, qsize_t qubit, bool isDagger); 13 | void X1_Gate(QuantumProgMap & prog_map, qsize_t qubit, bool isDagger); 14 | void Y1_Gate(QuantumProgMap & prog_map, qsize_t qubit, bool isDagger); 15 | void Z1_Gate(QuantumProgMap &prog_map, qsize_t qubit, bool isDagger); 16 | 17 | void RX_Gate(QuantumProgMap & prog_map, qsize_t qubit, double angle, bool isDagger); 18 | void RY_Gate(QuantumProgMap & prog_map, qsize_t qubit, double angle, bool isDagger); 19 | void RZ_Gate(QuantumProgMap & prog_map, qsize_t qubit, double angle, bool isDagger); 20 | void U1_Gate(QuantumProgMap & prog_map, qsize_t qubit, double angle, bool isDagger); 21 | 22 | void CZ_Gate(QuantumProgMap &prog_map,qsize_t qubit1,qsize_t qubit2,bool isDagger); 23 | void CNOT_Gate(QuantumProgMap &prog_map, qsize_t qubit1, qsize_t qubit2, bool isDagger); 24 | void ISWAP_Gate(QuantumProgMap &prog_map, qsize_t qubit1, qsize_t qubit2, bool isDagger); 25 | void SQISWAP_Gate(QuantumProgMap &prog_map, qsize_t qubit1, qsize_t qubit2, bool isDagger); 26 | 27 | void CR_Gate(QuantumProgMap &prog_map,qsize_t qubit1,qsize_t qubit2,double angle, bool isDagger); 28 | 29 | #endif // !QUANTUMGATES_H 30 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/Core/VirtualQuantumProcessor/SingleAmplitude/TensorEngine.h: -------------------------------------------------------------------------------- 1 | #ifndef TENSOR_ENGINE_H 2 | #define TENSOR_ENGINE_H 3 | #include "Core/VirtualQuantumProcessor/SingleAmplitude/TensorNode.h" 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | using namespace std; 13 | 14 | typedef struct QubitVertice 15 | { 16 | qsize_t m_qubit_id; 17 | qsize_t m_num; 18 | qsize_t m_max; 19 | int m_count; 20 | QubitVertice(const QubitVertice & old) 21 | { 22 | m_num = old.m_num; 23 | m_qubit_id = old.m_qubit_id; 24 | m_max = old.m_max; 25 | m_count = old.m_count; 26 | } 27 | 28 | QubitVertice operator = (const QubitVertice & old) 29 | { 30 | m_num = old.m_num; 31 | m_qubit_id = old.m_qubit_id; 32 | m_max = old.m_max; 33 | m_count = old.m_count; 34 | return *this; 35 | } 36 | QubitVertice() :m_num(0), m_qubit_id(0), m_max(0), m_count(0) 37 | {} 38 | } 39 | qubit_vertice_t; 40 | 41 | void split(QuantumProgMap* prog_map, 42 | qubit_vertice_t* qubit_vertice, 43 | qcomplex_data_t* result); 44 | 45 | class TensorEngine 46 | { 47 | public: 48 | static qubit_vertice_t getNoValueVertice(QuantumProgMap& prog_map,size_t contect_edge); 49 | static qubit_vertice_t getNoValueAndContectEdgeMaxVertice(QuantumProgMap& prog_map); 50 | static void Merge(QuantumProgMap& prog_map); 51 | static qcomplex_data_t Merge(QuantumProgMap& prog_map, qubit_vertice_t*); 52 | static qcomplex_data_t computing(QuantumProgMap & prog_map); 53 | static map::iterator 54 | MergeQuantumProgMap(QuantumProgMap&, qubit_vertice_t&); 55 | 56 | static void dimDecrementbyValue(QuantumProgMap&, qubit_vertice_t &,int value); 57 | }; 58 | 59 | #endif // !TENSOR_ENGINE_H 60 | 61 | 62 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/QAlg/Components/MaxCutProblemGenerator/MaxCutProblemGenerator.h: -------------------------------------------------------------------------------- 1 | #ifndef PYQPANDA_MAXCUTGENERATOR_H 2 | #define PYQPANDA_MAXCUTGENERATOR_H 3 | 4 | //#include "pybind11/pybind11.h" 5 | //#include "pybind11/stl.h" 6 | #include "vector" 7 | #include 8 | 9 | using std::vector; 10 | using std::map; 11 | //namespace py = pybind11; 12 | 13 | double vector_dot(vector &x, vector &y); 14 | double all_cut_of_graph(vector> adjacent_matrix, 15 | vector & all_cut_list, 16 | vector & target_value_list); 17 | 18 | #endif // ! PYQPANDA_MAXCUTGENERATOR_H -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/QAlg/Components/Optimizer/OptimizerFactory.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017-2018 Origin Quantum Computing. All Right Reserved. 3 | Licensed under the Apache License 2.0 4 | 5 | OptimizerFactor.h 6 | 7 | Author: LiYe 8 | Created in 2018-09-06 9 | 10 | 11 | */ 12 | 13 | #ifndef OPTIMIZERFACTOR_H 14 | #define OPTIMIZERFACTOR_H 15 | 16 | #include 17 | #include "QAlg/DataStruct.h" 18 | 19 | namespace QPanda 20 | { 21 | /* 22 | Abstract class of Optimizer. 23 | */ 24 | class AbstractOptimizer; 25 | class OptimizerFactory 26 | { 27 | public: 28 | OptimizerFactory(); 29 | 30 | static std::unique_ptr 31 | makeOptimizer(const OptimizerType &optimizer); 32 | static std::unique_ptr 33 | makeOptimizer(const std::string &optimizer); 34 | }; 35 | 36 | } 37 | 38 | #endif // OPTIMIZERFACTOR_H 39 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/QAlg/Components/Optimizer/OriginNelderMead.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/qurator-vscode/ddb73d09b6e4700cd45c9dcabd09ea3c2c432713/client/resources/qrunesScripts/include/QAlg/Components/Optimizer/OriginNelderMead.h -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/QAlg/Utils/RJson/RJson.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/qurator-vscode/ddb73d09b6e4700cd45c9dcabd09ea3c2c432713/client/resources/qrunesScripts/include/QAlg/Utils/RJson/RJson.h -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/QAlg/Utils/Utilities.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017-2018 Origin Quantum Computing. All Right Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef UTILITIES_H 18 | #define UTILITIES_H 19 | #include "Core/QuantumCircuit/ClassicalProgram.h" 20 | #include "Core/Utilities/QPandaNamespace.h" 21 | #include "Core/QuantumCircuit/QProgram.h" 22 | #include "Core/QuantumCircuit/QCircuit.h" 23 | #include "Core/QuantumCircuit/QGate.h" 24 | #include 25 | QPANDA_BEGIN 26 | QProg Reset_Qubit(Qubit* q, bool setVal); 27 | 28 | QProg Reset_Qubit_Circuit(Qubit *q, ClassicalCondition& cbit, bool setVal); 29 | 30 | QProg Reset_All(std::vector qubit_vector, bool setVal); 31 | 32 | /* 33 | CNOT all qubits (except last) with the last qubit 34 | 35 | param: 36 | qubit_vec: qubit vector 37 | return: 38 | QCircuit 39 | */ 40 | QCircuit parity_check_circuit(std::vector qubit_vec); 41 | 42 | /* 43 | Apply Quantum Gate on a series of Qubit 44 | 45 | param: 46 | qubits: qubit vector 47 | return: 48 | QCircuit 49 | */ 50 | inline QCircuit apply_QGate(QVec qubits, std::function gate) { 51 | QCircuit c; 52 | for (auto qubit : qubits) { 53 | c << gate(qubit); 54 | } 55 | return c; 56 | } 57 | 58 | template 59 | using Oracle = std::function; 60 | 61 | inline QGate Toffoli(Qubit* qc1, Qubit* qc2, Qubit* target) { 62 | auto gate = X(target); 63 | return gate.control({ qc1,qc2 }); 64 | } 65 | 66 | QPANDA_END 67 | #endif -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/QPandaConfig.h: -------------------------------------------------------------------------------- 1 | /* #undef USE_CUDA */ 2 | #define USE_PYQPANDA 3 | #define USE_OPENMP 4 | /* #undef USE_CURL */ 5 | /* #undef USE_MPI */ 6 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/QPandaVersion.h: -------------------------------------------------------------------------------- 1 | #define QPANDA_MAJOR_VERSION 1 2 | #define QPANDA_MINOR_VERSION 3 3 | #define QPANDA_PATCH_VERSION 4 4 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/ThirdParty/Eigen/Cholesky: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_CHOLESKY_MODULE_H 9 | #define EIGEN_CHOLESKY_MODULE_H 10 | 11 | #include "Core" 12 | #include "Jacobi" 13 | 14 | #include "src/Core/util/DisableStupidWarnings.h" 15 | 16 | /** \defgroup Cholesky_Module Cholesky module 17 | * 18 | * 19 | * 20 | * This module provides two variants of the Cholesky decomposition for selfadjoint (hermitian) matrices. 21 | * Those decompositions are also accessible via the following methods: 22 | * - MatrixBase::llt() 23 | * - MatrixBase::ldlt() 24 | * - SelfAdjointView::llt() 25 | * - SelfAdjointView::ldlt() 26 | * 27 | * \code 28 | * #include 29 | * \endcode 30 | */ 31 | 32 | #include "src/Cholesky/LLT.h" 33 | #include "src/Cholesky/LDLT.h" 34 | #ifdef EIGEN_USE_LAPACKE 35 | #ifdef EIGEN_USE_MKL 36 | #include "mkl_lapacke.h" 37 | #else 38 | #include "src/misc/lapacke.h" 39 | #endif 40 | #include "src/Cholesky/LLT_LAPACKE.h" 41 | #endif 42 | 43 | #include "src/Core/util/ReenableStupidWarnings.h" 44 | 45 | #endif // EIGEN_CHOLESKY_MODULE_H 46 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 47 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/ThirdParty/Eigen/CholmodSupport: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_CHOLMODSUPPORT_MODULE_H 9 | #define EIGEN_CHOLMODSUPPORT_MODULE_H 10 | 11 | #include "SparseCore" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | extern "C" { 16 | #include 17 | } 18 | 19 | /** \ingroup Support_modules 20 | * \defgroup CholmodSupport_Module CholmodSupport module 21 | * 22 | * This module provides an interface to the Cholmod library which is part of the suitesparse package. 23 | * It provides the two following main factorization classes: 24 | * - class CholmodSupernodalLLT: a supernodal LLT Cholesky factorization. 25 | * - class CholmodDecomposiiton: a general L(D)LT Cholesky factorization with automatic or explicit runtime selection of the underlying factorization method (supernodal or simplicial). 26 | * 27 | * For the sake of completeness, this module also propose the two following classes: 28 | * - class CholmodSimplicialLLT 29 | * - class CholmodSimplicialLDLT 30 | * Note that these classes does not bring any particular advantage compared to the built-in 31 | * SimplicialLLT and SimplicialLDLT factorization classes. 32 | * 33 | * \code 34 | * #include 35 | * \endcode 36 | * 37 | * In order to use this module, the cholmod headers must be accessible from the include paths, and your binary must be linked to the cholmod library and its dependencies. 38 | * The dependencies depend on how cholmod has been compiled. 39 | * For a cmake based project, you can use our FindCholmod.cmake module to help you in this task. 40 | * 41 | */ 42 | 43 | #include "src/CholmodSupport/CholmodSupport.h" 44 | 45 | #include "src/Core/util/ReenableStupidWarnings.h" 46 | 47 | #endif // EIGEN_CHOLMODSUPPORT_MODULE_H 48 | 49 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/ThirdParty/Eigen/Dense: -------------------------------------------------------------------------------- 1 | #include "Core" 2 | #include "LU" 3 | #include "Cholesky" 4 | #include "QR" 5 | #include "SVD" 6 | #include "Geometry" 7 | #include "Eigenvalues" 8 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/ThirdParty/Eigen/Eigen: -------------------------------------------------------------------------------- 1 | #include "Dense" 2 | #include "Sparse" 3 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/ThirdParty/Eigen/Eigenvalues: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_EIGENVALUES_MODULE_H 9 | #define EIGEN_EIGENVALUES_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | #include "Cholesky" 16 | #include "Jacobi" 17 | #include "Householder" 18 | #include "LU" 19 | #include "Geometry" 20 | 21 | /** \defgroup Eigenvalues_Module Eigenvalues module 22 | * 23 | * 24 | * 25 | * This module mainly provides various eigenvalue solvers. 26 | * This module also provides some MatrixBase methods, including: 27 | * - MatrixBase::eigenvalues(), 28 | * - MatrixBase::operatorNorm() 29 | * 30 | * \code 31 | * #include 32 | * \endcode 33 | */ 34 | 35 | #include "src/misc/RealSvd2x2.h" 36 | #include "src/Eigenvalues/Tridiagonalization.h" 37 | #include "src/Eigenvalues/RealSchur.h" 38 | #include "src/Eigenvalues/EigenSolver.h" 39 | #include "src/Eigenvalues/SelfAdjointEigenSolver.h" 40 | #include "src/Eigenvalues/GeneralizedSelfAdjointEigenSolver.h" 41 | #include "src/Eigenvalues/HessenbergDecomposition.h" 42 | #include "src/Eigenvalues/ComplexSchur.h" 43 | #include "src/Eigenvalues/ComplexEigenSolver.h" 44 | #include "src/Eigenvalues/RealQZ.h" 45 | #include "src/Eigenvalues/GeneralizedEigenSolver.h" 46 | #include "src/Eigenvalues/MatrixBaseEigenvalues.h" 47 | #ifdef EIGEN_USE_LAPACKE 48 | #ifdef EIGEN_USE_MKL 49 | #include "mkl_lapacke.h" 50 | #else 51 | #include "src/misc/lapacke.h" 52 | #endif 53 | #include "src/Eigenvalues/RealSchur_LAPACKE.h" 54 | #include "src/Eigenvalues/ComplexSchur_LAPACKE.h" 55 | #include "src/Eigenvalues/SelfAdjointEigenSolver_LAPACKE.h" 56 | #endif 57 | 58 | #include "src/Core/util/ReenableStupidWarnings.h" 59 | 60 | #endif // EIGEN_EIGENVALUES_MODULE_H 61 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 62 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/ThirdParty/Eigen/Householder: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_HOUSEHOLDER_MODULE_H 9 | #define EIGEN_HOUSEHOLDER_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | /** \defgroup Householder_Module Householder module 16 | * This module provides Householder transformations. 17 | * 18 | * \code 19 | * #include 20 | * \endcode 21 | */ 22 | 23 | #include "src/Householder/Householder.h" 24 | #include "src/Householder/HouseholderSequence.h" 25 | #include "src/Householder/BlockHouseholder.h" 26 | 27 | #include "src/Core/util/ReenableStupidWarnings.h" 28 | 29 | #endif // EIGEN_HOUSEHOLDER_MODULE_H 30 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 31 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/ThirdParty/Eigen/Jacobi: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_JACOBI_MODULE_H 9 | #define EIGEN_JACOBI_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | /** \defgroup Jacobi_Module Jacobi module 16 | * This module provides Jacobi and Givens rotations. 17 | * 18 | * \code 19 | * #include 20 | * \endcode 21 | * 22 | * In addition to listed classes, it defines the two following MatrixBase methods to apply a Jacobi or Givens rotation: 23 | * - MatrixBase::applyOnTheLeft() 24 | * - MatrixBase::applyOnTheRight(). 25 | */ 26 | 27 | #include "src/Jacobi/Jacobi.h" 28 | 29 | #include "src/Core/util/ReenableStupidWarnings.h" 30 | 31 | #endif // EIGEN_JACOBI_MODULE_H 32 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 33 | 34 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/ThirdParty/Eigen/LU: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_LU_MODULE_H 9 | #define EIGEN_LU_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | /** \defgroup LU_Module LU module 16 | * This module includes %LU decomposition and related notions such as matrix inversion and determinant. 17 | * This module defines the following MatrixBase methods: 18 | * - MatrixBase::inverse() 19 | * - MatrixBase::determinant() 20 | * 21 | * \code 22 | * #include 23 | * \endcode 24 | */ 25 | 26 | #include "src/misc/Kernel.h" 27 | #include "src/misc/Image.h" 28 | #include "src/LU/FullPivLU.h" 29 | #include "src/LU/PartialPivLU.h" 30 | #ifdef EIGEN_USE_LAPACKE 31 | #ifdef EIGEN_USE_MKL 32 | #include "mkl_lapacke.h" 33 | #else 34 | #include "src/misc/lapacke.h" 35 | #endif 36 | #include "src/LU/PartialPivLU_LAPACKE.h" 37 | #endif 38 | #include "src/LU/Determinant.h" 39 | #include "src/LU/InverseImpl.h" 40 | 41 | // Use the SSE optimized version whenever possible. At the moment the 42 | // SSE version doesn't compile when AVX is enabled 43 | #if defined EIGEN_VECTORIZE_SSE && !defined EIGEN_VECTORIZE_AVX 44 | #include "src/LU/arch/Inverse_SSE.h" 45 | #endif 46 | 47 | #include "src/Core/util/ReenableStupidWarnings.h" 48 | 49 | #endif // EIGEN_LU_MODULE_H 50 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 51 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/ThirdParty/Eigen/MetisSupport: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_METISSUPPORT_MODULE_H 9 | #define EIGEN_METISSUPPORT_MODULE_H 10 | 11 | #include "SparseCore" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | extern "C" { 16 | #include 17 | } 18 | 19 | 20 | /** \ingroup Support_modules 21 | * \defgroup MetisSupport_Module MetisSupport module 22 | * 23 | * \code 24 | * #include 25 | * \endcode 26 | * This module defines an interface for the METIS reordering package (http://glaros.dtc.umn.edu/gkhome/views/metis). 27 | * It can be used just as any other built-in method as explained in \link OrderingMethods_Module here. \endlink 28 | */ 29 | 30 | 31 | #include "src/MetisSupport/MetisSupport.h" 32 | 33 | #include "src/Core/util/ReenableStupidWarnings.h" 34 | 35 | #endif // EIGEN_METISSUPPORT_MODULE_H 36 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/ThirdParty/Eigen/PaStiXSupport: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_PASTIXSUPPORT_MODULE_H 9 | #define EIGEN_PASTIXSUPPORT_MODULE_H 10 | 11 | #include "SparseCore" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | extern "C" { 16 | #include 17 | #include 18 | } 19 | 20 | #ifdef complex 21 | #undef complex 22 | #endif 23 | 24 | /** \ingroup Support_modules 25 | * \defgroup PaStiXSupport_Module PaStiXSupport module 26 | * 27 | * This module provides an interface to the PaSTiX library. 28 | * PaSTiX is a general \b supernodal, \b parallel and \b opensource sparse solver. 29 | * It provides the two following main factorization classes: 30 | * - class PastixLLT : a supernodal, parallel LLt Cholesky factorization. 31 | * - class PastixLDLT: a supernodal, parallel LDLt Cholesky factorization. 32 | * - class PastixLU : a supernodal, parallel LU factorization (optimized for a symmetric pattern). 33 | * 34 | * \code 35 | * #include 36 | * \endcode 37 | * 38 | * In order to use this module, the PaSTiX headers must be accessible from the include paths, and your binary must be linked to the PaSTiX library and its dependencies. 39 | * The dependencies depend on how PaSTiX has been compiled. 40 | * For a cmake based project, you can use our FindPaSTiX.cmake module to help you in this task. 41 | * 42 | */ 43 | 44 | #include "src/PaStiXSupport/PaStiXSupport.h" 45 | 46 | #include "src/Core/util/ReenableStupidWarnings.h" 47 | 48 | #endif // EIGEN_PASTIXSUPPORT_MODULE_H 49 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/ThirdParty/Eigen/PardisoSupport: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_PARDISOSUPPORT_MODULE_H 9 | #define EIGEN_PARDISOSUPPORT_MODULE_H 10 | 11 | #include "SparseCore" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | #include 16 | 17 | /** \ingroup Support_modules 18 | * \defgroup PardisoSupport_Module PardisoSupport module 19 | * 20 | * This module brings support for the Intel(R) MKL PARDISO direct sparse solvers. 21 | * 22 | * \code 23 | * #include 24 | * \endcode 25 | * 26 | * In order to use this module, the MKL headers must be accessible from the include paths, and your binary must be linked to the MKL library and its dependencies. 27 | * See this \ref TopicUsingIntelMKL "page" for more information on MKL-Eigen integration. 28 | * 29 | */ 30 | 31 | #include "src/PardisoSupport/PardisoSupport.h" 32 | 33 | #include "src/Core/util/ReenableStupidWarnings.h" 34 | 35 | #endif // EIGEN_PARDISOSUPPORT_MODULE_H 36 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/ThirdParty/Eigen/QR: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_QR_MODULE_H 9 | #define EIGEN_QR_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | #include "Cholesky" 16 | #include "Jacobi" 17 | #include "Householder" 18 | 19 | /** \defgroup QR_Module QR module 20 | * 21 | * 22 | * 23 | * This module provides various QR decompositions 24 | * This module also provides some MatrixBase methods, including: 25 | * - MatrixBase::householderQr() 26 | * - MatrixBase::colPivHouseholderQr() 27 | * - MatrixBase::fullPivHouseholderQr() 28 | * 29 | * \code 30 | * #include 31 | * \endcode 32 | */ 33 | 34 | #include "src/QR/HouseholderQR.h" 35 | #include "src/QR/FullPivHouseholderQR.h" 36 | #include "src/QR/ColPivHouseholderQR.h" 37 | #include "src/QR/CompleteOrthogonalDecomposition.h" 38 | #ifdef EIGEN_USE_LAPACKE 39 | #ifdef EIGEN_USE_MKL 40 | #include "mkl_lapacke.h" 41 | #else 42 | #include "src/misc/lapacke.h" 43 | #endif 44 | #include "src/QR/HouseholderQR_LAPACKE.h" 45 | #include "src/QR/ColPivHouseholderQR_LAPACKE.h" 46 | #endif 47 | 48 | #include "src/Core/util/ReenableStupidWarnings.h" 49 | 50 | #endif // EIGEN_QR_MODULE_H 51 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 52 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/ThirdParty/Eigen/QtAlignedMalloc: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_QTMALLOC_MODULE_H 9 | #define EIGEN_QTMALLOC_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #if (!EIGEN_MALLOC_ALREADY_ALIGNED) 14 | 15 | #include "src/Core/util/DisableStupidWarnings.h" 16 | 17 | void *qMalloc(std::size_t size) 18 | { 19 | return Eigen::internal::aligned_malloc(size); 20 | } 21 | 22 | void qFree(void *ptr) 23 | { 24 | Eigen::internal::aligned_free(ptr); 25 | } 26 | 27 | void *qRealloc(void *ptr, std::size_t size) 28 | { 29 | void* newPtr = Eigen::internal::aligned_malloc(size); 30 | std::memcpy(newPtr, ptr, size); 31 | Eigen::internal::aligned_free(ptr); 32 | return newPtr; 33 | } 34 | 35 | #include "src/Core/util/ReenableStupidWarnings.h" 36 | 37 | #endif 38 | 39 | #endif // EIGEN_QTMALLOC_MODULE_H 40 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 41 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/ThirdParty/Eigen/SPQRSupport: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_SPQRSUPPORT_MODULE_H 9 | #define EIGEN_SPQRSUPPORT_MODULE_H 10 | 11 | #include "SparseCore" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | #include "SuiteSparseQR.hpp" 16 | 17 | /** \ingroup Support_modules 18 | * \defgroup SPQRSupport_Module SuiteSparseQR module 19 | * 20 | * This module provides an interface for the SPQR library, which is part of the suitesparse package. 21 | * 22 | * \code 23 | * #include 24 | * \endcode 25 | * 26 | * In order to use this module, the SPQR headers must be accessible from the include paths, and your binary must be linked to the SPQR library and its dependencies (Cholmod, AMD, COLAMD,...). 27 | * For a cmake based project, you can use our FindSPQR.cmake and FindCholmod.Cmake modules 28 | * 29 | */ 30 | 31 | #include "src/CholmodSupport/CholmodSupport.h" 32 | #include "src/SPQRSupport/SuiteSparseQRSupport.h" 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/ThirdParty/Eigen/SVD: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_SVD_MODULE_H 9 | #define EIGEN_SVD_MODULE_H 10 | 11 | #include "QR" 12 | #include "Householder" 13 | #include "Jacobi" 14 | 15 | #include "src/Core/util/DisableStupidWarnings.h" 16 | 17 | /** \defgroup SVD_Module SVD module 18 | * 19 | * 20 | * 21 | * This module provides SVD decomposition for matrices (both real and complex). 22 | * Two decomposition algorithms are provided: 23 | * - JacobiSVD implementing two-sided Jacobi iterations is numerically very accurate, fast for small matrices, but very slow for larger ones. 24 | * - BDCSVD implementing a recursive divide & conquer strategy on top of an upper-bidiagonalization which remains fast for large problems. 25 | * These decompositions are accessible via the respective classes and following MatrixBase methods: 26 | * - MatrixBase::jacobiSvd() 27 | * - MatrixBase::bdcSvd() 28 | * 29 | * \code 30 | * #include 31 | * \endcode 32 | */ 33 | 34 | #include "src/misc/RealSvd2x2.h" 35 | #include "src/SVD/UpperBidiagonalization.h" 36 | #include "src/SVD/SVDBase.h" 37 | #include "src/SVD/JacobiSVD.h" 38 | #include "src/SVD/BDCSVD.h" 39 | #if defined(EIGEN_USE_LAPACKE) && !defined(EIGEN_USE_LAPACKE_STRICT) 40 | #ifdef EIGEN_USE_MKL 41 | #include "mkl_lapacke.h" 42 | #else 43 | #include "src/misc/lapacke.h" 44 | #endif 45 | #include "src/SVD/JacobiSVD_LAPACKE.h" 46 | #endif 47 | 48 | #include "src/Core/util/ReenableStupidWarnings.h" 49 | 50 | #endif // EIGEN_SVD_MODULE_H 51 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 52 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/ThirdParty/Eigen/Sparse: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_SPARSE_MODULE_H 9 | #define EIGEN_SPARSE_MODULE_H 10 | 11 | /** \defgroup Sparse_Module Sparse meta-module 12 | * 13 | * Meta-module including all related modules: 14 | * - \ref SparseCore_Module 15 | * - \ref OrderingMethods_Module 16 | * - \ref SparseCholesky_Module 17 | * - \ref SparseLU_Module 18 | * - \ref SparseQR_Module 19 | * - \ref IterativeLinearSolvers_Module 20 | * 21 | \code 22 | #include 23 | \endcode 24 | */ 25 | 26 | #include "SparseCore" 27 | #include "OrderingMethods" 28 | #ifndef EIGEN_MPL2_ONLY 29 | #include "SparseCholesky" 30 | #endif 31 | #include "SparseLU" 32 | #include "SparseQR" 33 | #include "IterativeLinearSolvers" 34 | 35 | #endif // EIGEN_SPARSE_MODULE_H 36 | 37 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/ThirdParty/Eigen/SparseCholesky: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2013 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_SPARSECHOLESKY_MODULE_H 11 | #define EIGEN_SPARSECHOLESKY_MODULE_H 12 | 13 | #include "SparseCore" 14 | #include "OrderingMethods" 15 | 16 | #include "src/Core/util/DisableStupidWarnings.h" 17 | 18 | /** 19 | * \defgroup SparseCholesky_Module SparseCholesky module 20 | * 21 | * This module currently provides two variants of the direct sparse Cholesky decomposition for selfadjoint (hermitian) matrices. 22 | * Those decompositions are accessible via the following classes: 23 | * - SimplicialLLt, 24 | * - SimplicialLDLt 25 | * 26 | * Such problems can also be solved using the ConjugateGradient solver from the IterativeLinearSolvers module. 27 | * 28 | * \code 29 | * #include 30 | * \endcode 31 | */ 32 | 33 | #ifdef EIGEN_MPL2_ONLY 34 | #error The SparseCholesky module has nothing to offer in MPL2 only mode 35 | #endif 36 | 37 | #include "src/SparseCholesky/SimplicialCholesky.h" 38 | 39 | #ifndef EIGEN_MPL2_ONLY 40 | #include "src/SparseCholesky/SimplicialCholesky_impl.h" 41 | #endif 42 | 43 | #include "src/Core/util/ReenableStupidWarnings.h" 44 | 45 | #endif // EIGEN_SPARSECHOLESKY_MODULE_H 46 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/ThirdParty/Eigen/SparseLU: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2012 Désiré Nuentsa-Wakam 5 | // Copyright (C) 2012 Gael Guennebaud 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_SPARSELU_MODULE_H 12 | #define EIGEN_SPARSELU_MODULE_H 13 | 14 | #include "SparseCore" 15 | 16 | /** 17 | * \defgroup SparseLU_Module SparseLU module 18 | * This module defines a supernodal factorization of general sparse matrices. 19 | * The code is fully optimized for supernode-panel updates with specialized kernels. 20 | * Please, see the documentation of the SparseLU class for more details. 21 | */ 22 | 23 | // Ordering interface 24 | #include "OrderingMethods" 25 | 26 | #include "src/SparseLU/SparseLU_gemm_kernel.h" 27 | 28 | #include "src/SparseLU/SparseLU_Structs.h" 29 | #include "src/SparseLU/SparseLU_SupernodalMatrix.h" 30 | #include "src/SparseLU/SparseLUImpl.h" 31 | #include "src/SparseCore/SparseColEtree.h" 32 | #include "src/SparseLU/SparseLU_Memory.h" 33 | #include "src/SparseLU/SparseLU_heap_relax_snode.h" 34 | #include "src/SparseLU/SparseLU_relax_snode.h" 35 | #include "src/SparseLU/SparseLU_pivotL.h" 36 | #include "src/SparseLU/SparseLU_panel_dfs.h" 37 | #include "src/SparseLU/SparseLU_kernel_bmod.h" 38 | #include "src/SparseLU/SparseLU_panel_bmod.h" 39 | #include "src/SparseLU/SparseLU_column_dfs.h" 40 | #include "src/SparseLU/SparseLU_column_bmod.h" 41 | #include "src/SparseLU/SparseLU_copy_to_ucol.h" 42 | #include "src/SparseLU/SparseLU_pruneL.h" 43 | #include "src/SparseLU/SparseLU_Utils.h" 44 | #include "src/SparseLU/SparseLU.h" 45 | 46 | #endif // EIGEN_SPARSELU_MODULE_H 47 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/ThirdParty/Eigen/SparseQR: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_SPARSEQR_MODULE_H 9 | #define EIGEN_SPARSEQR_MODULE_H 10 | 11 | #include "SparseCore" 12 | #include "OrderingMethods" 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | /** \defgroup SparseQR_Module SparseQR module 16 | * \brief Provides QR decomposition for sparse matrices 17 | * 18 | * This module provides a simplicial version of the left-looking Sparse QR decomposition. 19 | * The columns of the input matrix should be reordered to limit the fill-in during the 20 | * decomposition. Built-in methods (COLAMD, AMD) or external methods (METIS) can be used to this end. 21 | * See the \link OrderingMethods_Module OrderingMethods\endlink module for the list 22 | * of built-in and external ordering methods. 23 | * 24 | * \code 25 | * #include 26 | * \endcode 27 | * 28 | * 29 | */ 30 | 31 | #include "OrderingMethods" 32 | #include "src/SparseCore/SparseColEtree.h" 33 | #include "src/SparseQR/SparseQR.h" 34 | 35 | #include "src/Core/util/ReenableStupidWarnings.h" 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/ThirdParty/Eigen/StdDeque: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Gael Guennebaud 5 | // Copyright (C) 2009 Hauke Heibel 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_STDDEQUE_MODULE_H 12 | #define EIGEN_STDDEQUE_MODULE_H 13 | 14 | #include "Core" 15 | #include 16 | 17 | #if EIGEN_COMP_MSVC && EIGEN_OS_WIN64 && (EIGEN_MAX_STATIC_ALIGN_BYTES<=16) /* MSVC auto aligns up to 16 bytes in 64 bit builds */ 18 | 19 | #define EIGEN_DEFINE_STL_DEQUE_SPECIALIZATION(...) 20 | 21 | #else 22 | 23 | #include "src/StlSupport/StdDeque.h" 24 | 25 | #endif 26 | 27 | #endif // EIGEN_STDDEQUE_MODULE_H 28 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/ThirdParty/Eigen/StdList: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Hauke Heibel 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_STDLIST_MODULE_H 11 | #define EIGEN_STDLIST_MODULE_H 12 | 13 | #include "Core" 14 | #include 15 | 16 | #if EIGEN_COMP_MSVC && EIGEN_OS_WIN64 && (EIGEN_MAX_STATIC_ALIGN_BYTES<=16) /* MSVC auto aligns up to 16 bytes in 64 bit builds */ 17 | 18 | #define EIGEN_DEFINE_STL_LIST_SPECIALIZATION(...) 19 | 20 | #else 21 | 22 | #include "src/StlSupport/StdList.h" 23 | 24 | #endif 25 | 26 | #endif // EIGEN_STDLIST_MODULE_H 27 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/ThirdParty/Eigen/StdVector: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Gael Guennebaud 5 | // Copyright (C) 2009 Hauke Heibel 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_STDVECTOR_MODULE_H 12 | #define EIGEN_STDVECTOR_MODULE_H 13 | 14 | #include "Core" 15 | #include 16 | 17 | #if EIGEN_COMP_MSVC && EIGEN_OS_WIN64 && (EIGEN_MAX_STATIC_ALIGN_BYTES<=16) /* MSVC auto aligns up to 16 bytes in 64 bit builds */ 18 | 19 | #define EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(...) 20 | 21 | #else 22 | 23 | #include "src/StlSupport/StdVector.h" 24 | 25 | #endif 26 | 27 | #endif // EIGEN_STDVECTOR_MODULE_H 28 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/ThirdParty/Eigen/UmfPackSupport: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_UMFPACKSUPPORT_MODULE_H 9 | #define EIGEN_UMFPACKSUPPORT_MODULE_H 10 | 11 | #include "SparseCore" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | extern "C" { 16 | #include 17 | } 18 | 19 | /** \ingroup Support_modules 20 | * \defgroup UmfPackSupport_Module UmfPackSupport module 21 | * 22 | * This module provides an interface for the UmfPack library which is part of the suitesparse package. 23 | * It provides the following factorization class: 24 | * - class UmfPackLU: a multifrontal sequential LU factorization. 25 | * 26 | * \code 27 | * #include 28 | * \endcode 29 | * 30 | * In order to use this module, the umfpack headers must be accessible from the include paths, and your binary must be linked to the umfpack library and its dependencies. 31 | * The dependencies depend on how umfpack has been compiled. 32 | * For a cmake based project, you can use our FindUmfPack.cmake module to help you in this task. 33 | * 34 | */ 35 | 36 | #include "src/UmfPackSupport/UmfPackSupport.h" 37 | 38 | #include "src/Core/util/ReenableStupidWarnings.h" 39 | 40 | #endif // EIGEN_UMFPACKSUPPORT_MODULE_H 41 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/ThirdParty/Eigen/src/Core/DiagonalProduct.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008 Gael Guennebaud 5 | // Copyright (C) 2007-2009 Benoit Jacob 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_DIAGONALPRODUCT_H 12 | #define EIGEN_DIAGONALPRODUCT_H 13 | 14 | namespace Eigen { 15 | 16 | /** \returns the diagonal matrix product of \c *this by the diagonal matrix \a diagonal. 17 | */ 18 | template 19 | template 20 | inline const Product 21 | MatrixBase::operator*(const DiagonalBase &a_diagonal) const 22 | { 23 | return Product(derived(),a_diagonal.derived()); 24 | } 25 | 26 | } // end namespace Eigen 27 | 28 | #endif // EIGEN_DIAGONALPRODUCT_H 29 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/ThirdParty/Eigen/src/Core/SelfCwiseBinaryOp.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009-2010 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_SELFCWISEBINARYOP_H 11 | #define EIGEN_SELFCWISEBINARYOP_H 12 | 13 | namespace Eigen { 14 | 15 | // TODO generalize the scalar type of 'other' 16 | 17 | template 18 | EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase::operator*=(const Scalar& other) 19 | { 20 | internal::call_assignment(this->derived(), PlainObject::Constant(rows(),cols(),other), internal::mul_assign_op()); 21 | return derived(); 22 | } 23 | 24 | template 25 | EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& ArrayBase::operator+=(const Scalar& other) 26 | { 27 | internal::call_assignment(this->derived(), PlainObject::Constant(rows(),cols(),other), internal::add_assign_op()); 28 | return derived(); 29 | } 30 | 31 | template 32 | EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& ArrayBase::operator-=(const Scalar& other) 33 | { 34 | internal::call_assignment(this->derived(), PlainObject::Constant(rows(),cols(),other), internal::sub_assign_op()); 35 | return derived(); 36 | } 37 | 38 | template 39 | EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase::operator/=(const Scalar& other) 40 | { 41 | internal::call_assignment(this->derived(), PlainObject::Constant(rows(),cols(),other), internal::div_assign_op()); 42 | return derived(); 43 | } 44 | 45 | } // end namespace Eigen 46 | 47 | #endif // EIGEN_SELFCWISEBINARYOP_H 48 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/ThirdParty/Eigen/src/Core/arch/AVX/TypeCasting.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2015 Benoit Steiner 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_TYPE_CASTING_AVX_H 11 | #define EIGEN_TYPE_CASTING_AVX_H 12 | 13 | namespace Eigen { 14 | 15 | namespace internal { 16 | 17 | // For now we use SSE to handle integers, so we can't use AVX instructions to cast 18 | // from int to float 19 | template <> 20 | struct type_casting_traits { 21 | enum { 22 | VectorizedCast = 0, 23 | SrcCoeffRatio = 1, 24 | TgtCoeffRatio = 1 25 | }; 26 | }; 27 | 28 | template <> 29 | struct type_casting_traits { 30 | enum { 31 | VectorizedCast = 0, 32 | SrcCoeffRatio = 1, 33 | TgtCoeffRatio = 1 34 | }; 35 | }; 36 | 37 | 38 | 39 | template<> EIGEN_STRONG_INLINE Packet8i pcast(const Packet8f& a) { 40 | return _mm256_cvtps_epi32(a); 41 | } 42 | 43 | template<> EIGEN_STRONG_INLINE Packet8f pcast(const Packet8i& a) { 44 | return _mm256_cvtepi32_ps(a); 45 | } 46 | 47 | } // end namespace internal 48 | 49 | } // end namespace Eigen 50 | 51 | #endif // EIGEN_TYPE_CASTING_AVX_H 52 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/ThirdParty/Eigen/src/Core/arch/Default/ConjHelper.h: -------------------------------------------------------------------------------- 1 | 2 | // This file is part of Eigen, a lightweight C++ template library 3 | // for linear algebra. 4 | // 5 | // Copyright (C) 2017 Gael Guennebaud 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_ARCH_CONJ_HELPER_H 12 | #define EIGEN_ARCH_CONJ_HELPER_H 13 | 14 | #define EIGEN_MAKE_CONJ_HELPER_CPLX_REAL(PACKET_CPLX, PACKET_REAL) \ 15 | template<> struct conj_helper { \ 16 | EIGEN_STRONG_INLINE PACKET_CPLX pmadd(const PACKET_REAL& x, const PACKET_CPLX& y, const PACKET_CPLX& c) const \ 17 | { return padd(c, pmul(x,y)); } \ 18 | EIGEN_STRONG_INLINE PACKET_CPLX pmul(const PACKET_REAL& x, const PACKET_CPLX& y) const \ 19 | { return PACKET_CPLX(Eigen::internal::pmul(x, y.v)); } \ 20 | }; \ 21 | \ 22 | template<> struct conj_helper { \ 23 | EIGEN_STRONG_INLINE PACKET_CPLX pmadd(const PACKET_CPLX& x, const PACKET_REAL& y, const PACKET_CPLX& c) const \ 24 | { return padd(c, pmul(x,y)); } \ 25 | EIGEN_STRONG_INLINE PACKET_CPLX pmul(const PACKET_CPLX& x, const PACKET_REAL& y) const \ 26 | { return PACKET_CPLX(Eigen::internal::pmul(x.v, y)); } \ 27 | }; 28 | 29 | #endif // EIGEN_ARCH_CONJ_HELPER_H 30 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/ThirdParty/Eigen/src/Core/arch/Default/Settings.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2010 Gael Guennebaud 5 | // Copyright (C) 2006-2008 Benoit Jacob 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | 12 | /* All the parameters defined in this file can be specialized in the 13 | * architecture specific files, and/or by the user. 14 | * More to come... */ 15 | 16 | #ifndef EIGEN_DEFAULT_SETTINGS_H 17 | #define EIGEN_DEFAULT_SETTINGS_H 18 | 19 | /** Defines the maximal loop size to enable meta unrolling of loops. 20 | * Note that the value here is expressed in Eigen's own notion of "number of FLOPS", 21 | * it does not correspond to the number of iterations or the number of instructions 22 | */ 23 | #ifndef EIGEN_UNROLLING_LIMIT 24 | #define EIGEN_UNROLLING_LIMIT 100 25 | #endif 26 | 27 | /** Defines the threshold between a "small" and a "large" matrix. 28 | * This threshold is mainly used to select the proper product implementation. 29 | */ 30 | #ifndef EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD 31 | #define EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD 8 32 | #endif 33 | 34 | /** Defines the maximal width of the blocks used in the triangular product and solver 35 | * for vectors (level 2 blas xTRMV and xTRSV). The default is 8. 36 | */ 37 | #ifndef EIGEN_TUNE_TRIANGULAR_PANEL_WIDTH 38 | #define EIGEN_TUNE_TRIANGULAR_PANEL_WIDTH 8 39 | #endif 40 | 41 | 42 | /** Defines the default number of registers available for that architecture. 43 | * Currently it must be 8 or 16. Other values will fail. 44 | */ 45 | #ifndef EIGEN_ARCH_DEFAULT_NUMBER_OF_REGISTERS 46 | #define EIGEN_ARCH_DEFAULT_NUMBER_OF_REGISTERS 8 47 | #endif 48 | 49 | #endif // EIGEN_DEFAULT_SETTINGS_H 50 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/ThirdParty/Eigen/src/Core/arch/SSE/TypeCasting.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2015 Benoit Steiner 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_TYPE_CASTING_SSE_H 11 | #define EIGEN_TYPE_CASTING_SSE_H 12 | 13 | namespace Eigen { 14 | 15 | namespace internal { 16 | 17 | #ifndef EIGEN_VECTORIZE_AVX 18 | template <> 19 | struct type_casting_traits { 20 | enum { 21 | VectorizedCast = 1, 22 | SrcCoeffRatio = 1, 23 | TgtCoeffRatio = 1 24 | }; 25 | }; 26 | 27 | template <> 28 | struct type_casting_traits { 29 | enum { 30 | VectorizedCast = 1, 31 | SrcCoeffRatio = 1, 32 | TgtCoeffRatio = 1 33 | }; 34 | }; 35 | 36 | template <> 37 | struct type_casting_traits { 38 | enum { 39 | VectorizedCast = 1, 40 | SrcCoeffRatio = 2, 41 | TgtCoeffRatio = 1 42 | }; 43 | }; 44 | 45 | template <> 46 | struct type_casting_traits { 47 | enum { 48 | VectorizedCast = 1, 49 | SrcCoeffRatio = 1, 50 | TgtCoeffRatio = 2 51 | }; 52 | }; 53 | #endif 54 | 55 | template<> EIGEN_STRONG_INLINE Packet4i pcast(const Packet4f& a) { 56 | return _mm_cvttps_epi32(a); 57 | } 58 | 59 | template<> EIGEN_STRONG_INLINE Packet4f pcast(const Packet4i& a) { 60 | return _mm_cvtepi32_ps(a); 61 | } 62 | 63 | template<> EIGEN_STRONG_INLINE Packet4f pcast(const Packet2d& a, const Packet2d& b) { 64 | return _mm_shuffle_ps(_mm_cvtpd_ps(a), _mm_cvtpd_ps(b), (1 << 2) | (1 << 6)); 65 | } 66 | 67 | template<> EIGEN_STRONG_INLINE Packet2d pcast(const Packet4f& a) { 68 | // Simply discard the second half of the input 69 | return _mm_cvtps_pd(a); 70 | } 71 | 72 | 73 | } // end namespace internal 74 | 75 | } // end namespace Eigen 76 | 77 | #endif // EIGEN_TYPE_CASTING_SSE_H 78 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/ThirdParty/Eigen/src/Core/functors/TernaryFunctors.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2016 Eugene Brevdo 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_TERNARY_FUNCTORS_H 11 | #define EIGEN_TERNARY_FUNCTORS_H 12 | 13 | namespace Eigen { 14 | 15 | namespace internal { 16 | 17 | //---------- associative ternary functors ---------- 18 | 19 | 20 | 21 | } // end namespace internal 22 | 23 | } // end namespace Eigen 24 | 25 | #endif // EIGEN_TERNARY_FUNCTORS_H 26 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/ThirdParty/Eigen/src/Core/util/NonMPL2.h: -------------------------------------------------------------------------------- 1 | #ifdef EIGEN_MPL2_ONLY 2 | #error Including non-MPL2 code in EIGEN_MPL2_ONLY mode 3 | #endif 4 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/ThirdParty/Eigen/src/Core/util/ReenableStupidWarnings.h: -------------------------------------------------------------------------------- 1 | #ifdef EIGEN_WARNINGS_DISABLED 2 | #undef EIGEN_WARNINGS_DISABLED 3 | 4 | #ifndef EIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS 5 | #ifdef _MSC_VER 6 | #pragma warning( pop ) 7 | #elif defined __INTEL_COMPILER 8 | #pragma warning pop 9 | #elif defined __clang__ 10 | #pragma clang diagnostic pop 11 | #elif defined __GNUC__ && __GNUC__>=6 12 | #pragma GCC diagnostic pop 13 | #endif 14 | 15 | #if defined __NVCC__ 16 | // Don't reenable the diagnostic messages, as it turns out these messages need 17 | // to be disabled at the point of the template instantiation (i.e the user code) 18 | // otherwise they'll be triggered by nvcc. 19 | // #pragma diag_default code_is_unreachable 20 | // #pragma diag_default initialization_not_reachable 21 | // #pragma diag_default 2651 22 | // #pragma diag_default 2653 23 | #endif 24 | 25 | #endif 26 | 27 | #endif // EIGEN_WARNINGS_DISABLED 28 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/ThirdParty/Eigen/src/IterativeLinearSolvers/Eigen.lnk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/qurator-vscode/ddb73d09b6e4700cd45c9dcabd09ea3c2c432713/client/resources/qrunesScripts/include/ThirdParty/Eigen/src/IterativeLinearSolvers/Eigen.lnk -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/ThirdParty/Eigen/src/SparseCore/SparseFuzzy.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2014 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_SPARSE_FUZZY_H 11 | #define EIGEN_SPARSE_FUZZY_H 12 | 13 | namespace Eigen { 14 | 15 | template 16 | template 17 | bool SparseMatrixBase::isApprox(const SparseMatrixBase& other, const RealScalar &prec) const 18 | { 19 | const typename internal::nested_eval::type actualA(derived()); 20 | typename internal::conditional::type, 22 | const PlainObject>::type actualB(other.derived()); 23 | 24 | return (actualA - actualB).squaredNorm() <= prec * prec * numext::mini(actualA.squaredNorm(), actualB.squaredNorm()); 25 | } 26 | 27 | } // end namespace Eigen 28 | 29 | #endif // EIGEN_SPARSE_FUZZY_H 30 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/ThirdParty/Eigen/src/SparseCore/SparseRedux.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2014 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_SPARSEREDUX_H 11 | #define EIGEN_SPARSEREDUX_H 12 | 13 | namespace Eigen { 14 | 15 | template 16 | typename internal::traits::Scalar 17 | SparseMatrixBase::sum() const 18 | { 19 | eigen_assert(rows()>0 && cols()>0 && "you are using a non initialized matrix"); 20 | Scalar res(0); 21 | internal::evaluator thisEval(derived()); 22 | for (Index j=0; j::InnerIterator iter(thisEval,j); iter; ++iter) 24 | res += iter.value(); 25 | return res; 26 | } 27 | 28 | template 29 | typename internal::traits >::Scalar 30 | SparseMatrix<_Scalar,_Options,_Index>::sum() const 31 | { 32 | eigen_assert(rows()>0 && cols()>0 && "you are using a non initialized matrix"); 33 | if(this->isCompressed()) 34 | return Matrix::Map(m_data.valuePtr(), m_data.size()).sum(); 35 | else 36 | return Base::sum(); 37 | } 38 | 39 | template 40 | typename internal::traits >::Scalar 41 | SparseVector<_Scalar,_Options,_Index>::sum() const 42 | { 43 | eigen_assert(rows()>0 && cols()>0 && "you are using a non initialized matrix"); 44 | return Matrix::Map(m_data.valuePtr(), m_data.size()).sum(); 45 | } 46 | 47 | } // end namespace Eigen 48 | 49 | #endif // EIGEN_SPARSEREDUX_H 50 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/ThirdParty/Eigen/src/misc/RealSvd2x2.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009-2010 Benoit Jacob 5 | // Copyright (C) 2013-2016 Gael Guennebaud 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_REALSVD2X2_H 12 | #define EIGEN_REALSVD2X2_H 13 | 14 | namespace Eigen { 15 | 16 | namespace internal { 17 | 18 | template 19 | void real_2x2_jacobi_svd(const MatrixType& matrix, Index p, Index q, 20 | JacobiRotation *j_left, 21 | JacobiRotation *j_right) 22 | { 23 | using std::sqrt; 24 | using std::abs; 25 | Matrix m; 26 | m << numext::real(matrix.coeff(p,p)), numext::real(matrix.coeff(p,q)), 27 | numext::real(matrix.coeff(q,p)), numext::real(matrix.coeff(q,q)); 28 | JacobiRotation rot1; 29 | RealScalar t = m.coeff(0,0) + m.coeff(1,1); 30 | RealScalar d = m.coeff(1,0) - m.coeff(0,1); 31 | 32 | if(abs(d) < (std::numeric_limits::min)()) 33 | { 34 | rot1.s() = RealScalar(0); 35 | rot1.c() = RealScalar(1); 36 | } 37 | else 38 | { 39 | // If d!=0, then t/d cannot overflow because the magnitude of the 40 | // entries forming d are not too small compared to the ones forming t. 41 | RealScalar u = t / d; 42 | RealScalar tmp = sqrt(RealScalar(1) + numext::abs2(u)); 43 | rot1.s() = RealScalar(1) / tmp; 44 | rot1.c() = u / tmp; 45 | } 46 | m.applyOnTheLeft(0,1,rot1); 47 | j_right->makeJacobi(m,0,1); 48 | *j_left = rot1 * j_right->transpose(); 49 | } 50 | 51 | } // end namespace internal 52 | 53 | } // end namespace Eigen 54 | 55 | #endif // EIGEN_REALSVD2X2_H 56 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/ThirdParty/Eigen/src/misc/lapacke_mangling.h: -------------------------------------------------------------------------------- 1 | #ifndef LAPACK_HEADER_INCLUDED 2 | #define LAPACK_HEADER_INCLUDED 3 | 4 | #ifndef LAPACK_GLOBAL 5 | #if defined(LAPACK_GLOBAL_PATTERN_LC) || defined(ADD_) 6 | #define LAPACK_GLOBAL(lcname,UCNAME) lcname##_ 7 | #elif defined(LAPACK_GLOBAL_PATTERN_UC) || defined(UPPER) 8 | #define LAPACK_GLOBAL(lcname,UCNAME) UCNAME 9 | #elif defined(LAPACK_GLOBAL_PATTERN_MC) || defined(NOCHANGE) 10 | #define LAPACK_GLOBAL(lcname,UCNAME) lcname 11 | #else 12 | #define LAPACK_GLOBAL(lcname,UCNAME) lcname##_ 13 | #endif 14 | #endif 15 | 16 | #endif 17 | 18 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/ThirdParty/bplus-tree/include/private/errors.h: -------------------------------------------------------------------------------- 1 | #ifndef _PRIVATE_ERRORS_H_ 2 | #define _PRIVATE_ERRORS_H_ 3 | 4 | #define BP_OK 0 5 | 6 | #define BP_EFILE 0x101 7 | #define BP_EFILEREAD_OOB 0x102 8 | #define BP_EFILEREAD 0x103 9 | #define BP_EFILEWRITE 0x104 10 | #define BP_EFILEFLUSH 0x105 11 | #define BP_EFILERENAME 0x106 12 | #define BP_ECOMPACT_EXISTS 0x107 13 | 14 | #define BP_ECOMP 0x201 15 | #define BP_EDECOMP 0x202 16 | 17 | #define BP_EALLOC 0x301 18 | #define BP_EMUTEX 0x302 19 | #define BP_ERWLOCK 0x303 20 | 21 | #define BP_ENOTFOUND 0x401 22 | #define BP_ESPLITPAGE 0x402 23 | #define BP_EEMPTYPAGE 0x403 24 | #define BP_EUPDATECONFLICT 0x404 25 | #define BP_EREMOVECONFLICT 0x405 26 | 27 | #endif /* _PRIVATE_ERRORS_H_ */ 28 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/ThirdParty/bplus-tree/include/private/tree.h: -------------------------------------------------------------------------------- 1 | #ifndef _PRIVATE_TREE_H_ 2 | #define _PRIVATE_TREE_H_ 3 | 4 | #include "private/writer.h" 5 | #include "private/pages.h" 6 | #include "Core/Utilities/ReadWriteLock.h" 7 | 8 | #define BP__HEAD_SIZE sizeof(uint64_t) * 4 9 | 10 | #define BP_TREE_PRIVATE \ 11 | BP_WRITER_PRIVATE \ 12 | SharedMutex rwlock; \ 13 | bp__tree_head_t head; \ 14 | bp_compare_cb compare_cb; 15 | 16 | typedef struct bp__tree_head_s bp__tree_head_t; 17 | 18 | int bp__init(bp_db_t *tree); 19 | void bp__destroy(bp_db_t *tree); 20 | 21 | int bp__tree_read_head(bp__writer_t *w, void *data); 22 | int bp__tree_write_head(bp__writer_t *w, void *data); 23 | 24 | int bp__default_compare_cb(const bp_key_t *a, const bp_key_t *b); 25 | int bp__default_filter_cb(void *arg, const bp_key_t *key); 26 | 27 | 28 | struct bp__tree_head_s { 29 | uint64_t offset; 30 | uint64_t config; 31 | uint64_t page_size; 32 | uint64_t hash; 33 | 34 | bp__page_t *page; 35 | }; 36 | 37 | #endif /* _PRIVATE_TREE_H_ */ 38 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/ThirdParty/bplus-tree/include/private/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef _PRIVATE_UTILS_H_ 2 | #define _PRIVATE_UTILS_H_ 3 | 4 | #include /* uint64_t */ 5 | 6 | uint64_t bp__compute_hashl(uint64_t key); 7 | uint64_t myhtonll(uint64_t value); 8 | uint64_t myntohll(uint64_t value); 9 | 10 | #endif /* _PRIVATE_UTILS_H_ */ 11 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/ThirdParty/bplus-tree/include/private/values.h: -------------------------------------------------------------------------------- 1 | #ifndef _PRIVATE_VALUES_H_ 2 | #define _PRIVATE_VALUES_H_ 3 | 4 | 5 | #include "private/tree.h" 6 | #include 7 | 8 | #define BP__KV_HEADER_SIZE 24 9 | #define BP__KV_SIZE(kv) BP__KV_HEADER_SIZE + kv.length 10 | #define BP__STOVAL(str, key) \ 11 | key.value = (char *) str; \ 12 | key.length = strlen(str) + 1; 13 | 14 | #define BP_KEY_PRIVATE \ 15 | uint64_t _prev_offset; \ 16 | uint64_t _prev_length; 17 | 18 | typedef struct bp__kv_s bp__kv_t; 19 | 20 | 21 | int bp__value_load(bp_db_t *t, 22 | const uint64_t offset, 23 | const uint64_t length, 24 | bp_value_t *value); 25 | int bp__value_save(bp_db_t *t, 26 | const bp_value_t *value, 27 | const bp__kv_t *previous, 28 | uint64_t *offset, 29 | uint64_t *length); 30 | 31 | int bp__kv_copy(const bp__kv_t *source, bp__kv_t *target, int alloc); 32 | 33 | struct bp__kv_s { 34 | BP_KEY_FIELDS 35 | 36 | uint64_t offset; 37 | uint64_t config; 38 | 39 | uint8_t allocated; 40 | }; 41 | 42 | 43 | #endif /* _PRIVATE_VALUES_H_ */ 44 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/ThirdParty/bplus-tree/include/private/writer.h: -------------------------------------------------------------------------------- 1 | #ifndef _PRIVATE_WRITER_H_ 2 | #define _PRIVATE_WRITER_H_ 3 | 4 | #include 5 | #include 6 | 7 | #define BP_WRITER_PRIVATE \ 8 | std::fstream fd; \ 9 | std::ifstream ifd; \ 10 | char *filename; \ 11 | uint64_t filesize; \ 12 | char padding[BP_PADDING]; 13 | 14 | typedef struct bp__writer_s bp__writer_t; 15 | typedef int (*bp__writer_cb)(bp__writer_t *w, void *data); 16 | 17 | enum comp_type { 18 | kNotCompressed = 0, 19 | kCompressed = 1 20 | }; 21 | 22 | int bp__writer_create(bp__writer_t *w, const char *filename); 23 | int bp__writer_destroy(bp__writer_t *w); 24 | 25 | int bp__writer_fsync(bp__writer_t *w); 26 | 27 | int bp__writer_read(bp__writer_t *w, 28 | const enum comp_type comp, 29 | const uint64_t offset, 30 | uint64_t *size, 31 | void **data); 32 | int bp__writer_write(bp__writer_t *w, 33 | const enum comp_type comp, 34 | const void *data, 35 | uint64_t *offset, 36 | uint64_t *size); 37 | 38 | int bp__writer_find(bp__writer_t *w, 39 | const enum comp_type comp, 40 | const uint64_t size, 41 | void *data, 42 | bp__writer_cb seek, 43 | bp__writer_cb miss); 44 | 45 | struct bp__writer_s { 46 | BP_WRITER_PRIVATE 47 | }; 48 | 49 | 50 | 51 | #endif /* _PRIVATE_WRITER_H_ */ 52 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/ThirdParty/rapidjson/internal/swap.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_INTERNAL_SWAP_H_ 16 | #define RAPIDJSON_INTERNAL_SWAP_H_ 17 | 18 | #include "../rapidjson.h" 19 | 20 | #if defined(__clang__) 21 | RAPIDJSON_DIAG_PUSH 22 | RAPIDJSON_DIAG_OFF(c++98-compat) 23 | #endif 24 | 25 | RAPIDJSON_NAMESPACE_BEGIN 26 | namespace internal { 27 | 28 | //! Custom swap() to avoid dependency on C++ header 29 | /*! \tparam T Type of the arguments to swap, should be instantiated with primitive C++ types only. 30 | \note This has the same semantics as std::swap(). 31 | */ 32 | template 33 | inline void Swap(T& a, T& b) RAPIDJSON_NOEXCEPT { 34 | T tmp = a; 35 | a = b; 36 | b = tmp; 37 | } 38 | 39 | } // namespace internal 40 | RAPIDJSON_NAMESPACE_END 41 | 42 | #if defined(__clang__) 43 | RAPIDJSON_DIAG_POP 44 | #endif 45 | 46 | #endif // RAPIDJSON_INTERNAL_SWAP_H_ 47 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/Variational/DataType.h: -------------------------------------------------------------------------------- 1 | #ifndef DATATYPE_H 2 | #define DATATYPE_H 3 | 4 | #include 5 | 6 | namespace QPanda { 7 | namespace Variational { 8 | 9 | class Double 10 | { 11 | std::shared_ptr m_d; 12 | public: 13 | Double(); 14 | Double(double); 15 | Double(const Double&); 16 | operator double() 17 | { 18 | return *m_d; 19 | } 20 | }; 21 | 22 | inline Double::Double() { m_d = std::shared_ptr(new double(0)); } 23 | inline Double::Double(double val) { m_d = std::shared_ptr(new double(val)); } 24 | inline Double::Double(const Double& d) { m_d = d.m_d; } 25 | 26 | } // Variational 27 | } // QPanda 28 | #endif // !DATATYPE_H -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/Variational/Optimizer.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/qurator-vscode/ddb73d09b6e4700cd45c9dcabd09ea3c2c432713/client/resources/qrunesScripts/include/Variational/Optimizer.h -------------------------------------------------------------------------------- /client/resources/qrunesScripts/include/Variational/utils.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Variational/expression.h" 4 | #include 5 | 6 | namespace QPanda { 7 | namespace Variational { 8 | 9 | // The utils file is a list of functions that 10 | // could be commonly used by the user. 11 | // 12 | // So far, we support eval(), and back(). 13 | // 14 | // The general format is for the user to 15 | // input a specific flag into the functions. 16 | // The user _should not_ have to know the internals. 17 | 18 | // Provides an interface for the et::expression evaluation 19 | // pipeline. This is to abstract away the construction of 20 | // an expression and choose the method of evaluation. 21 | MatrixXd eval(var v, bool iter); 22 | 23 | // Provides an interface for the et::expression backprop 24 | // pipeline. 25 | 26 | enum class back_flags { 27 | const_qualify 28 | }; 29 | 30 | void back(const var&, std::unordered_map&); 31 | void back(expression&, std::unordered_map&); 32 | void back(const var&, std::unordered_map&, const std::unordered_set&); 33 | void back(expression&, std::unordered_map&, const std::unordered_set&); 34 | 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/lib_linux/libQAlg.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/qurator-vscode/ddb73d09b6e4700cd45c9dcabd09ea3c2c432713/client/resources/qrunesScripts/lib_linux/libQAlg.a -------------------------------------------------------------------------------- /client/resources/qrunesScripts/lib_linux/libQPanda2.0.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/qurator-vscode/ddb73d09b6e4700cd45c9dcabd09ea3c2c432713/client/resources/qrunesScripts/lib_linux/libQPanda2.0.a -------------------------------------------------------------------------------- /client/resources/qrunesScripts/lib_linux/libTinyXML.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/qurator-vscode/ddb73d09b6e4700cd45c9dcabd09ea3c2c432713/client/resources/qrunesScripts/lib_linux/libTinyXML.a -------------------------------------------------------------------------------- /client/resources/qrunesScripts/lib_windows/libBplusTree.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/qurator-vscode/ddb73d09b6e4700cd45c9dcabd09ea3c2c432713/client/resources/qrunesScripts/lib_windows/libBplusTree.a -------------------------------------------------------------------------------- /client/resources/qrunesScripts/lib_windows/libQAlg.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/qurator-vscode/ddb73d09b6e4700cd45c9dcabd09ea3c2c432713/client/resources/qrunesScripts/lib_windows/libQAlg.a -------------------------------------------------------------------------------- /client/resources/qrunesScripts/lib_windows/libQPanda2.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/qurator-vscode/ddb73d09b6e4700cd45c9dcabd09ea3c2c432713/client/resources/qrunesScripts/lib_windows/libQPanda2.a -------------------------------------------------------------------------------- /client/resources/qrunesScripts/lib_windows/libTinyXML.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/qurator-vscode/ddb73d09b6e4700cd45c9dcabd09ea3c2c432713/client/resources/qrunesScripts/lib_windows/libTinyXML.a -------------------------------------------------------------------------------- /client/resources/qrunesScripts/lib_windows/libVariational.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/qurator-vscode/ddb73d09b6e4700cd45c9dcabd09ea3c2c432713/client/resources/qrunesScripts/lib_windows/libVariational.a -------------------------------------------------------------------------------- /client/resources/qrunesScripts/lib_windows/libgtest.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/qurator-vscode/ddb73d09b6e4700cd45c9dcabd09ea3c2c432713/client/resources/qrunesScripts/lib_windows/libgtest.a -------------------------------------------------------------------------------- /client/resources/qrunesScripts/lib_windows/libpyQPanda.dll.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/qurator-vscode/ddb73d09b6e4700cd45c9dcabd09ea3c2c432713/client/resources/qrunesScripts/lib_windows/libpyQPanda.dll.a -------------------------------------------------------------------------------- /client/resources/qrunesScripts/lib_windows/libpyQPandaPauliOperator.dll.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/qurator-vscode/ddb73d09b6e4700cd45c9dcabd09ea3c2c432713/client/resources/qrunesScripts/lib_windows/libpyQPandaPauliOperator.dll.a -------------------------------------------------------------------------------- /client/resources/qrunesScripts/qcodeHandle.py: -------------------------------------------------------------------------------- 1 | from antlr4 import FileStream,CommonTokenStream 2 | from qcode.QcodeLexer import QcodeLexer 3 | from qcode.QcodeParser import QcodeParser 4 | from QcodeUtil import QcodeFileManager 5 | from TraverseEngineCpp import TraverEngineCpp 6 | from TraverseEngine import TraverEngine 7 | import os 8 | import sys 9 | import argparse 10 | 11 | def qcode_handle(source_file_name:str, file_manager:QcodeFileManager, flag_index:int): 12 | input = FileStream(source_file_name, encoding = 'utf-8') 13 | lexer = QcodeLexer(input) 14 | stream = CommonTokenStream(lexer) 15 | parser = QcodeParser(stream) 16 | tree = parser.qrunes() 17 | if flag_index == 0: 18 | visitor = TraverEngine(file_manager) 19 | visitor.visit(tree) 20 | elif flag_index == 1: 21 | with TraverEngineCpp(file_manager) as visitor: 22 | visitor.visit(tree) 23 | 24 | def main(qrunes_file,file_generate_path,flag_index): 25 | # current_path 26 | current_path = os.path.abspath(__file__) 27 | sep_path = os.path.dirname(current_path) + os.path.sep 28 | 29 | # flag_index 0:python 1:cpp 30 | if flag_index == 0: 31 | source_file_name = os.path.abspath(sep_path + os.sep + "qcodes.q") 32 | qcode_file_path = file_generate_path + os.sep + 'qcodes.py' 33 | elif flag_index == 1: 34 | source_file_name = os.path.abspath(sep_path + os.sep + "qcodes.p") 35 | qcode_file_path = file_generate_path + os.sep + 'qcodes.h' 36 | 37 | # find the result file and judge whether the file is accessed 38 | if os.path.exists(qcode_file_path): 39 | try: 40 | os.remove(qcode_file_path) 41 | except IOError: 42 | pass 43 | 44 | if not os.path.exists(qcode_file_path): 45 | qcode_file = open(qcode_file_path, 'w', encoding='utf-8') 46 | file_manager = QcodeFileManager(qcode_file) 47 | qcode_handle(source_file_name, file_manager, flag_index) 48 | qcode_file.close() 49 | 50 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/qcodeVisitorHandle.py: -------------------------------------------------------------------------------- 1 | from qcode.qcodeParser import qcodeParser 2 | from qcode.qcodeVisitor import qcodeVisitor 3 | 4 | #ParseTreeVisitor 5 | class qcodeVisitorHandle(qcodeVisitor): 6 | 7 | # Visit a parse tree produced by qcodeParser#qrunes. 8 | def visitQrunes(self, ctx:qcodeParser.QrunesContext): 9 | for index in range(len(ctx.lang_unit())): 10 | self.visitLang_unit(ctx.lang_unit(index)) 11 | 12 | # Visit a parse tree produced by qcodeParser#lang_unit. 13 | def visitLang_unit(self, ctx:qcodeParser.Lang_unitContext): 14 | if ctx.declaration() is not None: 15 | self.visitDeclaration(ctx.declaration())#+++++++++++ 16 | elif ctx.function_definition() is not None: 17 | self.visitFunction_definition(ctx.function_definition())#+++++++++++++++++++++++++ 18 | 19 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/qcodes.p: -------------------------------------------------------------------------------- 1 | circuit,qubit> generate_two_qubit_oracle(vector oracle_function){ 2 | return lambda (vector qlist,qubit qubit2):{ 3 | if (oracle_function[0] == false && 4 | oracle_function[1] == true) 5 | { 6 | // f(x) = x; 7 | CNOT(qlist[0], qubit2); 8 | } 9 | else if (oracle_function[0] == true && 10 | oracle_function[1] == false) 11 | { 12 | // f(x) = x + 1; 13 | CNOT(qlist[0], qubit2); 14 | X(qubit2); 15 | } 16 | else if (oracle_function[0] == true && 17 | oracle_function[1] == true) 18 | { 19 | // f(x) = 1 20 | X(qubit2); 21 | } 22 | else 23 | { 24 | // f(x) = 0, do nothing 25 | } 26 | }; 27 | } 28 | 29 | Deutsch_Jozsa_algorithm(vector qlist,qubit qubit2,vector clist,circuit,qubit> oracle){ 30 | X(qubit2); 31 | apply_QGate(qlist, H); 32 | H(qubit2); 33 | oracle(qlist,qubit2); 34 | apply_QGate(qlist, H); 35 | measure_all(qlist,clist); 36 | } 37 | 38 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/qcodes.q: -------------------------------------------------------------------------------- 1 | circuit controlfunc(vector qvec, int index, int value) { 2 | let cd = qvec.length() / 2; 3 | vector qvtemp; 4 | qvtemp = qvec[0:cd]; 5 | if (index == 1) { 6 | X(qvec[0]); 7 | } else if (index == 2) { 8 | X(qvec[1]); 9 | } else if (index == 0) { 10 | X(qvec[0]); 11 | X(qvec[1]); 12 | } 13 | 14 | if (value == 1) { 15 | X(qvec[3]).control(qvtemp); 16 | } else if (value == 2) { 17 | X(qvec[2]).control(qvtemp); 18 | } else if (value == 3) { 19 | X(qvec[2]).control(qvtemp); 20 | X(qvec[3]).control(qvtemp); 21 | } 22 | 23 | if (index == 1) { 24 | X(qvec[0]); 25 | } else if (index == 2) { 26 | X(qvec[1]); 27 | } else if (index == 0) { 28 | X(qvec[0]); 29 | X(qvec[1]); 30 | } 31 | } 32 | 33 | circuit oraclefunc(vector qvec, vector funvalue) { 34 | let cd = qvec.length()/2; 35 | for (let i=0: 1: 4){ 36 | let value = funvalue[i]; 37 | controlfunc(qvec, i, value); 38 | } 39 | } 40 | 41 | Simon_QProg(vector qvec, vector cvec, vector funvalue) { 42 | let cd = cvec.length(); 43 | for (let i=0: 1: cd) { 44 | H(qvec[i]); 45 | } 46 | oraclefunc(qvec, funvalue); 47 | for (let i=0: 1: cd) { 48 | H(qvec[i]); 49 | } 50 | for (let i=0: 1: cd) { 51 | measure(qvec[i], cvec[i]); 52 | } 53 | } 54 | 55 | -------------------------------------------------------------------------------- /client/resources/qrunesScripts/sh.bat: -------------------------------------------------------------------------------- 1 | g++ -w -std=c++14 -fopenmp -I./include/ -I./include/Core -I./include/Core/QuantumMachine -I./include/Core/VirtualQuantumProcessor -I./include/Core/Utilities -I./include/Core/Utilities/Transform -I./include/QAlg -I./include/ThirdParty -I./include/QAlg -I./include/ThirdParty/bplus-tree -I./include/ThirdParty/bplus-tree/include/ -I./include/ThirdParty/rapidjson/ d:/IDE/algorithmtrans2qrunes/alg_cpp/DJ_Algorithm_cpp/script.cpp -L./lib_windows/ -lQPanda2 -lpthread -lTinyXML -lQAlg -lVariational -o d:/IDE/algorithmtrans2qrunes/alg_cpp/DJ_Algorithm_cpp/a.exe -------------------------------------------------------------------------------- /client/src/configuration.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This TS file provides read Configuration info. 3 | */ 4 | 5 | import { workspace } from 'vscode'; 6 | import { Version } from './version'; 7 | import { PackageInfo } from './interfaces'; 8 | // Get qrunes package by map 9 | export namespace qrunesVSCodeConfiguration { 10 | export function requiredPackages(): PackageInfo[] { 11 | let config = workspace.getConfiguration('qurator-vscode'); 12 | let qrunesPackages = config.get('qrunes.packages'); 13 | 14 | return Object.keys(qrunesPackages).map(key => ({ 15 | name: key, 16 | version: Version.fromString(qrunesPackages[key]) 17 | })); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /client/src/dependencies/dependencyMgr.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This TS file provides read environment variables 3 | */ 4 | 5 | import * as Q from "q"; 6 | 7 | import { IDependency } from '../interfaces'; 8 | import { Dependency } from './dependency'; 9 | import { Version } from '../version'; 10 | import { workspace } from 'vscode'; 11 | 12 | export class DependencyMgr { 13 | _dependencies: Q.Promise = []; 14 | constructor() { 15 | const config = workspace.getConfiguration('qurator-vscode'); 16 | const dependList = config.get('qurator.dependencies'); 17 | Object.keys(dependList).forEach(key => { 18 | this._dependencies.push( 19 | new Dependency(key.toString(), Version.fromString(dependList[key].toString())) 20 | ); 21 | }); 22 | } 23 | 24 | checkDependencies(): Q.Promise { 25 | let packages: Array> = []; 26 | 27 | this._dependencies.forEach(dep => { 28 | packages.push(dep.isInstalled()); 29 | }); 30 | 31 | return Q.all(packages); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /client/src/interfaces.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This TS file provides Some interfaces 3 | */ 4 | 5 | import * as Q from "q"; 6 | 7 | export interface IVersionInfo { 8 | major: number; 9 | minor: number; 10 | maintenance: number; 11 | } 12 | 13 | export interface IVersion { 14 | info: IVersionInfo; 15 | 16 | toString(): string; 17 | isEqual(version: IVersion): boolean; 18 | isGreater(version: IVersion): boolean; 19 | isLesser(version: IVersion): boolean; 20 | isPythonVersion(version: IVersion): boolean; 21 | } 22 | 23 | export interface IPackageInfo { 24 | name: string; 25 | version: IVersion; 26 | summary: string; 27 | location: string; 28 | dependencies: string; //TODO:Should be [IPackageInfo] 29 | 30 | getPackageInfo(pkg: string): Q.Promise; 31 | } 32 | 33 | export interface PackageInfo { 34 | name: string; 35 | version: IVersion; 36 | summary?: string; 37 | location?: string; 38 | dependencies?: string; //TODO:Should be [PackageInfo] 39 | } 40 | 41 | export interface IDependency { 42 | name: string; 43 | requiredVersion: IVersion; 44 | 45 | isInstalled(): Q.Promise; 46 | } 47 | 48 | export interface IPackage { 49 | info: IPackageInfo; 50 | // Checks whether or not the package is installed, and if installed, check 51 | // for newer versions 52 | checkVersion(pkgVersion: string, verbose: boolean | false): Q.Promise; 53 | update(pkg: string): Q.Promise; 54 | install(pkg: string): Q.Promise; 55 | } 56 | -------------------------------------------------------------------------------- /client/src/logger.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This TS file provides Log configuration 3 | */ 4 | 5 | 'use strict'; 6 | 7 | import * as winston from 'winston'; 8 | import { FileTransportOptions } from 'winston/lib/winston/transports'; 9 | 10 | export namespace QLogger { 11 | const { printf } = winston.format; 12 | 13 | const logFormat = printf(event => `${event.level} - ${event.label}: ${event.message}`); 14 | 15 | const fileTransport = new winston.transports.File({ 16 | filename: 'qurator-vscode-log.out', 17 | maxsize: 1000000, 18 | maxFiles: 1, 19 | tailable: true 20 | } as FileTransportOptions); 21 | 22 | const logger = winston.createLogger({ 23 | level: 'silly', 24 | format: logFormat, 25 | transports: [new winston.transports.Console(), fileTransport] 26 | }); 27 | 28 | export function error(message: string, reference: any) { 29 | logger.error(message, meta(reference)); 30 | } 31 | 32 | export function info(message: string, reference: any) { 33 | logger.info(message, meta(reference)); 34 | } 35 | 36 | export function verbose(message: string, reference: any) { 37 | logger.verbose(message, meta(reference)); 38 | } 39 | 40 | export function debug(message: string, reference: any) { 41 | logger.debug(message, meta(reference)); 42 | } 43 | 44 | function meta(reference?: any) { 45 | let label = reference ? reference.constructor.name : 'unknown'; 46 | return { label }; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /client/src/packages/types.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This TS file provides the package interface 3 | */ 4 | 5 | import { PackageInfo } from '../interfaces'; 6 | 7 | export type InstallationCallback = (packageInfo: PackageInfo) => void; 8 | -------------------------------------------------------------------------------- /client/src/pip/packageInfoParser.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This TS file provides a package information parser 3 | */ 4 | 5 | export namespace PackageInfoParser { 6 | export function parseName(input: string): string { 7 | return /Name:\s*(.+)/g.exec(input)[1].trim(); 8 | } 9 | 10 | export function parseVersion(input: string): string { 11 | return /Version:\s*(.+)/g.exec(input)[1].trim(); 12 | } 13 | 14 | export function parseSummary(input: string): string { 15 | return /Summary:\s*(.+)/g.exec(input)[1].trim(); 16 | } 17 | 18 | export function parseLocation(input: string): string { 19 | return /Location:\s*(.+)/g.exec(input)[1].trim(); 20 | } 21 | 22 | export function parseDependencies(input: string): string { 23 | return /Requires:\s*(.+)/g.exec(input)[1].trim(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /client/src/pip/pipCommandExecutor.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This TS file provides ChildProcess Command Executor 3 | */ 4 | 5 | import { CommandExecutor } from '../commandExecutor'; 6 | import * as Q from 'q'; 7 | 8 | export type ParserFunction = (out: string) => string; 9 | 10 | export interface CommandExecutor { 11 | exec(command: string, args: string[], parser: ParserFunction): Q.Promise; 12 | } 13 | 14 | const PIP_COMMAND = 'pip'; 15 | // Install pyqpanda、antlr4-python3-runtime 16 | export class ChildProcessCommandExecutor implements CommandExecutor { 17 | public exec(command: string, args: string[], parser: ParserFunction): Q.Promise { 18 | return CommandExecutor.exec(PIP_COMMAND, [command].concat(args)) 19 | .then(stdout => { 20 | return Q.resolve(parser(stdout)); 21 | }) 22 | .catch(err => { 23 | return Q.reject(err); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /client/src/pip/pypiExecutor.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This TS file provides PyPiExecutor 3 | */ 4 | 5 | import * as Q from 'q'; 6 | import * as httpm from 'typed-rest-client/HttpClient'; 7 | import { PackageInfo } from '../interfaces'; 8 | import { Version } from '../version'; 9 | 10 | const PYPI_BASE_URL = 'https://pypi.python.org/pypi/'; 11 | 12 | export class PyPiExecutor { 13 | constructor() {} 14 | // Get package info 15 | async getPackageInfo(pkg: string): Q.Promise { 16 | let url: string = PYPI_BASE_URL + pkg + '/json'; 17 | let httpc: httpm.HttpClient = new httpm.HttpClient('vsts-node-api'); 18 | return httpc.get(url).then((res: httpm.HttpClientResponse) => { 19 | return res.readBody().then((body: string) => { 20 | let pypiPkgJson = JSON.parse(body); 21 | 22 | return { 23 | name: pypiPkgJson.info.name, 24 | version: Version.fromString(pypiPkgJson.info.version), 25 | summary: pypiPkgJson.info.summary, 26 | location: pypiPkgJson.info.package_url 27 | }; 28 | }); 29 | }); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /client/src/resultProvider.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This TS file provides ResultProvider 3 | */ 4 | 5 | 'use strict'; 6 | 7 | import { TextDocumentContentProvider, EventEmitter, Uri, Event } from "vscode"; 8 | 9 | export class ResultProvider implements TextDocumentContentProvider { 10 | public content: string; 11 | 12 | private _onDidChange = new EventEmitter(); 13 | 14 | public displayContent(content: string, uri: Uri) { 15 | this.content = content; 16 | this.update(uri); 17 | } 18 | 19 | public provideTextDocumentContent(): string { 20 | return this.content; 21 | } 22 | 23 | get onDidChange(): Event { 24 | return this._onDidChange.event; 25 | } 26 | 27 | public update(uri: Uri) { 28 | this._onDidChange.fire(uri); 29 | } 30 | 31 | } -------------------------------------------------------------------------------- /client/src/utils.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This TS file provides DependentPath 3 | */ 4 | import * as path from 'path'; 5 | 6 | export namespace Util { 7 | // Get path util 8 | export function getOSDependentPath(_path: string): string { 9 | let pathInOS = path.resolve(__dirname, _path); 10 | if (process.platform === 'win32') { 11 | pathInOS = pathInOS.replace(/\\/g, '/'); 12 | } 13 | return pathInOS; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /client/src/visualizations.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This TS file provides License VizManager 3 | */ 4 | 5 | 'use strict'; 6 | 7 | import { RenderBuilder } from './visualizations/renderBuilder'; 8 | 9 | export namespace VizManager { 10 | export function createViz(result: object): string { 11 | let renderer = RenderBuilder.instanceFrom(result); 12 | return renderer.render(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /client/src/visualizations/deviceStatusVisualization.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This TS file provides DeviceStatusVisualization 3 | */ 4 | 5 | 'use strict'; 6 | 7 | export namespace DeviceStatusVisualization { 8 | export function render(result: object): string { 9 | return `${result}`; 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /client/src/visualizations/preformattedRenderer.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @license 3 | * 4 | * Copyright (c) 2018, IBM. 5 | * 6 | * This source code is licensed under the Apache License, Version 2.0 found in 7 | * the LICENSE.txt file in the root directory of this source tree. 8 | */ 9 | 10 | 'use strict'; 11 | 12 | import { RenderStrategy } from './types'; 13 | 14 | export class PreformattedRenderer implements RenderStrategy { 15 | constructor(private result: object) {} 16 | 17 | render(): string { 18 | return `
${this.result}
`; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /client/src/visualizations/renderBuilder.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @license 3 | * 4 | * Copyright (c) 2018, IBM. 5 | * 6 | * This source code is licensed under the Apache License, Version 2.0 found in 7 | * the LICENSE.txt file in the root directory of this source tree. 8 | */ 9 | 10 | 'use strict'; 11 | 12 | import { RenderStrategy } from './types'; 13 | import { HistogramRenderer } from './histogramRenderer'; 14 | 15 | export namespace RenderBuilder { 16 | export function instanceFrom(result: object): RenderStrategy { 17 | 18 | return new HistogramRenderer(result); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /client/src/visualizations/types.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @license 3 | * 4 | * Copyright (c) 2018, IBM. 5 | * 6 | * This source code is licensed under the Apache License, Version 2.0 found in 7 | * the LICENSE.txt file in the root directory of this source tree. 8 | */ 9 | 10 | 'use strict'; 11 | 12 | export interface RenderStrategy { 13 | render(): string; 14 | } 15 | -------------------------------------------------------------------------------- /client/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.base.json", 3 | "compilerOptions": { 4 | "noImplicitAny": false, 5 | "module": "commonjs", 6 | "target": "es2018", 7 | "outDir": "out", 8 | "rootDir": "src", 9 | "lib": [ "es7" ], 10 | "sourceMap": true 11 | }, 12 | "include": [ 13 | "src" 14 | ], 15 | "exclude": [ 16 | "node_modules" 17 | ] 18 | } -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | SOURCEDIR = . 8 | BUILDDIR = _build 9 | 10 | # Put it first so that "make" without argument is like "make help". 11 | help: 12 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 13 | 14 | .PHONY: help Makefile 15 | 16 | # Catch-all target: route all unknown targets to Sphinx using the new 17 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 18 | %: Makefile 19 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) -------------------------------------------------------------------------------- /docs/images/Jump_definition.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/qurator-vscode/ddb73d09b6e4700cd45c9dcabd09ea3c2c432713/docs/images/Jump_definition.gif -------------------------------------------------------------------------------- /docs/images/autoComplete.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/qurator-vscode/ddb73d09b6e4700cd45c9dcabd09ea3c2c432713/docs/images/autoComplete.gif -------------------------------------------------------------------------------- /docs/images/autoCompletion.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/qurator-vscode/ddb73d09b6e4700cd45c9dcabd09ea3c2c432713/docs/images/autoCompletion.png -------------------------------------------------------------------------------- /docs/images/checkDependencies.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/qurator-vscode/ddb73d09b6e4700cd45c9dcabd09ea3c2c432713/docs/images/checkDependencies.png -------------------------------------------------------------------------------- /docs/images/checkSuccess.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/qurator-vscode/ddb73d09b6e4700cd45c9dcabd09ea3c2c432713/docs/images/checkSuccess.png -------------------------------------------------------------------------------- /docs/images/demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/qurator-vscode/ddb73d09b6e4700cd45c9dcabd09ea3c2c432713/docs/images/demo.png -------------------------------------------------------------------------------- /docs/images/execute-sample.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/qurator-vscode/ddb73d09b6e4700cd45c9dcabd09ea3c2c432713/docs/images/execute-sample.gif -------------------------------------------------------------------------------- /docs/images/extension.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/qurator-vscode/ddb73d09b6e4700cd45c9dcabd09ea3c2c432713/docs/images/extension.png -------------------------------------------------------------------------------- /docs/images/highlight.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/qurator-vscode/ddb73d09b6e4700cd45c9dcabd09ea3c2c432713/docs/images/highlight.png -------------------------------------------------------------------------------- /docs/images/hover.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/qurator-vscode/ddb73d09b6e4700cd45c9dcabd09ea3c2c432713/docs/images/hover.gif -------------------------------------------------------------------------------- /docs/images/languageChange.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/qurator-vscode/ddb73d09b6e4700cd45c9dcabd09ea3c2c432713/docs/images/languageChange.gif -------------------------------------------------------------------------------- /docs/images/qurator_test.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/qurator-vscode/ddb73d09b6e4700cd45c9dcabd09ea3c2c432713/docs/images/qurator_test.png -------------------------------------------------------------------------------- /docs/images/result.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/qurator-vscode/ddb73d09b6e4700cd45c9dcabd09ea3c2c432713/docs/images/result.png -------------------------------------------------------------------------------- /docs/images/run.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/qurator-vscode/ddb73d09b6e4700cd45c9dcabd09ea3c2c432713/docs/images/run.gif -------------------------------------------------------------------------------- /docs/images/runQRunes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/qurator-vscode/ddb73d09b6e4700cd45c9dcabd09ea3c2c432713/docs/images/runQRunes.png -------------------------------------------------------------------------------- /docs/images/runQRunes2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/qurator-vscode/ddb73d09b6e4700cd45c9dcabd09ea3c2c432713/docs/images/runQRunes2.png -------------------------------------------------------------------------------- /docs/images/run_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/qurator-vscode/ddb73d09b6e4700cd45c9dcabd09ea3c2c432713/docs/images/run_1.png -------------------------------------------------------------------------------- /docs/images/run_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/qurator-vscode/ddb73d09b6e4700cd45c9dcabd09ea3c2c432713/docs/images/run_2.png -------------------------------------------------------------------------------- /docs/images/run_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/qurator-vscode/ddb73d09b6e4700cd45c9dcabd09ea3c2c432713/docs/images/run_3.png -------------------------------------------------------------------------------- /docs/images/run_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/qurator-vscode/ddb73d09b6e4700cd45c9dcabd09ea3c2c432713/docs/images/run_4.png -------------------------------------------------------------------------------- /docs/images/snippet.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/qurator-vscode/ddb73d09b6e4700cd45c9dcabd09ea3c2c432713/docs/images/snippet.gif -------------------------------------------------------------------------------- /docs/images/validation.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/qurator-vscode/ddb73d09b6e4700cd45c9dcabd09ea3c2c432713/docs/images/validation.gif -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | .. qurator_tutorial documentation master file, created by 2 | sphinx-quickstart on Mon Feb 18 11:40:18 2019. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | qurator-vscode 7 | ============================================ 8 | 9 | 一种基于VS Code的量子程序开发工具 10 | -------------------------------------------- 11 | qurator-vscode 是本源量子推出的一款可以开发量子程序的 VS Code 插件。其支持 QRunes2 语言量子程序开发,并支持 Python 和 C++ 语言作为经典宿主语言。 12 | 13 | 在 qurator-vscode 中,量子程序的开发主要分为编写和运行两个部分。 14 | 15 | * 编写程序:插件支持模块化编程,在不同的模块实现不同的功能,其中量子程序的编写主要在 qcodes 模块中; 16 | 17 | * 程序运行:即是收集结果的过程,插件支持图表化数据展示,将运行结果更加清晰的展现在您的面前。 18 | 19 | qurator-vscode 设计思想 20 | ------------------------- 21 | 考虑到目前量子程序的开发离不开经典宿主语言的辅助,qurator-vscode 插件设计时考虑到一下几点: 22 | 23 | 1. 模块编程: 24 | ******************** 25 | 26 | qurator-vscode 插件支持模块编程,将整体程序分为三个模块:settings、qcodes 和 script 模块。在不同的模块完成不同的功能。 27 | 在 settings 模块中,您可以进行宿主语言类型、编译还是运行等设置;在 qcodes 模块中, 您可以编写 QRunes2 语言程序; 28 | 在 script 模块中,您可以编写相应的宿主语言程序。 29 | 30 | 2. 切换简单: 31 | ******************** 32 | 33 | qurator-vscode 插件目前支持两种宿主语言,分别为 Python 和 C++。您可以在两种宿主语言之间自由的切换,您只需要在 settings 模块中设置 language 的 34 | 类型,就可以在 script 模块中编写对应宿主语言的代码。插件会自动识别您所选择的宿主语言,并在 script 模块中提供相应的辅助功能。 35 | 36 | 3. 图形展示: 37 | ******************** 38 | 39 | qurator-vscode 插件提供图形化的结果展示,程序运行后会展示 json 格式的运行结果,您可以点击运行结果,会生成相应的柱状图,方便您对运行结果的分析。 40 | 41 | 目录: 42 | 43 | .. toctree:: 44 | :maxdepth: 2 45 | 46 | source/prerequisites 47 | source/quickStart 48 | source/functionDetail 49 | source/changeLog 50 | 51 | 52 | -------------------------------------------------------------------------------- /docs/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | pushd %~dp0 4 | 5 | REM Command file for Sphinx documentation 6 | 7 | if "%SPHINXBUILD%" == "" ( 8 | set SPHINXBUILD=sphinx-build 9 | ) 10 | set SOURCEDIR=. 11 | set BUILDDIR=_build 12 | 13 | if "%1" == "" goto help 14 | 15 | %SPHINXBUILD% >NUL 2>NUL 16 | if errorlevel 9009 ( 17 | echo. 18 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 19 | echo.installed, then set the SPHINXBUILD environment variable to point 20 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 21 | echo.may add the Sphinx directory to PATH. 22 | echo. 23 | echo.If you don't have Sphinx installed, grab it from 24 | echo.http://sphinx-doc.org/ 25 | exit /b 1 26 | ) 27 | 28 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% 29 | goto end 30 | 31 | :help 32 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% 33 | 34 | :end 35 | popd 36 | -------------------------------------------------------------------------------- /docs/source/changeLog.rst: -------------------------------------------------------------------------------- 1 | Change Log 2 | ================ 3 | 4 | 0.1.1 - 2019-03-01 5 | ------------------------- 6 | add 7 | ******* 8 | 9 | 1. 增加了对Ubuntu系统的支持。 10 | 2. 增加了对C++自动完成和悬停的支持。 11 | 3. 更新了snippets函数。 12 | 4. 添加了对某些关键字突出显示的支持。 13 | 5. 增加了用户手册。 14 | 15 | update 16 | *********** 17 | 18 | 1. 修正了使用不同编码的python的自动完成。 19 | 2. 修正了qcode提示的混乱代码。 20 | 3. 修正了对错误的qrunes标签(@settings、@qcode和@script)的验证。 21 | 22 | 0.1.2 - 2019-04-24 23 | ------------------------- 24 | add 25 | ******* 26 | 27 | 1. 增加了WebView命令来展示结果窗口。 28 | 29 | update 30 | *********** 31 | 32 | 1. 删除vscode.previewhtml命令。 33 | 2. 修复了@settings部分的验证。 34 | 35 | 0.1.3 - 2019-05-09 36 | ------------------------- 37 | update 38 | *********** 39 | 40 | 1. 修改pyqpanda包指定版本。 41 | 42 | 0.1.4 - 2019-08-27 43 | ------------------------- 44 | 45 | add 46 | ******* 47 | 48 | 1. 增加了定义跳转功能。 49 | 2. 增加了终端调用功能。 50 | 3. 增加了支持while循环。 51 | 4. 增加了逻辑门dagger、control操作。 52 | 53 | update 54 | *********** 55 | 56 | 1. 修改语法规则。 57 | 58 | 0.1.5 - 2020-06-30 59 | ------------------------- 60 | 61 | add 62 | ******* 63 | 64 | 1. 增加了消除qif和qwhile转换功能。 65 | 66 | update 67 | *********** 68 | 69 | 1. 修改变量命名语法。 70 | 71 | 0.1.6 - 2020-08-28 72 | ------------------------- 73 | 74 | add 75 | ******* 76 | 77 | 1. 增加了模拟器。 78 | 2. 增加了真实芯片。 79 | 3. 增加了自定义拓扑结构。 80 | 4. 增加了语法验证。 -------------------------------------------------------------------------------- /docs/source/functionDetail.rst: -------------------------------------------------------------------------------- 1 | 功能介绍 2 | ============= 3 | 4 | 相信在快速入门步骤之后,您已大体了解插件的整体功能,下面将介绍您在编辑量子程序过程中插件提供的辅助功能: 5 | 6 | 1. 自动补全 7 | ------------- 8 | 9 | 对于 QRunes2 语言内设的关键字可以智能提示,根据输入的字符列为您提供当前上下文中适用的最相关符号列表并提示其功能, 10 | 以便您可以更快地选择。 11 | 12 | .. image:: ../images/autoComplete.gif 13 | 14 | 2. 验证提示 15 | ------------- 16 | 17 | 对于输入进行验证并提示。每当插件检测到您编写的代码发生语法错误时,编辑器中会显示红色波浪线, 18 | 鼠标放上去可看到一系列错误信息,您可以准确定位错误发生的位置。 19 | 20 | .. image:: ../images/validation.gif 21 | 22 | 3. 高亮展示 23 | ------------- 24 | 25 | 不同的模块有不同的颜色划分,您可以清晰地编写每一个模块的代码,一目了然,快速开发。 26 | 27 | .. image:: ../images/highlight.png 28 | :width: 600px 29 | 30 | 4. 悬浮提示 31 | ------------- 32 | 33 | QRunes2 语言中的方法、变量都有详细的解释及用法。每当您编写 QRunes2 语言内设关键字时, 34 | 将鼠标放在该关键字上,编辑器将会显示该关键字的功能信息。 35 | 36 | .. image:: ../images/hover.gif 37 | 38 | 5. 智能片段 39 | ------------- 40 | 41 | 智能片段功能是指用户输入简短的触发指令而生成完整的代码片段,在本插件中内置了自定义代码片段, 42 | 可帮助您整理一些重复性代码,提高开发效率。 43 | 44 | .. image:: ../images/snippet.gif 45 | 46 | 插件支持的片段有: 47 | 48 | =============== =========================================================== 49 | 片段 简介 50 | =============== =========================================================== 51 | @settings4py 宿主语言为 Python 时的 settings 模块片段 52 | @settings4cpp 宿主语言为 Cpp 时的 settings 模块片段 53 | @qco qcodes 模块片段 54 | @script4py 宿主语言为 Python 时的 script 模块片段 55 | @script4cpp 宿主语言为 Cpp 时的 script 模块片段 56 | @sqs4py 宿主语言为 Python 时的三个模块片段 57 | @sqs4cpp 宿主语言为 Cpp 时的三个模块片段 58 | quanmac 宿主语言为 Python 时 init_quantum_machine 方法参数 59 | =============== =========================================================== 60 | 61 | 6. 语言切换 62 | ------------- 63 | 64 | 目前 QRunes2 语言可以支持 Python 及 C++ 宿主语言,您可以在 settings 模块的 language 关键字来设置 65 | 所需支持的语言类型,就可以在script模块编写相应语言的代码。 66 | 67 | .. image:: ../images/languageChange.gif 68 | 69 | 7. 定义跳转 70 | ------------- 71 | 72 | 定义跳转功能是指:在qcodes部分快速定位所调用的方法。 73 | 74 | .. image:: ../images/Jump_definition.gif 75 | 76 | 8. 编译运行 77 | ------------- 78 | 79 | 运行 QRunes2 语言代码,编译器会根据设定的语言去编译该代码,从而实现不同的语言编写生成相同的结构。 80 | 81 | .. image:: ../images/run.gif -------------------------------------------------------------------------------- /docs/source/prerequisites.rst: -------------------------------------------------------------------------------- 1 | 准备工作 2 | ============== 3 | 4 | 使用 qurator-vscode 插件之前需要做一些准备工作,以确保量子程序能够正确的运行。 5 | 6 | 需要依赖的运行环境有: 7 | 8 | * Python (版本 3.5以上版本) 9 | * Pip (版本 9.0 及以上) 10 | * MinGw-w64 (Windows 64位版本) 11 | 12 | 其中,pip 负责下载宿主语言为 Python 时程序运行所依赖的包。MinGw-w64 是宿主语言为 C++ 时程序运行所依赖的包。 13 | 14 | 1. 安装插件 15 | ------------- 16 | 17 | 首先需要您安装 `VS Code `_ ,然后打开 VS Code 安装 qurator-vscode 插件: 18 | 使用 Ctrl + Shift + X 快捷键打开插件页面,或者您可以在最左侧栏找到 Extensions 点击进入,然后输入 qurator-vscode 来搜索插件,点击 Install 按钮进行插件的安装。 19 | 20 | .. image:: ../images/extension.png 21 | 22 | 2. 检测运行环境 23 | ---------------- 24 | 25 | 插件安装好之后,您可以创建以 .qrunes 结尾的文件,此时插件会自动检测是否存在程序运行所依赖的环境。您也可以自己检测程序运行环境,使用 Ctrl + Shift + P 快捷键打开 VS Code 命令行, 26 | 输入 qurator-vscode 时您可以看到 qurator-vscode: Check Qurator VSCode Extension dependencies 选择项,点击此项就可以进行运行环境的检测。 27 | 28 | .. image:: ../images/checkDependencies.png 29 | 30 | 检测到运行时所需环境,会在右下角展示软件及版本号: 31 | 32 | .. image:: ../images/checkSuccess.png -------------------------------------------------------------------------------- /icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/qurator-vscode/ddb73d09b6e4700cd45c9dcabd09ea3c2c432713/icon.png -------------------------------------------------------------------------------- /index.md: -------------------------------------------------------------------------------- 1 | last 0.1.3 -------------------------------------------------------------------------------- /qrunes-configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "comments": { 3 | }, 4 | "brackets": [ 5 | ["{", "}"], 6 | ["[", "]"], 7 | ["(", ")"] 8 | ], 9 | "autoClosingPairs": [ 10 | { "open": "{", "close": "}" }, 11 | { "open": "[", "close": "]" }, 12 | { "open": "(", "close": ")" }, 13 | { "open": "@", "close": ":" }, 14 | { "open": "\"", "close": "\"" }, 15 | { "open": "'", "close": "'" }, 16 | { "open": "/**", "close": " */", "notIn": [ "string" ] } 17 | ], 18 | "surroundingPairs": [ 19 | ["{", "}"], 20 | ["[", "]"], 21 | ["(", ")"], 22 | ["@", ":"], 23 | ["\"", "\""], 24 | ["'", "'"] 25 | ] 26 | } -------------------------------------------------------------------------------- /server/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "qurator-vscode", 3 | "description": "A general purpose quantum programming language.", 4 | "version": "0.1.0", 5 | "author": "Qurator", 6 | "engines": { 7 | "vscode": "^1.27.0" 8 | }, 9 | "scripts": {}, 10 | "dependencies": { 11 | "vscode-languageserver": "^5.1.0", 12 | "vscode-languageserver-types": "^3.13.0", 13 | "vscode-nls": "^4.0.0", 14 | "antlr4-c3": "^1.1.7" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /server/qcodeSDK.json: -------------------------------------------------------------------------------- 1 | { 2 | "classes": [{ 3 | "name": "qvec", 4 | "detail": "Vector of qubits.", 5 | "documentation": "Vector of qubits.", 6 | "arguments": [{ 7 | }], 8 | "methods": [{ 9 | "name": "insert", 10 | "type": "boolean", 11 | "detail": "insert method", 12 | "documentation": "insert method", 13 | "arguments": [{ 14 | "name": "qubits", 15 | "type": "qubits" 16 | }] 17 | }, 18 | { 19 | "name": "push_back", 20 | "type": "boolean", 21 | "detail": "add qubits", 22 | "documentation": "add qubits", 23 | "arguments": [{ 24 | "name": "qubits", 25 | "type": "qubits" 26 | }] 27 | } 28 | ] 29 | }, 30 | { 31 | "name": "qgate", 32 | "detail": "Quantum gate.", 33 | "documentation": "Quantum gate.", 34 | "arguments": [{ 35 | }], 36 | "methods": [{ 37 | "name": "control", 38 | "type": "boolean", 39 | "detail": "set control", 40 | "documentation": "set control", 41 | "arguments": [{ 42 | "name": "qvec", 43 | "type": "qvec" 44 | }] 45 | } 46 | ] 47 | }] 48 | } -------------------------------------------------------------------------------- /server/src/qrunesModes/embeddedModeImpl/commonCompiler/symbols.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | 5 | 'use strict'; 6 | 7 | export interface Type { 8 | getName(): string; 9 | } 10 | 11 | export class Symbol implements Type { 12 | name: string; 13 | data: any; 14 | type: Type; 15 | 16 | constructor(name: string, type: Type) { 17 | this.name = name; 18 | this.type = type; 19 | } 20 | 21 | getName(): string { 22 | return this.name; 23 | } 24 | 25 | isType(theType: string): boolean { 26 | return this.type.getName() === theType; 27 | } 28 | } 29 | 30 | export class BuiltInTypeSymbol extends Symbol implements Type { 31 | constructor(name: string) { 32 | super(name, null); 33 | } 34 | 35 | getName(): string { 36 | return this.name; 37 | } 38 | 39 | toString(): string { 40 | return `{ name: ${this.getName()} }`; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /server/src/qrunesModes/embeddedModeImpl/commonCompiler/types.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | 5 | 'use strict'; 6 | 7 | import { Symbol } from './symbols'; 8 | import { Scope } from './scope'; 9 | 10 | export interface SymbolTable { 11 | /** Pointer to the current scope at the symbol table. */ 12 | currentScope: Scope; 13 | currentScopes: Scope[]; 14 | 15 | /** Searches the given symbol name at the root scope, if a line number is specified searches for a scope 16 | * containing that symbol. 17 | */ 18 | lookup(symbolName: string, line?: number): Symbol; 19 | 20 | /** Searches the given symbol name at the current scopes. 21 | */ 22 | lookupList(scope:Scope, symbolName: string, line?: number): Symbol; 23 | 24 | /** Searches the given symbol name at the current scopes to root scope. 25 | */ 26 | lookupToRoot(scope:Scope, symbolName: string, line?: number): Symbol; 27 | 28 | /** Stores the given symbol with the line where it was declared for first time. */ 29 | define(symbol: Symbol, declarationLine: number): void; 30 | 31 | /** Stores the given symbol with the line into scopes where it was declared for first time. */ 32 | defineList(scope: Scope, symbol: Symbol, declarationLine: number): void; 33 | 34 | /** Adds a new scope to the current scope. */ 35 | push(scopeName: string, startLine: number, endLine: number): void; 36 | 37 | /** Adds a new scope to the current scopes. */ 38 | pushList(scope: Scope): void; 39 | 40 | /** Update scope the endLine */ 41 | update(endLine: number): void; 42 | 43 | /** Returns to the parent scope closing the current one. */ 44 | pop(line: number): void; 45 | 46 | /** Returns a list of the USER DEFINED symbols for the current scope and its parents. */ 47 | currentSymbols(): Symbol[]; 48 | 49 | /** Merge into the global scope the symbols at the given scope. */ 50 | mergeWith(scope: Scope): void; 51 | 52 | print(): void; 53 | } 54 | -------------------------------------------------------------------------------- /server/src/qrunesModes/embeddedModeImpl/commonCompiler/variableDefinition.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | 5 | 'use strict'; 6 | 7 | import { Symbol } from './symbols'; 8 | 9 | export class VariableDefinition { 10 | constructor(public symbol: Symbol, public startLine: number, public endLine: number) {} 11 | 12 | nameEquals(name: string): boolean { 13 | return this.symbol.name === name; 14 | } 15 | 16 | inScope(line: number): boolean { 17 | return line >= this.startLine && line <= this.endLine; 18 | } 19 | 20 | toString() { 21 | return `{ ${this.symbol} from: ${this.startLine} to: ${this.endLine} }`; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /server/src/qrunesModes/embeddedModeImpl/cpp/ast/treeFolder.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import { AbstractParseTreeVisitor, TerminalNode } from 'antlr4ts/tree'; 4 | import { Block, CodeBlock } from './types'; 5 | import { CPP14Visitor } from '../antlr/CPP14Visitor'; 6 | 7 | export class TreeFolder extends AbstractParseTreeVisitor implements CPP14Visitor { 8 | defaultResult(): Block { 9 | return new CodeBlock(); 10 | } 11 | } -------------------------------------------------------------------------------- /server/src/qrunesModes/embeddedModeImpl/cpp/parser.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | 5 | 'use strict'; 6 | 7 | import { ANTLRInputStream, CommonTokenStream, ConsoleErrorListener } from 'antlr4ts'; 8 | import { Parser, ParserResult } from '../types'; 9 | import { CPP14Parser } from './antlr/CPP14Parser'; 10 | import { CPP14Lexer } from './antlr/CPP14Lexer'; 11 | import { ErrorListener } from '../tools/errorListener'; 12 | 13 | export class CppParser implements Parser { 14 | parse(input: string): ParserResult { 15 | let errorListener = new ErrorListener(); 16 | let parser = this.buildCppParser(input, errorListener); 17 | 18 | let tree = parser.translationunit(); 19 | return { 20 | ast: tree, 21 | errors: errorListener.errors 22 | }; 23 | } 24 | 25 | private buildCppParser(input: string, errorListener: ErrorListener): CPP14Parser { 26 | let inputStream = new ANTLRInputStream(input); 27 | let lexer = new CPP14Lexer(inputStream); 28 | lexer.removeErrorListener(ConsoleErrorListener.INSTANCE); 29 | 30 | let tokenStream = new CommonTokenStream(lexer); 31 | let parser = new CPP14Parser(tokenStream); 32 | parser.addErrorListener(errorListener); 33 | 34 | return parser; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /server/src/qrunesModes/embeddedModeImpl/cpp/suggestions/methodsDictionary.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | 5 | 'use strict'; 6 | 7 | import { SuggestionSymbol } from '../../types'; 8 | import { SuggestionsDictionary } from './suggestionsDictionary'; 9 | 10 | export class MethodsDictionary { 11 | constructor( 12 | private suggestionsDictionary: SuggestionsDictionary 13 | ) {} 14 | 15 | currentMethods(): SuggestionSymbol[] { 16 | return this.suggestionsDictionary.allMethods(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /server/src/qrunesModes/embeddedModeImpl/cpp/suggestions/suggestionsCalculator.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | 5 | 'use strict'; 6 | 7 | import { SuggestionSymbol } from '../../types'; 8 | import { CodeCompletionCore } from 'antlr4-c3'; 9 | import { MethodsDictionary } from './methodsDictionary'; 10 | import { CPP14Parser } from '../antlr/CPP14Parser'; 11 | 12 | export class SuggestionsCalculator { 13 | constructor( 14 | private parser: CPP14Parser, 15 | private methodsDictionary: MethodsDictionary 16 | ) {} 17 | 18 | calculateAtPosition(tokenPosition: number): SuggestionSymbol[] { 19 | let core = new CodeCompletionCore(this.parser); 20 | core.ignoredTokens = GrammarElements.ignorableTokens(); 21 | 22 | let candidates = core.collectCandidates(tokenPosition); 23 | 24 | let allowedSymbols: string[] = []; 25 | for (let candidate of candidates.tokens) { 26 | let terminal = this.parser.vocabulary.getSymbolicName(candidate[0]); 27 | allowedSymbols.push(terminal); 28 | } 29 | 30 | for (let candidate of candidates.rules) { 31 | let rule = this.parser.ruleNames[candidate[0]]; 32 | allowedSymbols.push(rule); 33 | } 34 | 35 | let result: SuggestionSymbol[] = this.calculateSuggestions(allowedSymbols); 36 | 37 | return result; 38 | } 39 | 40 | private calculateSuggestions(allowedSymbols: string[]): SuggestionSymbol[] { 41 | let result: SuggestionSymbol[] = []; 42 | result.push(...this.methodsDictionary.currentMethods()); 43 | 44 | return result; 45 | } 46 | } 47 | 48 | namespace GrammarElements { 49 | export function ignorableTokens(): Set { 50 | return new Set([ 51 | CPP14Parser.EOF 52 | ]); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /server/src/qrunesModes/embeddedModeImpl/cpp/suggestions/suggestionsDictionary.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | 5 | 'use strict'; 6 | 7 | import { SuggestionSymbol } from '../../types'; 8 | 9 | export class SuggestionsDictionary { 10 | allSymbols(): SuggestionSymbol[] { 11 | return this.getSymbols(); 12 | } 13 | 14 | symbolsWithTypeIn(types: string[]): SuggestionSymbol[] { 15 | let isContainedInTypes = (symbol: SuggestionSymbol) => types.indexOf(symbol.type) > -1; 16 | 17 | return this.getSymbols().filter(isContainedInTypes); 18 | } 19 | 20 | allMethods(): SuggestionSymbol[] { 21 | return this.symbolsWithTypeIn(['method']); 22 | } 23 | 24 | private getSymbols(): SuggestionSymbol[] { 25 | const QPandaSymbols: QPandaSDK = require('../../../../QPandaSDK.json'); 26 | let symbols: SuggestionSymbol[] = []; 27 | QPandaSymbols.methods.forEach(qmethod => { 28 | symbols.push({ 29 | label: qmethod.name, 30 | detail: qmethod.detail, 31 | documentation: qmethod.documentation, 32 | type: 'method', 33 | parent: qmethod.name, 34 | data: qmethod.data 35 | }); 36 | }); 37 | return symbols; 38 | } 39 | } 40 | 41 | interface QPandaSDK { 42 | methods: QPandaMethod[]; 43 | } 44 | 45 | interface QPandaMethod { 46 | name: string; 47 | type: string; 48 | detail: string; 49 | documentation: string; 50 | arguments: QPandaArgument[]; 51 | data: any; 52 | } 53 | 54 | interface QPandaArgument { 55 | name: string; 56 | type: string; 57 | } 58 | -------------------------------------------------------------------------------- /server/src/qrunesModes/embeddedModeImpl/python/ast/importsAnalyzer.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | 5 | import { ParserRuleContext } from 'antlr4ts'; 6 | import { AbstractParseTreeVisitor } from 'antlr4ts/tree'; 7 | import { Python3Visitor } from '../antlr/Python3Visitor'; 8 | import { Import_as_nameContext } from '../antlr/Python3Parser'; 9 | import { ErrorListener } from '../../tools/errorListener'; 10 | 11 | export namespace ImportsAnalyzer { 12 | export function analyze(tree: ParserRuleContext, errorListener: ErrorListener) { 13 | let validator = new ImportsValidator(errorListener); 14 | tree.accept(validator); 15 | } 16 | } 17 | 18 | class ImportsValidator extends AbstractParseTreeVisitor implements Python3Visitor { 19 | imported: string[] = []; 20 | 21 | constructor(private errorListener: ErrorListener) { 22 | super(); 23 | } 24 | 25 | defaultResult() {} 26 | 27 | visitImport_as_name(ctx: Import_as_nameContext) { 28 | this.imported.push(ctx.text); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /server/src/qrunesModes/embeddedModeImpl/python/ast/tools/errorBuilder.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | 5 | import { VisitableItem } from '../types'; 6 | import { ParserError, ParseErrorLevel } from '../../../types'; 7 | 8 | export namespace ErrorBuilder { 9 | export function warning(message: string, item: VisitableItem): ParserError { 10 | return { 11 | line: item.start.line, 12 | start: item.start.column, 13 | end: item.end.column, 14 | message, 15 | level: ParseErrorLevel.WARNING 16 | }; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /server/src/qrunesModes/embeddedModeImpl/python/compiler/qpandaSymbolTableBuilder.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | 5 | 'use strict'; 6 | 7 | import { Scope } from '../../commonCompiler/scope'; 8 | import { PyQpandaSymbols, ArgumentSymbol, MethodSymbol } from './symbols'; 9 | import { PyQpandaSDK, PyQpandaArgument } from '../libs/pyQpandaSDK'; 10 | import { SymbolTable } from '../../commonCompiler/types'; 11 | import { BuiltInTypeSymbol } from '../../commonCompiler/symbols'; 12 | import { MultiScopeSymbolTable } from '../../commonCompiler/multiScopeSymbolTable'; 13 | 14 | export namespace PyQpandaSymbolTableBuilder { 15 | export function create(): SymbolTable { 16 | let scope = new Scope(null, 'global'); 17 | 18 | scope.define(new BuiltInTypeSymbol(PyQpandaSymbols.void), 0); 19 | scope.define(new BuiltInTypeSymbol(PyQpandaSymbols.object), 0); 20 | scope.define(new BuiltInTypeSymbol(PyQpandaSymbols.string), 0); 21 | scope.define(new BuiltInTypeSymbol(PyQpandaSymbols.number), 0); 22 | scope.define(new BuiltInTypeSymbol(PyQpandaSymbols.boolean), 0); 23 | scope.define(new BuiltInTypeSymbol(PyQpandaSymbols.dictionary), 0); 24 | scope.define(new BuiltInTypeSymbol(PyQpandaSymbols.method), 0); 25 | 26 | loadPyQpandaSymbolsAt(scope); 27 | 28 | return new MultiScopeSymbolTable(scope); 29 | } 30 | 31 | function loadPyQpandaSymbolsAt(scope: Scope): void { 32 | PyQpandaSDK.methods().forEach(methods => { 33 | let type = scope.lookup(PyQpandaSymbols.method); 34 | let requiredArguments = getArgumentsSymbols(methods.arguments, scope); 35 | let methodSymbol = new MethodSymbol(methods.name, type, requiredArguments) 36 | 37 | scope.define(methodSymbol, 0); 38 | }); 39 | } 40 | 41 | function getArgumentsSymbols(qarguments: PyQpandaArgument[] | undefined, scope: Scope): ArgumentSymbol[] { 42 | if (qarguments === undefined) { 43 | return []; 44 | } 45 | 46 | return qarguments.map(qargument => { 47 | let type = scope.lookup(qargument.type) || scope.lookup(PyQpandaSymbols.void); 48 | 49 | return new ArgumentSymbol(qargument.name, type, qargument.optional); 50 | }); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /server/src/qrunesModes/embeddedModeImpl/python/compiler/symbols.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | 5 | 'use strict'; 6 | 7 | import { Symbol, Type } from '../../commonCompiler/symbols'; 8 | 9 | export class MethodSymbol extends Symbol { 10 | arguments: ArgumentSymbol[] = []; 11 | 12 | constructor(name: string, type: Type, requiredArguments: ArgumentSymbol[] = []) { 13 | super(name, type); 14 | this.arguments = requiredArguments; 15 | } 16 | 17 | getArguments(): ArgumentSymbol[] { 18 | return this.arguments; 19 | } 20 | 21 | toString() { 22 | return `{ name: ${this.name}, type: ${this.type.getName()}, arguments: ${this.arguments} }`; 23 | } 24 | } 25 | 26 | export class ArgumentSymbol extends Symbol { 27 | constructor(name: string, type: Type, public optional = false) { 28 | super(name, type); 29 | } 30 | 31 | toString() { 32 | if (this.type === null) { 33 | return `{ name: ${this.name}, type: NULL }`; 34 | } 35 | 36 | return `{ name: ${this.name}, type: ${this.type.getName()} }`; 37 | } 38 | } 39 | 40 | export class VariableSymbol extends Symbol { 41 | metadata: VariableMetadata = null; 42 | 43 | constructor(name: string, type: Type, metadata?: VariableMetadata) { 44 | super(name, type); 45 | 46 | if (metadata && metadata !== null) { 47 | this.metadata = metadata; 48 | } 49 | } 50 | 51 | hasSize(): boolean { 52 | return this.metadata !== null && this.metadata.size !== null; 53 | } 54 | 55 | size(): number { 56 | return this.metadata.size; 57 | } 58 | 59 | toString() { 60 | if (this.type === null) { 61 | return `{ name: ${this.name}, type: NULL }`; 62 | } 63 | 64 | return `{ name: ${this.name}, type: ${this.type.getName()} }`; 65 | } 66 | } 67 | 68 | export interface VariableMetadata { 69 | name?: string; 70 | size?: number; 71 | } 72 | 73 | export enum PyQpandaSymbols { 74 | void = 'void', 75 | object = 'object', 76 | string = 'string', 77 | number = 'number', 78 | boolean = 'boolean', 79 | dictionary = 'dict', 80 | method = 'method' 81 | } 82 | -------------------------------------------------------------------------------- /server/src/qrunesModes/embeddedModeImpl/python/compiler/tools/errorMessages.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | 5 | 'use strict'; 6 | 7 | export namespace ErrorMessages { 8 | export function notPreviouslyImported(expectedImport: string): string { 9 | return `${expectedImport} must be previously imported.`; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /server/src/qrunesModes/embeddedModeImpl/python/libs/PyQpandaSDK.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | 5 | export namespace PyQpandaSDK { 6 | const dictionary: any = require('../../../../../pyQpandaSDK.json'); 7 | 8 | export function methods(): PyQpandaMethods[] { 9 | return dictionary.methods; 10 | } 11 | 12 | } 13 | 14 | export interface PyQpandaMethods { 15 | name: string; 16 | type: string; 17 | detail: string; 18 | documentation: string; 19 | arguments?: PyQpandaArgument[]; 20 | } 21 | 22 | export interface PyQpandaArgument { 23 | name: string; 24 | type: string; 25 | optional?: boolean; 26 | } 27 | -------------------------------------------------------------------------------- /server/src/qrunesModes/embeddedModeImpl/python/parser.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This ts file provides the parser function of pyqpanda. 3 | */ 4 | 5 | 'use strict'; 6 | 7 | import { ANTLRInputStream, CommonTokenStream, ConsoleErrorListener } from 'antlr4ts'; 8 | import { Parser, ParserResult } from '../types'; 9 | import { Python3Parser } from './antlr/Python3Parser'; 10 | import { Python3Lexer } from './antlr/Python3Lexer'; 11 | import { TreeFolder } from './ast/treeFolder'; 12 | import { SymbolTableGenerator } from './ast/symbolTableGenerator'; 13 | import { SemanticAnalyzer } from './ast/semanticAnalyzer'; 14 | import { ImportsAnalyzer } from './ast/importsAnalyzer'; 15 | import { ErrorListener } from '../tools/errorListener'; 16 | 17 | export class PythonParser implements Parser { 18 | parse(input: string): ParserResult { 19 | let errorListener = new ErrorListener(); 20 | let parser = this.buildPyQpandaParser(input, errorListener); 21 | 22 | let tree = parser.program(); 23 | let folder = new TreeFolder(); 24 | let codeBlock = folder.visit(tree); 25 | let symbolTable = SymbolTableGenerator.symbolTableFor(codeBlock); 26 | let errors = SemanticAnalyzer.analyze(codeBlock, symbolTable); 27 | ImportsAnalyzer.analyze(tree, errorListener); 28 | 29 | return { 30 | ast: tree, 31 | errors: errorListener.errors.concat(errors) 32 | }; 33 | } 34 | 35 | private buildPyQpandaParser(input: string, errorListener: ErrorListener): Python3Parser { 36 | let inputStream = new ANTLRInputStream(input); 37 | let lexer = new Python3Lexer(inputStream); 38 | lexer.removeErrorListener(ConsoleErrorListener.INSTANCE); 39 | 40 | let tokenStream = new CommonTokenStream(lexer); 41 | let parser = new Python3Parser(tokenStream); 42 | parser.addErrorListener(errorListener); 43 | 44 | return parser; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /server/src/qrunesModes/embeddedModeImpl/python/suggestions/methodsDictionary.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | 5 | 'use strict'; 6 | 7 | import { SuggestionSymbol } from '../../types'; 8 | import { SuggestionsDictionary } from './suggestionsDictionary'; 9 | 10 | export class MethodsDictionary { 11 | constructor( 12 | private suggestionsDictionary: SuggestionsDictionary 13 | ) {} 14 | 15 | currentMethods(): SuggestionSymbol[] { 16 | return this.suggestionsDictionary.allMethods(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /server/src/qrunesModes/embeddedModeImpl/python/suggestions/suggestionsDictionary.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | 5 | 'use strict'; 6 | 7 | import { SuggestionSymbol } from '../../types'; 8 | 9 | export class SuggestionsDictionary { 10 | allSymbols(): SuggestionSymbol[] { 11 | return this.getSymbols(); 12 | } 13 | 14 | symbolsWithTypeIn(types: string[]): SuggestionSymbol[] { 15 | let isContainedInTypes = (symbol: SuggestionSymbol) => types.indexOf(symbol.type) > -1; 16 | 17 | return this.getSymbols().filter(isContainedInTypes); 18 | } 19 | 20 | methodsIn(names: string[]): SuggestionSymbol[] { 21 | return this.symbolsWithTypeIn(['method']).filter(symbol => names.includes(symbol.label)); 22 | } 23 | 24 | allMethods(): SuggestionSymbol[] { 25 | return this.symbolsWithTypeIn(['method']); 26 | } 27 | 28 | private getSymbols(): SuggestionSymbol[] { 29 | const pyqpandaSymbols: PyQpandaSDK = require('../../../../../pyQpandaSDK.json'); 30 | let symbols: SuggestionSymbol[] = []; 31 | 32 | pyqpandaSymbols.methods.map(qmethod => { 33 | symbols.push({ 34 | label: qmethod.name, 35 | detail: qmethod.detail, 36 | documentation: qmethod.documentation, 37 | type: 'method', 38 | parent: qmethod.name, 39 | data: qmethod.data 40 | }); 41 | }); 42 | 43 | return symbols; 44 | } 45 | } 46 | 47 | interface PyQpandaSDK { 48 | methods: PyQpandaMethod[]; 49 | } 50 | 51 | interface PyQpandaMethod { 52 | name: string; 53 | type: string; 54 | detail: string; 55 | documentation: string; 56 | arguments: PyQpandaArgument[]; 57 | data: any; 58 | } 59 | 60 | interface PyQpandaArgument { 61 | name: string; 62 | type: string; 63 | } 64 | -------------------------------------------------------------------------------- /server/src/qrunesModes/embeddedModeImpl/qcodes/compiler/qcodesSyntacticParser.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This ts file provides the parser of qcodes. 3 | */ 4 | 5 | 'use strict'; 6 | 7 | import { 8 | ParserRuleContext, 9 | ANTLRInputStream, 10 | CommonTokenStream, 11 | ANTLRErrorListener, 12 | CommonToken, 13 | ConsoleErrorListener 14 | } from 'antlr4ts'; 15 | import { qcodeLexer } from '../antlr/qcodeLexer'; 16 | import { qcodeParser } from '../antlr/qcodeParser'; 17 | 18 | export namespace QcodesSyntacticParser { 19 | export function parse(input: string): ParserRuleContext { 20 | let inputStream = new ANTLRInputStream(input); 21 | let lexer = new qcodeLexer(inputStream); 22 | 23 | let tokenStream = new CommonTokenStream(lexer); 24 | let parser = new qcodeParser(tokenStream); 25 | 26 | return parser.qrunes(); 27 | } 28 | 29 | export function parseWithErrorListener( 30 | input: string, 31 | errorListener: ANTLRErrorListener 32 | ): ParserRuleContext { 33 | let inputStream = new ANTLRInputStream(input); 34 | let lexer = new qcodeLexer(inputStream); 35 | lexer.removeErrorListener(ConsoleErrorListener.INSTANCE); 36 | 37 | let tokenStream = new CommonTokenStream(lexer); 38 | let parser = new qcodeParser(tokenStream); 39 | parser.addErrorListener(errorListener); 40 | 41 | return parser.qrunes(); 42 | } 43 | 44 | export function ruleNames(): string[] { 45 | return qcodeParser.ruleNames; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /server/src/qrunesModes/embeddedModeImpl/qcodes/compiler/tools/errorMessages.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This ts file defines the error messages of qcodes validation. 3 | */ 4 | 5 | 'use strict'; 6 | 7 | export namespace ErrorMessages { 8 | export function symbolNotPreviouslyDefined(name: string): string { 9 | return `Symbol ${name} is not previously defined.`; 10 | } 11 | 12 | export function symbolPreviousDefinitionOf(name: string): string { 13 | return `Symbol ${name} is previously defined.`; 14 | } 15 | 16 | export function symbolNotPreviousTypeDefinitionOf(name: string, type: string): string { 17 | return `The type of Symbol ${name} is not ${type}.`; 18 | } 19 | 20 | export function ArrayNotPreviouslyDefined(name: string): string { 21 | return `Array ${name} is not previously defined.`; 22 | } 23 | 24 | export function ArrayindexOutOfBound(name: string): string { 25 | return `Array ${name} is out of bounds.`; 26 | } 27 | 28 | export function functionNotFound(name: string): string { 29 | return `Function ${name} is not found.`; 30 | } 31 | 32 | export function functionNotDefined(name: string): string { 33 | return `Function ${name} is not defined.`; 34 | } 35 | 36 | export function functionPreviousDefinitionOf(name: string): string { 37 | return `Function ${name} is previously defined.`; 38 | } 39 | 40 | export function functionArgsNumber(name: string, num: string): string { 41 | return `The number of parameter is not ${num}.`; 42 | } 43 | 44 | export function functionArgsType(name: string): string { 45 | return `The type of parameter is not ${name}.`; 46 | } 47 | 48 | export function functionNoArgs(name: string): string { 49 | return `${name} function's parameters cannot be empty.`; 50 | } 51 | 52 | export function definationPreviousDefinitionOf(name: string): string { 53 | return `Function defination ${name} is previously defined.`; 54 | } 55 | 56 | export function missingSymbol(name: string): string { 57 | return `The ${name} is missing.`; 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /server/src/qrunesModes/embeddedModeImpl/qcodes/compiler/types.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This ts file defines the result interface of symbol table. 3 | */ 4 | 5 | 'use strict'; 6 | 7 | import { ParserError } from '../../types'; 8 | import { SymbolTable } from '../../commonCompiler/types'; 9 | 10 | export interface SymbolTableResult { 11 | symbolTable: SymbolTable; 12 | errors: ParserError[]; 13 | } 14 | -------------------------------------------------------------------------------- /server/src/qrunesModes/embeddedModeImpl/qcodes/libs/qcodeSDK.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | export namespace QCodeSDK { 4 | const dictionary: any = require('./../../../../qcodeSDK.json'); 5 | 6 | export function classes(): QCodeClass[] { 7 | return dictionary.classes; 8 | } 9 | 10 | export function containsClass(className: string): boolean { 11 | return classes().some(theClass => theClass.name === className); 12 | } 13 | } 14 | 15 | export interface QCodeClass { 16 | name: string; 17 | detail: string; 18 | documentation: string; 19 | arguments?: QCodeArgument[]; 20 | methods: QCodeMethod[]; 21 | } 22 | 23 | export interface QCodeMethod { 24 | name: string; 25 | type: string; 26 | detail: string; 27 | documentation: string; 28 | arguments?: QCodeArgument[]; 29 | } 30 | 31 | export interface QCodeArgument { 32 | name: string; 33 | type: string; 34 | optional?: boolean; 35 | } 36 | -------------------------------------------------------------------------------- /server/src/qrunesModes/embeddedModeImpl/qcodes/parser.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This ts file provides qcodes mode parser function. 3 | */ 4 | 5 | 'use strict'; 6 | 7 | import { Parser, ParserResult } from '../types'; 8 | import { SymbolTableGenerator } from './compiler/symbolTableGenerator'; 9 | import { SemanticAnalyzer } from './compiler/semanticAnalyzer'; 10 | import { QcodesSyntacticParser } from './compiler/qcodesSyntacticParser'; 11 | import { ErrorListener } from '../tools/errorListener'; 12 | 13 | export class QcodesParser implements Parser { 14 | parse(input: string): ParserResult { 15 | let errorListener = new ErrorListener(); 16 | 17 | let tree = QcodesSyntacticParser.parseWithErrorListener(input, errorListener); 18 | let symbolTable = SymbolTableGenerator.symbolTableFor(tree, errorListener); 19 | SemanticAnalyzer.analyze(tree, symbolTable, errorListener); 20 | 21 | return { 22 | ast: tree, 23 | errors: errorListener.errors 24 | }; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /server/src/qrunesModes/embeddedModeImpl/qcodes/suggestions/methodsDictionary.ts: -------------------------------------------------------------------------------- 1 | 2 | 'use strict'; 3 | 4 | import { SuggestionSymbol, SuggestionSymbolType } from '../../types'; 5 | import { AtomFinder } from './atomFinder'; 6 | import { CommonTokenStream } from 'antlr4ts'; 7 | import { SuggestionsDictionary } from './suggestionsDictionary'; 8 | import { dataTypeSymbols } from '../compiler/symbolTable'; 9 | 10 | export class MethodsDictionary { 11 | constructor( 12 | private atomFinder: AtomFinder, 13 | private tokenStream: CommonTokenStream, 14 | private suggestionsDictionary: SuggestionsDictionary 15 | ) {} 16 | 17 | currentMethods(): SuggestionSymbol[] { 18 | let atom = this.atomFinder.firstViableAtomFor(this.tokenStream); 19 | if (atom !== null && atom.type.getName() in dataTypeSymbols) { 20 | return this.suggestionsDictionary 21 | .allMethods() 22 | .filter(suggestion => suggestion.parent === atom.type.getName()) 23 | .filter(suggestion => suggestion.type === SuggestionSymbolType.method); 24 | } else { 25 | return this.suggestionsDictionary.allMethods(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /server/src/qrunesModes/embeddedModeImpl/settings/antlr/.antlr/setting.interp: -------------------------------------------------------------------------------- 1 | token literal names: 2 | null 3 | 'language' 4 | 'autoimport' 5 | 'compile_only' 6 | '=' 7 | ';' 8 | null 9 | null 10 | null 11 | null 12 | 13 | token symbolic names: 14 | null 15 | LANGUAGE 16 | AUTOIMPORT 17 | COMPILE_ONLY 18 | EQUAL 19 | SEMI 20 | Identifier 21 | WhiteSpace 22 | SingleLineComment 23 | MultiLinesComment 24 | 25 | rule names: 26 | qsetting 27 | qConfig 28 | auto_import 29 | lan_set 30 | compile_only 31 | ischoosed 32 | lan_type 33 | 34 | 35 | atn: 36 | [3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 11, 47, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 3, 2, 7, 2, 18, 10, 2, 12, 2, 14, 2, 21, 11, 2, 3, 3, 3, 3, 3, 3, 5, 3, 26, 10, 3, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 7, 3, 7, 3, 8, 3, 8, 3, 8, 2, 2, 9, 2, 4, 6, 8, 10, 12, 14, 2, 2, 2, 42, 2, 19, 3, 2, 2, 2, 4, 25, 3, 2, 2, 2, 6, 27, 3, 2, 2, 2, 8, 32, 3, 2, 2, 2, 10, 37, 3, 2, 2, 2, 12, 42, 3, 2, 2, 2, 14, 44, 3, 2, 2, 2, 16, 18, 5, 4, 3, 2, 17, 16, 3, 2, 2, 2, 18, 21, 3, 2, 2, 2, 19, 17, 3, 2, 2, 2, 19, 20, 3, 2, 2, 2, 20, 3, 3, 2, 2, 2, 21, 19, 3, 2, 2, 2, 22, 26, 5, 8, 5, 2, 23, 26, 5, 6, 4, 2, 24, 26, 5, 10, 6, 2, 25, 22, 3, 2, 2, 2, 25, 23, 3, 2, 2, 2, 25, 24, 3, 2, 2, 2, 26, 5, 3, 2, 2, 2, 27, 28, 7, 4, 2, 2, 28, 29, 7, 6, 2, 2, 29, 30, 5, 12, 7, 2, 30, 31, 7, 7, 2, 2, 31, 7, 3, 2, 2, 2, 32, 33, 7, 3, 2, 2, 33, 34, 7, 6, 2, 2, 34, 35, 5, 14, 8, 2, 35, 36, 7, 7, 2, 2, 36, 9, 3, 2, 2, 2, 37, 38, 7, 5, 2, 2, 38, 39, 7, 6, 2, 2, 39, 40, 5, 12, 7, 2, 40, 41, 7, 7, 2, 2, 41, 11, 3, 2, 2, 2, 42, 43, 7, 8, 2, 2, 43, 13, 3, 2, 2, 2, 44, 45, 7, 8, 2, 2, 45, 15, 3, 2, 2, 2, 4, 19, 25] -------------------------------------------------------------------------------- /server/src/qrunesModes/embeddedModeImpl/settings/antlr/.antlr/setting.tokens: -------------------------------------------------------------------------------- 1 | LANGUAGE=1 2 | AUTOIMPORT=2 3 | COMPILE_ONLY=3 4 | EQUAL=4 5 | SEMI=5 6 | Identifier=6 7 | WhiteSpace=7 8 | SingleLineComment=8 9 | MultiLinesComment=9 10 | 'language'=1 11 | 'autoimport'=2 12 | 'compile_only'=3 13 | '='=4 14 | ';'=5 15 | -------------------------------------------------------------------------------- /server/src/qrunesModes/embeddedModeImpl/settings/antlr/.antlr/settingLexer.tokens: -------------------------------------------------------------------------------- 1 | LANGUAGE=1 2 | AUTOIMPORT=2 3 | COMPILE_ONLY=3 4 | EQUAL=4 5 | SEMI=5 6 | Identifier=6 7 | WhiteSpace=7 8 | SingleLineComment=8 9 | MultiLinesComment=9 10 | 'language'=1 11 | 'autoimport'=2 12 | 'compile_only'=3 13 | '='=4 14 | ';'=5 15 | -------------------------------------------------------------------------------- /server/src/qrunesModes/embeddedModeImpl/settings/antlr/setting.g4: -------------------------------------------------------------------------------- 1 | grammar setting; 2 | 3 | qsetting:qConfig*; 4 | 5 | qConfig: lan_set 6 | | auto_import 7 | | compile_only 8 | ; 9 | 10 | auto_import: AUTOIMPORT EQUAL ischoosed SEMI 11 | ; 12 | 13 | lan_set: LANGUAGE EQUAL lan_type SEMI 14 | ; 15 | 16 | compile_only: COMPILE_ONLY EQUAL ischoosed SEMI 17 | ; 18 | 19 | ischoosed: Identifier 20 | ; 21 | 22 | lan_type: Identifier 23 | ; 24 | 25 | //Keyword 26 | LANGUAGE: 'language' 27 | ; 28 | 29 | AUTOIMPORT: 'autoimport' 30 | ; 31 | 32 | COMPILE_ONLY: 'compile_only' 33 | ; 34 | 35 | EQUAL: '=' 36 | ; 37 | 38 | SEMI: ';' 39 | ; 40 | 41 | Identifier: IdentifierNotDigit (IdentifierNotDigit| Operator | Digit)* 42 | ; 43 | 44 | fragment 45 | IdentifierNotDigit : [a-zA-Z_] 46 | ; 47 | 48 | fragment 49 | Digit : [0-9] 50 | ; 51 | 52 | fragment 53 | Operator: '+' 54 | ; 55 | 56 | //WhiteSpace and Comments 57 | WhiteSpace: (' ' | '\r' | '\n' | '\t') -> skip 58 | ; 59 | 60 | SingleLineComment: '//' ~('\n'|'\r')* '\r'? '\n' -> skip 61 | ; 62 | 63 | MultiLinesComment: '/*' (.)*? '*/' -> skip 64 | ; -------------------------------------------------------------------------------- /server/src/qrunesModes/embeddedModeImpl/settings/antlr/setting.tokens: -------------------------------------------------------------------------------- 1 | LANGUAGE=1 2 | AUTOIMPORT=2 3 | COMPILE_ONLY=3 4 | EQUAL=4 5 | SEMI=5 6 | Identifier=6 7 | WhiteSpace=7 8 | SingleLineComment=8 9 | MultiLinesComment=9 10 | 'language'=1 11 | 'autoimport'=2 12 | 'compile_only'=3 13 | '='=4 14 | ';'=5 15 | -------------------------------------------------------------------------------- /server/src/qrunesModes/embeddedModeImpl/settings/antlr/settingLexer.tokens: -------------------------------------------------------------------------------- 1 | LANGUAGE=1 2 | AUTOIMPORT=2 3 | COMPILE_ONLY=3 4 | EQUAL=4 5 | SEMI=5 6 | Identifier=6 7 | WhiteSpace=7 8 | SingleLineComment=8 9 | MultiLinesComment=9 10 | 'language'=1 11 | 'autoimport'=2 12 | 'compile_only'=3 13 | '='=4 14 | ';'=5 15 | -------------------------------------------------------------------------------- /server/src/qrunesModes/embeddedModeImpl/settings/compiler/settingsSyntacticParser.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This ts file provides settings parser, include parse and parse with error listener function. 3 | */ 4 | 'use strict'; 5 | 6 | import { 7 | ParserRuleContext, 8 | ANTLRInputStream, 9 | CommonTokenStream, 10 | ANTLRErrorListener, 11 | CommonToken, 12 | ConsoleErrorListener 13 | } from 'antlr4ts'; 14 | import { settingLexer } from '../antlr/settingLexer'; 15 | import { settingParser } from '../antlr/settingParser'; 16 | 17 | export namespace SettingsSyntacticParser { 18 | export function parse(input: string): ParserRuleContext { 19 | let inputStream = new ANTLRInputStream(input); 20 | let lexer = new settingLexer(inputStream); 21 | 22 | let tokenStream = new CommonTokenStream(lexer); 23 | let parser = new settingParser(tokenStream); 24 | 25 | return parser.qsetting(); 26 | } 27 | 28 | export function parseWithErrorListener( 29 | input: string, 30 | errorListener: ANTLRErrorListener 31 | ): ParserRuleContext { 32 | let inputStream = new ANTLRInputStream(input); 33 | let lexer = new settingLexer(inputStream); 34 | lexer.removeErrorListener(ConsoleErrorListener.INSTANCE); 35 | 36 | let tokenStream = new CommonTokenStream(lexer); 37 | let parser = new settingParser(tokenStream); 38 | parser.addErrorListener(errorListener); 39 | 40 | return parser.qsetting(); 41 | } 42 | 43 | export function ruleNames(): string[] { 44 | return settingParser.ruleNames; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /server/src/qrunesModes/embeddedModeImpl/settings/compiler/symbolTable.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This ts file provides the symbol table of setting 3 | */ 4 | 'use strict'; 5 | 6 | import { SymbolTable } from '../../commonCompiler/types'; 7 | import { Scope } from '../../commonCompiler/scope'; 8 | import { BuiltInTypeSymbol, Symbol, Type } from '../../commonCompiler/symbols'; 9 | import { MultiScopeSymbolTable } from '../../commonCompiler/multiScopeSymbolTable'; 10 | 11 | export namespace SymbolTableBuilder { 12 | export function build(): SymbolTable { 13 | let rootScope = new Scope(null, 'global'); 14 | rootScope.define(new BuiltInTypeSymbol(SettingSymbols.language), 0); 15 | rootScope.define(new BuiltInTypeSymbol(SettingSymbols.autoimport), 0); 16 | rootScope.define(new BuiltInTypeSymbol(SettingSymbols.compile_only), 0); 17 | 18 | return new MultiScopeSymbolTable(rootScope); 19 | } 20 | } 21 | 22 | export class SettingSymbol extends Symbol { 23 | 24 | constructor(name: string, type: Type) { 25 | super(name, type); 26 | } 27 | 28 | toString(): string { 29 | return `{ name: ${this.name}, type: ${this.type} }`; 30 | } 31 | } 32 | 33 | export enum SettingSymbols { 34 | language = 'language', 35 | autoimport = 'autoimport', 36 | compile_only = 'compile_only' 37 | } 38 | -------------------------------------------------------------------------------- /server/src/qrunesModes/embeddedModeImpl/settings/compiler/tools/errorMessages.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This ts file devides the error message of setting validations 3 | */ 4 | 5 | 'use strict'; 6 | 7 | export namespace ErrorMessages { 8 | 9 | export function previousDefinitionOf(name: string): string { 10 | return `${name} is previously defined.`; 11 | } 12 | 13 | export function defineNotSupported(name: string): string { 14 | return `${name} is not supported.`; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /server/src/qrunesModes/embeddedModeImpl/settings/compiler/validations/validations.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This ts file provides the validations for setting 3 | */ 4 | 'use strict'; 5 | 6 | import { ErrorMessages } from '../tools/errorMessages'; 7 | import { ErrorBuilder } from '../../../tools/errorBuilder'; 8 | import { ContentPosition } from '../../../types'; 9 | import { ErrorListener } from '../../../tools/errorListener'; 10 | import { SymbolTable } from '../../../commonCompiler/types'; 11 | 12 | export class SemanticRulesValidator { 13 | constructor(private symbolTable: SymbolTable, private errorListener: ErrorListener) {} 14 | 15 | validate(rules: SemanticRule[]) { 16 | if (rules === undefined || rules === null) { 17 | return; 18 | } 19 | 20 | rules.forEach(rule => rule.applyWith(this.symbolTable, this.errorListener)); 21 | } 22 | } 23 | 24 | export interface SemanticRule { 25 | applyWith(symbolTable: SymbolTable, errorListener: ErrorListener): void; 26 | } 27 | 28 | export class PreviousDefinitionValidation { 29 | constructor(private symbolTable: SymbolTable, private errorListener: ErrorListener) {} 30 | 31 | apply(variableName: string, setName: string, position: ContentPosition) { 32 | if (this.symbolTable.lookup(variableName) === null) { 33 | return; 34 | } 35 | 36 | let message = ErrorMessages.previousDefinitionOf(setName); 37 | let error = ErrorBuilder.error(message, position); 38 | 39 | this.errorListener.addError(error); 40 | } 41 | 42 | applyNotSupported(setName: string, position: ContentPosition) { 43 | let message = ErrorMessages.defineNotSupported(setName); 44 | let error = ErrorBuilder.error(message, position); 45 | 46 | this.errorListener.addError(error); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /server/src/qrunesModes/embeddedModeImpl/settings/parser.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This ts file provides settings mode parser function. 3 | */ 4 | 'use strict'; 5 | 6 | import { Parser, ParserResult } from '../types'; 7 | import { SettingsSyntacticParser } from './compiler/settingsSyntacticParser'; 8 | import { SymbolTableGenerator } from './compiler/symbolTableGenerator'; 9 | import { ErrorListener } from '../tools/errorListener'; 10 | 11 | export class SettingsParser implements Parser { 12 | parse(input: string): ParserResult { 13 | let errorListener = new ErrorListener(); 14 | let tree = SettingsSyntacticParser.parseWithErrorListener(input, errorListener); 15 | SymbolTableGenerator.symbolTableFor(tree, errorListener); 16 | 17 | return { 18 | ast: tree, 19 | errors: errorListener.errors 20 | }; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /server/src/qrunesModes/embeddedModeImpl/tools/errorBuilder.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | 5 | 'use strict'; 6 | 7 | import { ParserError, ParseErrorLevel } from '../types'; 8 | import { ContentPosition } from '../types'; 9 | 10 | export namespace ErrorBuilder { 11 | export function error(message: string, position: ContentPosition): ParserError { 12 | return { 13 | line: position.line, 14 | start: position.start, 15 | end: position.end, 16 | message, 17 | level: ParseErrorLevel.ERROR 18 | }; 19 | } 20 | 21 | export function warning(message: string, position: ContentPosition): ParserError { 22 | return { 23 | line: position.line, 24 | start: position.start, 25 | end: position.end, 26 | message, 27 | level: ParseErrorLevel.WARNING 28 | }; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /server/src/qrunesModes/embeddedModeImpl/tools/errorListener.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | 5 | 'use strict'; 6 | 7 | import { ANTLRErrorListener, CommonToken, Token, Recognizer, RecognitionException } from 'antlr4ts'; 8 | import { Override } from 'antlr4ts/Decorators'; 9 | import { ParserError, ParseErrorLevel } from '../types'; 10 | 11 | export class ErrorListener implements ANTLRErrorListener { 12 | errors: ParserError[] = []; 13 | 14 | addError(error: ParserError) { 15 | this.errors.push(error); 16 | } 17 | 18 | @Override 19 | syntaxError( 20 | _recognizer: Recognizer, 21 | offendingSymbol: T | undefined, 22 | line: number, 23 | charPositionInLine: number, 24 | msg: string, 25 | _e: RecognitionException | undefined 26 | ): void { 27 | // _e contains the first token of the rule that failed 28 | 29 | if (offendingSymbol.text === ')') { 30 | this.errors.push({ 31 | line: line - 1, 32 | start: charPositionInLine, 33 | end: charPositionInLine + offendingSymbol.text.length, 34 | message: 'Expecting arguments before symbol )', 35 | level: ParseErrorLevel.ERROR 36 | }); 37 | } else { 38 | this.errors.push({ 39 | line: line - 1, 40 | start: charPositionInLine, 41 | end: charPositionInLine + offendingSymbol.text.length, 42 | message: msg, 43 | level: ParseErrorLevel.ERROR 44 | }); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /server/src/qrunesModes/embeddedModeImpl/tools/positionAdapter.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | 5 | 'use strict'; 6 | 7 | import { TerminalNode } from 'antlr4ts/tree'; 8 | import { ContentPosition } from '../types'; 9 | import { Token } from 'antlr4ts'; 10 | 11 | export namespace PositionAdapter { 12 | export function fromTerminalNode(node: TerminalNode): ContentPosition { 13 | return { 14 | line: node.symbol.line - 1, 15 | start: node.symbol.charPositionInLine, 16 | end: node.symbol.charPositionInLine + node.text.length 17 | }; 18 | } 19 | 20 | export function fromToken(token: Token): ContentPosition { 21 | return { 22 | line: token.line - 1, 23 | start: token.charPositionInLine, 24 | end: token.charPositionInLine + token.text.length 25 | }; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /server/src/qrunesModes/embeddedModeImpl/tools/suggestionSymbolAdapter.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | 5 | 'use strict'; 6 | 7 | import { SuggestionSymbol } from '../types'; 8 | import { CompletionItemKind } from 'vscode-languageserver/lib/main'; 9 | 10 | export namespace SuggestionSymbolAdapter { 11 | export function toCompletionItem() { 12 | return (symbol: SuggestionSymbol, index: number) => { 13 | return { 14 | label: symbol.label, 15 | kind: CompletionItemKind.Text, 16 | data: symbol.data, 17 | detail: symbol.detail, 18 | documentation: symbol.documentation 19 | }; 20 | }; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /server/src/qrunesModes/embeddedModeImpl/tools/treePrinter.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | 5 | 'use strict'; 6 | 7 | import { ParserRuleContext } from 'antlr4ts'; 8 | 9 | export namespace TreePrinter { 10 | export function print(ruleNames: string[], root: ParserRuleContext): void { 11 | console.log(`START : ${ruleNames[root.ruleIndex]} > `); 12 | printChildren(ruleNames, root.children as ParserRuleContext[], 1); 13 | } 14 | 15 | function printChildren(ruleNames: string[], children: ParserRuleContext[], level: number): void { 16 | children.forEach(child => { 17 | let spaces = ''; 18 | let spacePosition = 0; 19 | while (spacePosition < level) { 20 | spaces += '| '; 21 | spacePosition++; 22 | } 23 | if (ruleNames[child.ruleIndex] === undefined) { 24 | console.log(`${spaces}${child.text}`); 25 | } else { 26 | console.log(`${spaces}${ruleNames[child.ruleIndex]} > `); 27 | } 28 | if (child.childCount > 0) { 29 | printChildren(ruleNames, child.children as ParserRuleContext[], level + 1); 30 | } 31 | }); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /server/src/qrunesModes/modes/hostLanguageModes/cppScriptMode.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This ts file provides the service of cpp script mode, include the validation, complete, 3 | * hover and other functions. 4 | */ 5 | 'use strict'; 6 | 7 | import { LanguageModelCache, getLanguageModelCache } from '../../languageModelCache'; 8 | import { TextDocument, Position, CompletionItem, CompletionList } from 'vscode-languageserver-types'; 9 | import { CompilationTool } from "../../embeddedModeImpl/compilation"; 10 | import { CppParser } from "../../embeddedModeImpl/cpp/parser"; 11 | import { CppSuggester } from "../../embeddedModeImpl/cpp/suggester"; 12 | import { LanguageMode } from '../../languageModes'; 13 | import { QRunesDocumentRegions } from '../../embeddedSupport'; 14 | import { TextDocumentPositionParams } from 'vscode-languageserver'; 15 | 16 | export function getCppScriptMode(documentRegions: LanguageModelCache): LanguageMode { 17 | 18 | let embeddedQcodesDocuments = getLanguageModelCache(10, 60, document => documentRegions.get(document).getEmbeddedDocument('cppscript')); 19 | let compilationTool: CompilationTool = new CompilationTool(new CppParser(), new CppSuggester()); 20 | 21 | return { 22 | getId() { 23 | return 'cppscript'; 24 | }, 25 | doValidation(document: TextDocument) { 26 | let embedded = embeddedQcodesDocuments.get(document); 27 | return compilationTool.validateDocument(embedded); 28 | }, 29 | doComplete(document: TextDocument, embeddedPosition: Position) { 30 | let embedded = embeddedQcodesDocuments.get(document); 31 | let content: TextDocumentPositionParams = {textDocument: embedded, position: embeddedPosition} 32 | return compilationTool.availableCompletions(content) || CompletionList.create(); 33 | }, 34 | doResolve(item: CompletionItem): CompletionItem { 35 | return compilationTool.completionDetailsFor(item); 36 | }, 37 | doHover(document: TextDocument, position: Position) { 38 | return compilationTool.doHover(document, position); 39 | }, 40 | onDocumentRemoved(document: TextDocument) { 41 | embeddedQcodesDocuments.onDocumentRemoved(document); 42 | }, 43 | dispose() { 44 | embeddedQcodesDocuments.dispose(); 45 | } 46 | }; 47 | } -------------------------------------------------------------------------------- /server/src/qrunesModes/modes/hostLanguageModes/pyScriptMode.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This ts file provides the service of pythob script mode, include the validation, complete, 3 | * hover and other functions. 4 | */ 5 | 'use strict'; 6 | 7 | import { LanguageModelCache, getLanguageModelCache } from '../../languageModelCache'; 8 | import { TextDocument, Position, CompletionItem, CompletionList } from 'vscode-languageserver-types'; 9 | import { CompilationTool } from "../../embeddedModeImpl/compilationPython"; 10 | import { PythonParser } from "../../embeddedModeImpl/python/parser"; 11 | import { PythonSuggester } from "../../embeddedModeImpl/python/suggester"; 12 | import { LanguageMode } from '../../languageModes'; 13 | import { QRunesDocumentRegions } from '../../embeddedSupport'; 14 | import { TextDocumentPositionParams } from 'vscode-languageserver'; 15 | 16 | export function getPyScriptMode(documentRegions: LanguageModelCache): LanguageMode { 17 | 18 | let embeddedScriptDocuments = getLanguageModelCache(10, 60, document => documentRegions.get(document).getEmbeddedDocument('pyscript')); 19 | let compilationTool: CompilationTool = new CompilationTool(new PythonParser(), new PythonSuggester()); 20 | 21 | return { 22 | getId() { 23 | return 'pyscript'; 24 | }, 25 | doValidation(document: TextDocument) { 26 | let embedded = embeddedScriptDocuments.get(document); 27 | return compilationTool.validateDocument(embedded); 28 | }, 29 | doComplete(document: TextDocument, embeddedPosition: Position) { 30 | let embedded = embeddedScriptDocuments.get(document); 31 | let content: TextDocumentPositionParams = {textDocument: embedded, position: embeddedPosition} 32 | return compilationTool.availableCompletions(content) || CompletionList.create(); 33 | }, 34 | doResolve(item: CompletionItem): CompletionItem { 35 | return compilationTool.completionDetailsFor(item); 36 | }, 37 | doHover(document: TextDocument, position: Position) { 38 | return compilationTool.doHover(document, position); 39 | }, 40 | onDocumentRemoved(document: TextDocument) { 41 | embeddedScriptDocuments.onDocumentRemoved(document); 42 | }, 43 | dispose() { 44 | embeddedScriptDocuments.dispose(); 45 | } 46 | }; 47 | } -------------------------------------------------------------------------------- /server/src/qrunesModes/modes/qrunesMode/qrunesMode.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This ts file provides the service of qrunes mode, include the validation, complete, 3 | * hover and other functions. 4 | */ 5 | 'use strict'; 6 | 7 | import { getLanguageModelCache } from '../../languageModelCache'; 8 | import { LanguageService as QRunesLanguageService, QRunesDocument } from '../../qrunesService/qrunesLanguageService'; 9 | import { TextDocument, Position , CompletionItem } from 'vscode-languageserver-types'; 10 | import { LanguageMode } from '../../languageModes'; 11 | 12 | export function getQRunesMode(qrunesLanguageService: QRunesLanguageService): LanguageMode { 13 | 14 | let qrunesDocuments = getLanguageModelCache(10, 60, document => qrunesLanguageService.parseQRunesDocument(document)); 15 | return { 16 | getId() { 17 | return 'qrunes'; 18 | }, 19 | doComplete(document: TextDocument, position: Position) { 20 | let pathCompletionProposals: CompletionItem[] = []; 21 | 22 | const qrunesDocument = qrunesDocuments.get(document); 23 | let completionList = qrunesLanguageService.doComplete(document, position, qrunesDocument); 24 | completionList.items.push(...pathCompletionProposals); 25 | return completionList; 26 | }, 27 | doHover(document: TextDocument, position: Position) { 28 | return qrunesLanguageService.doHover(document, position, qrunesDocuments.get(document)); 29 | }, 30 | findDocumentHighlight(document: TextDocument, position: Position) { 31 | return qrunesLanguageService.findDocumentHighlights(document, position, qrunesDocuments.get(document)); 32 | }, 33 | onDocumentRemoved(document: TextDocument) { 34 | qrunesDocuments.onDocumentRemoved(document); 35 | }, 36 | dispose() { 37 | qrunesDocuments.dispose(); 38 | } 39 | }; 40 | } 41 | -------------------------------------------------------------------------------- /server/src/qrunesModes/modes/settingMode/settingsMode.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This ts file provides the service of settings mode, include the validation, complete, 3 | * hover and other functions. 4 | */ 5 | 'use strict'; 6 | 7 | import { LanguageModelCache, getLanguageModelCache } from '../../languageModelCache'; 8 | import { TextDocument, Position, CompletionItem, CompletionList } from 'vscode-languageserver-types'; 9 | import { CompilationTool } from "../../embeddedModeImpl/compilation"; 10 | import { SettingsParser } from "../../embeddedModeImpl/settings/parser"; 11 | import { SettingsSuggester } from "../../embeddedModeImpl/settings/suggester"; 12 | import { LanguageMode } from '../../languageModes'; 13 | import { QRunesDocumentRegions } from '../../embeddedSupport'; 14 | import { TextDocumentPositionParams } from 'vscode-languageserver'; 15 | 16 | export function getSettingsMode(documentRegions: LanguageModelCache): LanguageMode { 17 | 18 | let embeddedSettingsDocuments = getLanguageModelCache(10, 60, document => documentRegions.get(document).getEmbeddedDocument('settings')); 19 | let compilationTool: CompilationTool = new CompilationTool(new SettingsParser(), new SettingsSuggester()); 20 | 21 | return { 22 | getId() { 23 | return 'settings'; 24 | }, 25 | doValidation(document: TextDocument) { 26 | let embedded = embeddedSettingsDocuments.get(document); 27 | return compilationTool.validateDocument(embedded); 28 | }, 29 | doComplete(document: TextDocument, embeddedPosition: Position) { 30 | let embedded = embeddedSettingsDocuments.get(document); 31 | let content: TextDocumentPositionParams = {textDocument: embedded, position: embeddedPosition} 32 | return compilationTool.availableCompletions(content) || CompletionList.create(); 33 | }, 34 | doResolve(item: CompletionItem): CompletionItem { 35 | return compilationTool.completionDetailsFor(item); 36 | }, 37 | doHover(document: TextDocument, position: Position) { 38 | return compilationTool.doHover(document, position); 39 | }, 40 | onDocumentRemoved(document: TextDocument) { 41 | embeddedSettingsDocuments.onDocumentRemoved(document); 42 | }, 43 | dispose() { 44 | embeddedSettingsDocuments.dispose(); 45 | } 46 | }; 47 | } -------------------------------------------------------------------------------- /server/src/qrunesModes/qrunesService/parser/qrunesTags.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This ts file provides the details of qrunes language tags 3 | */ 4 | 5 | import * as nls from 'vscode-nls'; 6 | let localize = nls.loadMessageBundle(); 7 | 8 | export interface IQRunesTagProvider { 9 | getId(): string; 10 | isApplicable(languageId: string) : boolean; 11 | collectTags(collector: (tag: string, label: string) => void): void; 12 | } 13 | 14 | export interface ITagSet { 15 | [tag: string]: QRunesTagSpecification; 16 | } 17 | 18 | export class QRunesTagSpecification { 19 | constructor(public label: string) { } 20 | } 21 | 22 | export const QRUNES_TAGS: ITagSet = { 23 | settings: new QRunesTagSpecification( 24 | localize('tags.settings', 'The settings element represents the configurations of QRunes\(Quantum Programming Language\).')), 25 | qcodes: new QRunesTagSpecification( 26 | localize('tags.qcodes', 'The qcodes element represents the quantum code for QRunes\(Quantum Programming Language\).')), 27 | script: new QRunesTagSpecification( 28 | localize('tags.script', 'The script element represents the classic programming languanges like Python, C++, etc.')) 29 | } 30 | 31 | export function getQRunesTagProvider(): IQRunesTagProvider { 32 | return { 33 | getId: () => 'qrunes', 34 | isApplicable: () => true, 35 | collectTags: (collector: (tag: string, label: string) => void) => collectTagsDefault(collector, QRUNES_TAGS) 36 | }; 37 | } 38 | 39 | function collectTagsDefault(collector: (tag: string, label: string) => void, tagSet: ITagSet): void { 40 | for (var tag in tagSet) { 41 | collector(tag, tagSet[tag].label); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /server/src/qrunesModes/qrunesService/qrunesLanguageService.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This ts file provides the qrunes language service, include scanner, parser, doComplete, 3 | * hover and other functions. 4 | */ 5 | 'use strict'; 6 | 7 | import { createScanner } from './parser/qrunesScanner'; 8 | import { parse } from './parser/qrunesParser'; 9 | import { QRunesCompletion } from './qrunesServiceImpl/qrunesCompletion'; 10 | import { doHover } from './qrunesServiceImpl/qrunesHover'; 11 | import { findDocumentHighlights } from './qrunesServiceImpl/qrunesHighlighting'; 12 | import { TextDocument, Position, DocumentHighlight, CompletionList, Hover } from 'vscode-languageserver-types'; 13 | import { Scanner, QRunesDocument } from './qrunesLanguageTypes'; 14 | 15 | export * from './qrunesLanguageTypes'; 16 | export * from 'vscode-languageserver-types'; 17 | 18 | 19 | export interface LanguageService { 20 | createScanner(input: string, initialOffset?: number): Scanner; 21 | parseQRunesDocument(document: TextDocument): QRunesDocument; 22 | findDocumentHighlights(document: TextDocument, position: Position, qrunesDocument: QRunesDocument): DocumentHighlight[]; 23 | doComplete(document: TextDocument, position: Position, qrunesDocument: QRunesDocument ): CompletionList; 24 | doHover(document: TextDocument, position: Position, qrunesDocument: QRunesDocument): Hover | null; 25 | } 26 | 27 | export function getLanguageService(): LanguageService { 28 | const qrunesCompletion = new QRunesCompletion(); 29 | return { 30 | createScanner, 31 | parseQRunesDocument: document => parse(document.getText()), 32 | doComplete: qrunesCompletion.doComplete.bind(qrunesCompletion), 33 | doHover, 34 | findDocumentHighlights 35 | }; 36 | } 37 | -------------------------------------------------------------------------------- /server/src/qrunesModes/qrunesService/qrunesLanguageTypes.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This ts file define language types, include node type for parser, token type for scanner and parser, 3 | * scanner state for scanner, qrunes document, and interface scanner. 4 | */ 5 | 6 | 'use strict'; 7 | 8 | export interface Node { 9 | tag: string | undefined; 10 | start: number; 11 | end: number; 12 | children: Node[]; 13 | } 14 | 15 | export enum TokenType { 16 | StartCommentTag, 17 | Comment, 18 | EndCommentTag, 19 | StartTagOpen, 20 | StartTagClose, 21 | StartTag, 22 | EndTag, 23 | Content, 24 | Whitespace, 25 | Unknown, 26 | QCodes, 27 | Settings, 28 | PyScript, 29 | CppScript, 30 | EOS 31 | } 32 | 33 | export enum ScannerState { 34 | WithinContent, 35 | AfterOpeningStartTag, 36 | AfterOpeningEndTag, 37 | WithinTag, 38 | WithinComment, 39 | WithinQCodesContent, 40 | WithinSettingsContent, 41 | WithinPyScriptContent, 42 | WithinCppScriptContent, 43 | } 44 | 45 | export interface Scanner { 46 | scan(): TokenType; 47 | getTokenType(): TokenType; 48 | getTokenOffset(): number; 49 | getTokenLength(): number; 50 | getTokenEnd(): number; 51 | getTokenText(): string; 52 | getTokenError(): string | undefined; 53 | getScannerState(): ScannerState; 54 | } 55 | 56 | export declare type QRunesDocument = { 57 | roots: Node[]; 58 | findNodeBefore(offset: number): Node; 59 | findNodeAt(offset: number): Node; 60 | }; -------------------------------------------------------------------------------- /server/src/qrunesModes/qrunesService/qrunesServiceImpl/qrunesHighlighting.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | 5 | 'use strict'; 6 | 7 | import { QRunesDocument } from '../parser/qrunesParser'; 8 | import { createScanner } from '../parser/qrunesScanner'; 9 | import { TextDocument, Range, Position, DocumentHighlightKind, DocumentHighlight } from 'vscode-languageserver-types'; 10 | import { TokenType } from '../qrunesLanguageTypes'; 11 | 12 | export function findDocumentHighlights(document: TextDocument, position: Position, qrunesDocument: QRunesDocument): DocumentHighlight[] { 13 | let offset = document.offsetAt(position); 14 | let node = qrunesDocument.findNodeAt(offset); 15 | if (!node.tag) { 16 | return []; 17 | } 18 | let result = []; 19 | let startTagRange = getTagNameRange(TokenType.StartTag, document, node.start); 20 | if (startTagRange && covers(startTagRange, position)) { 21 | if (startTagRange) { 22 | result.push({ kind: DocumentHighlightKind.Read, range: startTagRange }); 23 | } 24 | } 25 | return result; 26 | } 27 | 28 | function isBeforeOrEqual(pos1: Position, pos2: Position) { 29 | return pos1.line < pos2.line || (pos1.line === pos2.line && pos1.character <= pos2.character); 30 | } 31 | 32 | function covers(range: Range, position: Position) { 33 | return isBeforeOrEqual(range.start, position) && isBeforeOrEqual(position, range.end); 34 | } 35 | 36 | function getTagNameRange(tokenType: TokenType, document: TextDocument, startOffset: number): Range | null { 37 | let scanner = createScanner(document.getText(), startOffset); 38 | let token = scanner.scan(); 39 | while (token !== TokenType.EOS && token !== tokenType) { 40 | token = scanner.scan(); 41 | } 42 | if (token !== TokenType.EOS) { 43 | return { start: document.positionAt(scanner.getTokenOffset()), end: document.positionAt(scanner.getTokenEnd()) }; 44 | } 45 | return null; 46 | } 47 | -------------------------------------------------------------------------------- /server/src/qrunesModes/qrunesService/qrunesServiceImpl/qrunesHover.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This ts file provides the auto hover function of qrunes langauge. 3 | */ 4 | 5 | 'use strict'; 6 | 7 | import { QRunesDocument } from '../parser/qrunesParser'; 8 | import { createScanner } from '../parser/qrunesScanner'; 9 | import { TextDocument, Range, Position, Hover, MarkedString } from 'vscode-languageserver-types'; 10 | import { allTagProviders } from './tagProviders'; 11 | import { TokenType } from '../qrunesLanguageTypes'; 12 | 13 | export function doHover(document: TextDocument, position: Position, qrunesDocument: QRunesDocument): Hover | null { 14 | let offset = document.offsetAt(position); 15 | let node = qrunesDocument.findNodeAt(offset); 16 | if (!node || !node.tag) { 17 | return null; 18 | } 19 | let tagProviders = allTagProviders.filter(p => p.isApplicable(document.languageId)); 20 | function getTagHover(tag: string, range: Range, open: boolean): Hover | null { 21 | tag = tag.toLowerCase(); 22 | for (let provider of tagProviders) { 23 | let hover = null; 24 | provider.collectTags((t, label) => { 25 | if (t === tag) { 26 | let tagLabel = open ? '@' + tag + ':' : null; 27 | hover = { contents: [{ language: 'qrunes', value: tagLabel }, MarkedString.fromPlainText(label)], range }; 28 | } 29 | }); 30 | if (hover) { 31 | return hover; 32 | } 33 | } 34 | return null; 35 | } 36 | 37 | function getTagNameRange(tokenType: TokenType, startOffset: number): Range | null { 38 | let scanner = createScanner(document.getText(), startOffset); 39 | let token = scanner.scan(); 40 | while (token !== TokenType.EOS && (scanner.getTokenEnd() < offset || scanner.getTokenEnd() === offset && token !== tokenType)) { 41 | token = scanner.scan(); 42 | } 43 | if (token === tokenType && offset <= scanner.getTokenEnd()) { 44 | return { start: document.positionAt(scanner.getTokenOffset()), end: document.positionAt(scanner.getTokenEnd()) }; 45 | } 46 | return null; 47 | } 48 | 49 | let tagRange = getTagNameRange(TokenType.StartTag, node.start); 50 | if (tagRange) { 51 | return getTagHover(node.tag, tagRange, true); 52 | } 53 | return null; 54 | } 55 | 56 | -------------------------------------------------------------------------------- /server/src/qrunesModes/qrunesService/qrunesServiceImpl/tagProviders.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This ts file defines the qrunes language tag. 3 | */ 4 | 'use strict'; 5 | 6 | import {getQRunesTagProvider, IQRunesTagProvider} from '../parser/qrunesTags'; 7 | 8 | export let allTagProviders : IQRunesTagProvider[] = [ 9 | getQRunesTagProvider(), 10 | ]; -------------------------------------------------------------------------------- /server/src/tools/runner.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This handler provides the function about the runner, include runSafe and runSafeAsync. 3 | */ 4 | 5 | 'use strict'; 6 | 7 | import { ResponseError, ErrorCodes, CancellationToken } from 'vscode-languageserver'; 8 | 9 | export function formatError(message: string, err: any): string { 10 | if (err instanceof Error) { 11 | let error = err; 12 | return `${message}: ${error.message}\n${error.stack}`; 13 | } else if (typeof err === 'string') { 14 | return `${message}: ${err}`; 15 | } else if (err) { 16 | return `${message}: ${err.toString()}`; 17 | } 18 | return message; 19 | } 20 | 21 | export function runSafeAsync(func: () => Thenable, errorVal: T, errorMessage: string, token: CancellationToken): Thenable> { 22 | return new Promise>((resolve, reject) => { 23 | console.log(reject); 24 | setImmediate(() => { 25 | if (token.isCancellationRequested) { 26 | resolve(cancelValue()); 27 | } 28 | return func().then(result => { 29 | if (token.isCancellationRequested) { 30 | resolve(cancelValue()); 31 | return; 32 | } else { 33 | resolve(result); 34 | } 35 | }, e => { 36 | //console.error(formatError(errorMessage, e)); 37 | resolve(errorVal); 38 | }); 39 | }); 40 | }); 41 | } 42 | 43 | export function runSafe(func: () => T, errorVal: T, errorMessage: string, token: CancellationToken): Thenable> { 44 | return new Promise>((resolve, reject) => { 45 | console.log(reject); 46 | setImmediate(() => { 47 | if (token.isCancellationRequested) { 48 | resolve(cancelValue()); 49 | } else { 50 | try { 51 | let result = func(); 52 | if (token.isCancellationRequested) { 53 | resolve(cancelValue()); 54 | return; 55 | } else { 56 | resolve(result); 57 | } 58 | 59 | } catch (e) { 60 | //console.error(formatError(errorMessage, e)); 61 | resolve(errorVal); 62 | } 63 | } 64 | }); 65 | }); 66 | } 67 | 68 | function cancelValue() { 69 | return new ResponseError(ErrorCodes.RequestCancelled, 'Request cancelled'); 70 | } 71 | -------------------------------------------------------------------------------- /server/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.base.json", 3 | "compilerOptions": { 4 | "target": "es2018", 5 | "module": "commonjs", 6 | "moduleResolution": "node", 7 | "sourceMap": true, 8 | "outDir": "out", 9 | "rootDir": "src", 10 | "lib": [ "es2018" ], 11 | "noUnusedLocals": false, 12 | "noUnusedParameters": false, 13 | "experimentalDecorators": true 14 | }, 15 | "include": [ 16 | "src" 17 | ], 18 | "exclude": [ 19 | "node_modules" 20 | ] 21 | } -------------------------------------------------------------------------------- /tsconfig.base.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "noImplicitAny": true, 4 | "noImplicitReturns": true, 5 | "noUnusedLocals": true, 6 | "noUnusedParameters": true 7 | } 8 | } --------------------------------------------------------------------------------