generated from finos/software-project-blueprint
-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* compilePMCD and basic Test * compilePMCD and basic Test
- Loading branch information
Showing
10 changed files
with
190 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
...ava/org/finos/legend/engine/pure/runtime/compiler/compiled/natives/LegendCompilePMCD.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// Copyright 2022 Goldman Sachs | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package org.finos.legend.engine.pure.runtime.compiler.compiled.natives; | ||
|
||
import org.eclipse.collections.api.list.ListIterable; | ||
import org.eclipse.collections.api.list.MutableList; | ||
import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.PackageableElement; | ||
import org.finos.legend.pure.m3.execution.ExecutionSupport; | ||
import org.finos.legend.pure.m3.navigation.Instance; | ||
import org.finos.legend.pure.m3.navigation.M3Properties; | ||
import org.finos.legend.pure.m3.navigation.ProcessorSupport; | ||
import org.finos.legend.pure.m4.coreinstance.CoreInstance; | ||
import org.finos.legend.pure.runtime.java.compiled.execution.CompiledExecutionSupport; | ||
import org.finos.legend.pure.runtime.java.compiled.generation.ProcessorContext; | ||
import org.finos.legend.pure.runtime.java.compiled.generation.processors.natives.AbstractNative; | ||
import org.finos.legend.pure.runtime.java.compiled.generation.processors.valuespecification.ValueSpecificationProcessor; | ||
|
||
public class LegendCompilePMCD extends AbstractNative | ||
{ | ||
public LegendCompilePMCD() | ||
{ | ||
super("compilePMCD_String_1__PackageableElement_MANY_"); | ||
} | ||
|
||
@Override | ||
public String build(CoreInstance topLevelElement, CoreInstance functionExpression, ListIterable<String> listIterable, ProcessorContext processorContext) | ||
{ | ||
final ProcessorSupport processorSupport = processorContext.getSupport(); | ||
final ListIterable<? extends CoreInstance> parametersValues = Instance.getValueForMetaPropertyToManyResolved(functionExpression, M3Properties.parametersValues, processorSupport); | ||
|
||
String code = ValueSpecificationProcessor.processValueSpecification(topLevelElement, parametersValues.get(0), processorContext); | ||
|
||
return "org.finos.legend.engine.pure.runtime.compiler.compiled.natives.LegendCompilePMCD.compileExecPMCD(" + code + ", es)"; | ||
} | ||
|
||
@Override | ||
public String buildBody() | ||
{ | ||
return "new SharedPureFunction<Object>()\n" + | ||
" {\n" + | ||
" @Override\n" + | ||
" public Object execute(ListIterable<?> vars, final ExecutionSupport es)\n" + | ||
" {\n" + | ||
" return org.finos.legend.engine.pure.runtime.compiler.compiled.natives.LegendCompilePMCD.compileExecPMCD((String) vars.get(0), es);\n" + | ||
" }\n" + | ||
" }"; | ||
} | ||
|
||
public static MutableList<PackageableElement> compileExecPMCD(String code, final ExecutionSupport es) | ||
{ | ||
return org.finos.legend.engine.pure.runtime.compiler.shared.LegendCompile.doCompilePMCD(code, ((CompiledExecutionSupport) es).getProcessorSupport().getMetadata()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
.../org/finos/legend/engine/pure/runtime/compiler/interpreted/natives/LegendCompilePMCD.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright 2022 Goldman Sachs | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package org.finos.legend.engine.pure.runtime.compiler.interpreted.natives; | ||
|
||
import org.eclipse.collections.api.list.ListIterable; | ||
import org.eclipse.collections.api.list.MutableList; | ||
import org.eclipse.collections.api.map.MutableMap; | ||
import org.finos.legend.pure.m3.compiler.Context; | ||
import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.PackageableElement; | ||
import org.finos.legend.pure.m3.exception.PureExecutionException; | ||
import org.finos.legend.pure.m3.navigation.Instance; | ||
import org.finos.legend.pure.m3.navigation.M3Properties; | ||
import org.finos.legend.pure.m3.navigation.ProcessorSupport; | ||
import org.finos.legend.pure.m3.navigation.ValueSpecificationBootstrap; | ||
import org.finos.legend.pure.m4.ModelRepository; | ||
import org.finos.legend.pure.m4.coreinstance.CoreInstance; | ||
import org.finos.legend.pure.runtime.java.interpreted.ExecutionSupport; | ||
import org.finos.legend.pure.runtime.java.interpreted.FunctionExecutionInterpreted; | ||
import org.finos.legend.pure.runtime.java.interpreted.VariableContext; | ||
import org.finos.legend.pure.runtime.java.interpreted.natives.InstantiationContext; | ||
import org.finos.legend.pure.runtime.java.interpreted.natives.NativeFunction; | ||
import org.finos.legend.pure.runtime.java.interpreted.profiler.Profiler; | ||
|
||
import java.util.Stack; | ||
|
||
public class LegendCompilePMCD extends NativeFunction | ||
{ | ||
private final FunctionExecutionInterpreted functionExecution; | ||
|
||
public LegendCompilePMCD(FunctionExecutionInterpreted functionExecution, ModelRepository modelRepository) | ||
{ | ||
this.functionExecution = functionExecution; | ||
} | ||
|
||
@Override | ||
public CoreInstance execute(ListIterable<? extends CoreInstance> params, Stack<MutableMap<String, CoreInstance>> stack, Stack<MutableMap<String, CoreInstance>> stack1, VariableContext variableContext, CoreInstance coreInstance, Profiler profiler, InstantiationContext instantiationContext, ExecutionSupport executionSupport, Context context, ProcessorSupport processorSupport) throws PureExecutionException | ||
{ | ||
String code = Instance.getValueForMetaPropertyToOneResolved(params.get(0), M3Properties.values, processorSupport).getName(); | ||
|
||
MutableList<PackageableElement> createdElements = null; | ||
createdElements = org.finos.legend.engine.pure.runtime.compiler.shared.LegendCompile.doCompilePMCD(code, new InterpretedMetadata(processorSupport)); | ||
return ValueSpecificationBootstrap.wrapValueSpecification(createdElements, true, functionExecution.getProcessorSupport()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters