Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
qir
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Julien Lopez
qir
Commits
2fb34219
Commit
2fb34219
authored
Jan 8, 2016
by
Julien Lopez
Browse files
Options
Downloads
Patches
Plain Diff
- Add QIRNot
- Fix QIRFreeVarsVisitor
parent
b3e33ef2
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/qir/ast/expression/logic/QIRNot.java
+31
-0
31 additions, 0 deletions
src/qir/ast/expression/logic/QIRNot.java
src/qir/util/QIRFreeVarsVisitor.java
+40
-40
40 additions, 40 deletions
src/qir/util/QIRFreeVarsVisitor.java
with
71 additions
and
40 deletions
src/qir/ast/expression/logic/QIRNot.java
0 → 100644
+
31
−
0
View file @
2fb34219
package
qir.ast.expression.logic
;
import
com.oracle.truffle.api.source.*
;
import
qir.ast.*
;
import
qir.util.*
;
/**
* The {@link QIRNot} represents an expression that is true if and only if the {@link #left}
* expression and the {@link #right} expression are true.
*/
public
final
class
QIRNot
extends
QIRNode
{
/**
* The left side of the {@link QIRNot} operator.
*/
private
final
QIRNode
child
;
public
QIRNot
(
SourceSection
source
,
QIRNode
child
)
{
super
(
source
);
this
.
child
=
child
;
}
public
QIRNode
getChild
()
{
return
child
;
}
@Override
public
<
T
>
T
accept
(
IQIRVisitor
<
T
>
visitor
)
{
return
visitor
.
visit
(
this
);
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/qir/util/QIRFreeVarsVisitor.java
+
40
−
40
View file @
2fb34219
package
qir.util
;
import
java.util.Hash
Set
;
import
java.util.Hash
Map
;
import
qir.ast.*
;
import
qir.ast.data.*
;
...
...
@@ -13,201 +13,201 @@ import qir.ast.value.*;
/**
* This visitor returns the list of free variables in a query.
*/
public
final
class
QIRFreeVarsVisitor
implements
IQIRVisitor
<
Hash
Set
<
QIRVariable
>>
{
final
private
Hash
Set
<
QIRVariable
>
freeVariables
=
new
Hash
Set
<>();
final
private
Hash
Set
<
QIRVariable
>
boundVariables
=
new
Hash
Set
<>();
public
final
class
QIRFreeVarsVisitor
implements
IQIRVisitor
<
Hash
Map
<
String
,
QIRVariable
>>
{
final
private
Hash
Map
<
String
,
QIRVariable
>
freeVariables
=
new
Hash
Map
<>();
final
private
Hash
Map
<
String
,
QIRVariable
>
boundVariables
=
new
Hash
Map
<>();
@Override
public
Hash
Set
<
QIRVariable
>
visit
(
QIRProject
qirProject
)
{
public
Hash
Map
<
String
,
QIRVariable
>
visit
(
QIRProject
qirProject
)
{
qirProject
.
getFormatter
().
accept
(
this
);
return
qirProject
.
getChild
().
accept
(
this
);
}
@Override
public
Hash
Set
<
QIRVariable
>
visit
(
QIRScan
qirScan
)
{
public
Hash
Map
<
String
,
QIRVariable
>
visit
(
QIRScan
qirScan
)
{
return
qirScan
.
getTable
().
accept
(
this
);
}
@Override
public
Hash
Set
<
QIRVariable
>
visit
(
QIRSelect
qirSelect
)
{
public
Hash
Map
<
String
,
QIRVariable
>
visit
(
QIRSelect
qirSelect
)
{
qirSelect
.
getFilter
().
accept
(
this
);
return
qirSelect
.
getChild
().
accept
(
this
);
}
@Override
public
Hash
Set
<
QIRVariable
>
visit
(
QIRGroup
qirGroup
)
{
public
Hash
Map
<
String
,
QIRVariable
>
visit
(
QIRGroup
qirGroup
)
{
qirGroup
.
getEq
().
accept
(
this
);
qirGroup
.
getGroup
().
accept
(
this
);
return
qirGroup
.
getChild
().
accept
(
this
);
}
@Override
public
Hash
Set
<
QIRVariable
>
visit
(
QIROrder
qirOrder
)
{
public
Hash
Map
<
String
,
QIRVariable
>
visit
(
QIROrder
qirOrder
)
{
qirOrder
.
getOrder
().
accept
(
this
);
return
qirOrder
.
getChild
().
accept
(
this
);
}
@Override
public
Hash
Set
<
QIRVariable
>
visit
(
QIRLambda
qirLambda
)
{
public
Hash
Map
<
String
,
QIRVariable
>
visit
(
QIRLambda
qirLambda
)
{
QIRVariable
arg
=
qirLambda
.
getVar
();
boundVariables
.
add
(
arg
);
boundVariables
.
put
(
arg
.
getId
(),
arg
);
qirLambda
.
getBody
().
accept
(
this
);
boundVariables
.
remove
(
arg
);
return
freeVariables
;
}
@Override
public
Hash
Set
<
QIRVariable
>
visit
(
QIRApply
qirApply
)
{
public
Hash
Map
<
String
,
QIRVariable
>
visit
(
QIRApply
qirApply
)
{
qirApply
.
getLeft
().
accept
(
this
);
return
qirApply
.
getRight
().
accept
(
this
);
}
@Override
public
Hash
Set
<
QIRVariable
>
visit
(
QIRPlus
qirPlus
)
{
public
Hash
Map
<
String
,
QIRVariable
>
visit
(
QIRPlus
qirPlus
)
{
qirPlus
.
getLeft
().
accept
(
this
);
return
qirPlus
.
getRight
().
accept
(
this
);
}
@Override
public
Hash
Set
<
QIRVariable
>
visit
(
QIRMinus
qirMinus
)
{
public
Hash
Map
<
String
,
QIRVariable
>
visit
(
QIRMinus
qirMinus
)
{
qirMinus
.
getLeft
().
accept
(
this
);
return
qirMinus
.
getRight
().
accept
(
this
);
}
@Override
public
Hash
Set
<
QIRVariable
>
visit
(
QIRStar
qirStar
)
{
public
Hash
Map
<
String
,
QIRVariable
>
visit
(
QIRStar
qirStar
)
{
qirStar
.
getLeft
().
accept
(
this
);
return
qirStar
.
getRight
().
accept
(
this
);
}
@Override
public
Hash
Set
<
QIRVariable
>
visit
(
QIRDiv
qirDiv
)
{
public
Hash
Map
<
String
,
QIRVariable
>
visit
(
QIRDiv
qirDiv
)
{
qirDiv
.
getLeft
().
accept
(
this
);
return
qirDiv
.
getRight
().
accept
(
this
);
}
@Override
public
Hash
Set
<
QIRVariable
>
visit
(
QIRMod
qirMod
)
{
public
Hash
Map
<
String
,
QIRVariable
>
visit
(
QIRMod
qirMod
)
{
qirMod
.
getLeft
().
accept
(
this
);
return
qirMod
.
getRight
().
accept
(
this
);
}
@Override
public
Hash
Set
<
QIRVariable
>
visit
(
QIRAnd
qirAnd
)
{
public
Hash
Map
<
String
,
QIRVariable
>
visit
(
QIRAnd
qirAnd
)
{
qirAnd
.
getLeft
().
accept
(
this
);
return
qirAnd
.
getRight
().
accept
(
this
);
}
@Override
public
Hash
Set
<
QIRVariable
>
visit
(
QIROr
qirOr
)
{
public
Hash
Map
<
String
,
QIRVariable
>
visit
(
QIROr
qirOr
)
{
qirOr
.
getLeft
().
accept
(
this
);
return
qirOr
.
getRight
().
accept
(
this
);
}
@Override
public
Hash
Set
<
QIRVariable
>
visit
(
QIREqual
qirEqual
)
{
public
Hash
Map
<
String
,
QIRVariable
>
visit
(
QIREqual
qirEqual
)
{
qirEqual
.
getLeft
().
accept
(
this
);
return
qirEqual
.
getRight
().
accept
(
this
);
}
@Override
public
Hash
Set
<
QIRVariable
>
visit
(
QIRGreaterOrEqual
qirGreaterOrEqual
)
{
public
Hash
Map
<
String
,
QIRVariable
>
visit
(
QIRGreaterOrEqual
qirGreaterOrEqual
)
{
qirGreaterOrEqual
.
getLeft
().
accept
(
this
);
return
qirGreaterOrEqual
.
getRight
().
accept
(
this
);
}
@Override
public
Hash
Set
<
QIRVariable
>
visit
(
QIRGreaterThan
qirGreaterThan
)
{
public
Hash
Map
<
String
,
QIRVariable
>
visit
(
QIRGreaterThan
qirGreaterThan
)
{
qirGreaterThan
.
getLeft
().
accept
(
this
);
return
qirGreaterThan
.
getRight
().
accept
(
this
);
}
@Override
public
Hash
Set
<
QIRVariable
>
visit
(
QIRLowerOrEqual
qirLowerOrEqual
)
{
public
Hash
Map
<
String
,
QIRVariable
>
visit
(
QIRLowerOrEqual
qirLowerOrEqual
)
{
qirLowerOrEqual
.
getLeft
().
accept
(
this
);
return
qirLowerOrEqual
.
getRight
().
accept
(
this
);
}
@Override
public
Hash
Set
<
QIRVariable
>
visit
(
QIRLowerThan
qirLowerThan
)
{
public
Hash
Map
<
String
,
QIRVariable
>
visit
(
QIRLowerThan
qirLowerThan
)
{
qirLowerThan
.
getLeft
().
accept
(
this
);
return
qirLowerThan
.
getRight
().
accept
(
this
);
}
@Override
public
Hash
Set
<
QIRVariable
>
visit
(
QIRNotEqual
qirNotEqual
)
{
public
Hash
Map
<
String
,
QIRVariable
>
visit
(
QIRNotEqual
qirNotEqual
)
{
qirNotEqual
.
getLeft
().
accept
(
this
);
return
qirNotEqual
.
getRight
().
accept
(
this
);
}
@Override
public
Hash
Set
<
QIRVariable
>
visit
(
QIRTable
qirTable
)
{
public
Hash
Map
<
String
,
QIRVariable
>
visit
(
QIRTable
qirTable
)
{
return
freeVariables
;
}
@Override
public
Hash
Set
<
QIRVariable
>
visit
(
QIRLnil
qirLnil
)
{
public
Hash
Map
<
String
,
QIRVariable
>
visit
(
QIRLnil
qirLnil
)
{
return
freeVariables
;
}
@Override
public
Hash
Set
<
QIRVariable
>
visit
(
QIRLcons
qirLcons
)
{
public
Hash
Map
<
String
,
QIRVariable
>
visit
(
QIRLcons
qirLcons
)
{
qirLcons
.
getValue
().
accept
(
this
);
return
qirLcons
.
getTail
().
accept
(
this
);
}
@Override
public
Hash
Set
<
QIRVariable
>
visit
(
QIRLdestr
qirLdestr
)
{
public
Hash
Map
<
String
,
QIRVariable
>
visit
(
QIRLdestr
qirLdestr
)
{
qirLdestr
.
getList
().
accept
(
this
);
qirLdestr
.
getIfEmpty
().
accept
(
this
);
return
qirLdestr
.
getHandler
().
accept
(
this
);
}
@Override
public
Hash
Set
<
QIRVariable
>
visit
(
QIRTnil
qirTnil
)
{
public
Hash
Map
<
String
,
QIRVariable
>
visit
(
QIRTnil
qirTnil
)
{
return
freeVariables
;
}
@Override
public
Hash
Set
<
QIRVariable
>
visit
(
QIRTcons
qirTcons
)
{
public
Hash
Map
<
String
,
QIRVariable
>
visit
(
QIRTcons
qirTcons
)
{
qirTcons
.
getValue
().
accept
(
this
);
return
qirTcons
.
getTail
().
accept
(
this
);
}
@Override
public
Hash
Set
<
QIRVariable
>
visit
(
QIRTdestr
qirTdestr
)
{
public
Hash
Map
<
String
,
QIRVariable
>
visit
(
QIRTdestr
qirTdestr
)
{
return
qirTdestr
.
getTuple
().
accept
(
this
);
}
@Override
public
Hash
Set
<
QIRVariable
>
visit
(
QIRString
qirString
)
{
public
Hash
Map
<
String
,
QIRVariable
>
visit
(
QIRString
qirString
)
{
return
freeVariables
;
}
@Override
public
Hash
Set
<
QIRVariable
>
visit
(
QIRNumber
qirNumber
)
{
public
Hash
Map
<
String
,
QIRVariable
>
visit
(
QIRNumber
qirNumber
)
{
return
freeVariables
;
}
@Override
public
Hash
Set
<
QIRVariable
>
visit
(
QIRBigNumber
qirBigNumber
)
{
public
Hash
Map
<
String
,
QIRVariable
>
visit
(
QIRBigNumber
qirBigNumber
)
{
return
freeVariables
;
}
@Override
public
Hash
Set
<
QIRVariable
>
visit
(
QIRBoolean
qirBoolean
)
{
public
Hash
Map
<
String
,
QIRVariable
>
visit
(
QIRBoolean
qirBoolean
)
{
return
freeVariables
;
}
@Override
public
Hash
Set
<
QIRVariable
>
visit
(
QIRTruffleNode
qirTruffleNode
)
{
public
Hash
Map
<
String
,
QIRVariable
>
visit
(
QIRTruffleNode
qirTruffleNode
)
{
return
freeVariables
;
}
@Override
public
Hash
Set
<
QIRVariable
>
visit
(
QIRVariable
qirVariable
)
{
if
(!
boundVariables
.
contains
(
qirVariable
))
freeVariables
.
add
(
qirVariable
);
public
Hash
Map
<
String
,
QIRVariable
>
visit
(
QIRVariable
qirVariable
)
{
if
(!
boundVariables
.
contains
Key
(
qirVariable
.
getId
()
))
freeVariables
.
put
(
qirVariable
.
getId
(),
qirVariable
);
return
freeVariables
;
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment