Skip to content

Instantly share code, notes, and snippets.

@Jingbang-liu-lix
Created October 1, 2019 01:33
Show Gist options
  • Save Jingbang-liu-lix/4d5ffc51d973086617d183f9fb14ff32 to your computer and use it in GitHub Desktop.
Save Jingbang-liu-lix/4d5ffc51d973086617d183f9fb14ff32 to your computer and use it in GitHub Desktop.
Auto-generated Evaluation Node Example
/**
* Implementation of in operation of Lix DSL
*/
public abstract class AbstractInEvalNode implements AbstractEvalNode<Boolean> {
/**
* Grammar name of the element as it appears in Lix DSL.
*/
public static final String GRAMMAR_ID = "in";
/**
* Overload of <code>in</code> operation with signature <code>bool execute(long,collection<long>)</code>
*
* @param arg0 - long
* @param arg1 - collection<long>
*/
public abstract Boolean execute(DslExecutionContext context, Long arg0, com.linkedin.lix.dsl.v2.types.LongSet arg1);
/**
* Overload of <code>in</code> operation with signature <code>bool execute(string,collection<string>)</code>
*
* @param arg0 - string
* @param arg1 - collection<string>
*/
public abstract Boolean execute(DslExecutionContext context, String arg0, com.linkedin.lix.dsl.v2.types.StringSet arg1);
/**
* Overload of <code>in</code> operation with signature <code>bool execute(collection<long>,collection<long>)</code>
*
* @param arg0 - collection<long>
* @param arg1 - collection<long>
*/
public abstract Boolean execute(DslExecutionContext context, com.linkedin.lix.dsl.v2.types.LongSet arg0, com.linkedin.lix.dsl.v2.types.LongSet arg1);
/**
* Overload of <code>in</code> operation with signature <code>bool execute(collection<string>,collection<string>)</code>
*
* @param arg0 - collection<string>
* @param arg1 - collection<string>
*/
public abstract Boolean execute(DslExecutionContext context, com.linkedin.lix.dsl.v2.types.StringSet arg0, com.linkedin.lix.dsl.v2.types.StringSet arg1);
@Override
public Boolean compute(DslExecutionContext context, AbstractEvalTree tree, int thisNodeIndex) {
if (tree.getChildCount(thisNodeIndex) != 2) {
return null;
}
final int childListOffset = tree.getChildListOffset(thisNodeIndex);
final int disabledOverloadBits = tree.getDisabledOverloadBits(thisNodeIndex);
final Object child0Value = tree.computeNode(childListOffset + 0, context);
if (child0Value == null) {
return null;
}
final Object child1Value = tree.computeNode(childListOffset + 1, context);
if (child1Value == null) {
return null;
}
return callSpecificOverload(context, child0Value, child1Value, disabledOverloadBits);
}
public Boolean callSpecificOverload(final DslExecutionContext context, final Object objParam0, final Object objParam1, int disabledOverloadBits) {
while ((disabledOverloadBits & (1 << 0)) == 0) {
Long param0;
com.linkedin.lix.dsl.v2.types.LongSet param1;
if (objParam0 instanceof Long) {
param0 = (Long) objParam0;
} else {
break;
}
if (objParam1 instanceof com.linkedin.lix.dsl.v2.types.LongSet) {
param1 = (com.linkedin.lix.dsl.v2.types.LongSet) objParam1;
} else {
break;
}
return execute(context, param0, param1);
}
while ((disabledOverloadBits & (1 << 1)) == 0) {
String param0;
com.linkedin.lix.dsl.v2.types.StringSet param1;
if (objParam0 instanceof String) {
param0 = (String) objParam0;
} else {
break;
}
if (objParam1 instanceof com.linkedin.lix.dsl.v2.types.StringSet) {
param1 = (com.linkedin.lix.dsl.v2.types.StringSet) objParam1;
} else {
break;
}
return execute(context, param0, param1);
}
while ((disabledOverloadBits & (1 << 2)) == 0) {
com.linkedin.lix.dsl.v2.types.LongSet param0;
com.linkedin.lix.dsl.v2.types.LongSet param1;
if (objParam0 instanceof com.linkedin.lix.dsl.v2.types.LongSet) {
param0 = (com.linkedin.lix.dsl.v2.types.LongSet) objParam0;
} else {
break;
}
if (objParam1 instanceof com.linkedin.lix.dsl.v2.types.LongSet) {
param1 = (com.linkedin.lix.dsl.v2.types.LongSet) objParam1;
} else {
break;
}
return execute(context, param0, param1);
}
while ((disabledOverloadBits & (1 << 3)) == 0) {
com.linkedin.lix.dsl.v2.types.StringSet param0;
com.linkedin.lix.dsl.v2.types.StringSet param1;
if (objParam0 instanceof com.linkedin.lix.dsl.v2.types.StringSet) {
param0 = (com.linkedin.lix.dsl.v2.types.StringSet) objParam0;
} else {
break;
}
if (objParam1 instanceof com.linkedin.lix.dsl.v2.types.StringSet) {
param1 = (com.linkedin.lix.dsl.v2.types.StringSet) objParam1;
} else {
break;
}
return execute(context, param0, param1);
}
return null; // overload not found
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment