public IOpenSourceCodeModule asSourceCodeModule() { return new StringSourceCodeModule(value, getMetaInfo().getSourceUrl()); }
public IOpenSourceCodeModule asSourceCodeModule() { return new StringSourceCodeModule(value, getMetaInfo().getSourceUrl()); }
@Override public Object convert(List<AlgorithmTreeNode> nodesToCompile, String operationParam) throws SyntaxNodeException { if (operationParam == null) { return null; } StringValue cellContent = AlgorithmCompilerTool.getCellContent(nodesToCompile, operationParam); AlgorithmTreeNode executionNode = AlgorithmCompilerTool.extractOperationNode(nodesToCompile, operationParam); String methodName = String.format("%s_row_%s", operationParam.replace('.', '_'), executionNode.getAlgorithmRow().getRowNumber()); IOpenSourceCodeModule src = cellContent.getMetaInfo().getSource(); // return statements for the whole Algorithm(TBasic) should be casted to the return type of // whole Algorithm rule if (labelManager.isReturnInstruction(operationParam)) { /** create method and cast its value to the appropriate return type*/ return compiler.makeMethodWithCast(src, methodName, returnType); } else { return compiler.makeMethod(src, methodName); } } }
private CellMetaInfo checkMetaInfo(int row, int col, RuntimeOperation step, StringValue algorithmCell) { IOpenSourceCodeModule sourceModule = algorithmCell.getMetaInfo().getSource(); if (sourceModule instanceof GridCellSourceCodeModule) { ICell cell = ((GridCellSourceCodeModule) sourceModule).getCell(); if (isNeededCell(cell, row, col)) { // Found the cell. Return either meta info or null. if (step instanceof OpenLEvaluationOperation) { IMethodCaller methodCaller = ((OpenLEvaluationOperation) step).getOpenLStatement(); if (methodCaller instanceof CompositeMethod) { List<NodeUsage> nodeUsages = OpenLCellExpressionsCompiler.getNodeUsages( (CompositeMethod) methodCaller, sourceModule.getCode(), 0 ); return new CellMetaInfo(JavaOpenClass.STRING, false, nodeUsages); } } return null; } } return NOT_FOUND; } }