-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #714 from SteKoe/fix/one-selector
fix: some expressions
- Loading branch information
Showing
56 changed files
with
236 additions
and
320 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,25 @@ | ||
import {OclExecutionContext} from "../OclExecutionContext"; | ||
import {Expression} from "./Expression"; | ||
import {SourceBasedExpression} from "./SourceBasedExpression"; | ||
|
||
export abstract class BodyBasedExpression extends SourceBasedExpression { | ||
private body: Expression; | ||
|
||
setBody(body: Expression): any { | ||
this.body = body; | ||
} | ||
|
||
getBody(): Expression { | ||
return this.body; | ||
} | ||
|
||
_evaluateBodyAndSource(visitor: OclExecutionContext, localVariables?: any): { source: any, body: any } { | ||
const body = this.getSource() | ||
.evaluate(visitor, localVariables); | ||
|
||
const source = this.getBody() | ||
.evaluate(visitor, localVariables); | ||
|
||
return {source, body}; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import {OclExecutionContext} from "../OclExecutionContext"; | ||
import {Utils} from "../Utils"; | ||
|
||
import {BodyBasedExpression} from "./BodyBasedExpression"; | ||
|
||
export abstract class IteratorExpression extends BodyBasedExpression { | ||
private iterators: Array<any>; | ||
|
||
setIterators(iterators: Array<any>): void { | ||
this.iterators = iterators; | ||
} | ||
|
||
getIterators(): Array<any> { | ||
return this.iterators; | ||
} | ||
|
||
protected evaluateBody(visitor: OclExecutionContext, localVariables: any, item: any) { | ||
const variables = {}; | ||
if (this.getIterators()) { | ||
variables[this.getIterators()[0]] = item; | ||
} else { | ||
const variableName = Utils.getVariableName(this); | ||
const varName = variableName.getVariable(); | ||
variables[varName] = varName === "self" ? item : (item[varName] ?? item); | ||
} | ||
|
||
return this.getBody().evaluate(visitor, {...localVariables, ...variables}); | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import {Expression} from "./Expression"; | ||
|
||
export abstract class SourceBasedExpression extends Expression { | ||
private readonly source: any; | ||
|
||
constructor(source) { | ||
super(); | ||
this.source = source; | ||
} | ||
|
||
getSource(): Expression { | ||
return this.source; | ||
} | ||
} |
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
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
Oops, something went wrong.