use of org.matheclipse.core.interfaces.IBuiltInSymbol in project symja_android_library by axkr.
the class FunctionIDGenerator method printGithubSymjaFunctionLineNumber.
public static void printGithubSymjaFunctionLineNumber() {
try {
ParserConfig.EXPLICIT_TIMES_OPERATOR = true;
F.initSymbols();
ArrayList<String> list = new ArrayList<String>();
for (int i = 0; i < AST2Expr.UPPERCASE_SYMBOL_STRINGS.length; i++) {
list.add(AST2Expr.UPPERCASE_SYMBOL_STRINGS[i]);
}
for (int i = 0; i < AST2Expr.SYMBOL_STRINGS.length; i++) {
list.add(AST2Expr.SYMBOL_STRINGS[i]);
}
for (int i = 0; i < AST2Expr.FUNCTION_STRINGS.length; i++) {
list.add(AST2Expr.FUNCTION_STRINGS[i]);
}
for (int i = 0; i < AST2Expr.DOLLAR_STRINGS.length; i++) {
list.add(AST2Expr.DOLLAR_STRINGS[i]);
}
Collections.sort(list);
int counter = 0;
System.out.println("/**\n" + " * Generated by class: <code>org.matheclipse.core.preprocessor.FunctionIDGenerator\n" + " * </code>\n" + " */\n" + "public final static int[] LINE_NUMBER_OF_JAVA_CLASS = new int[] { //");
for (int i = 0; i < list.size(); i++) {
counter++;
if (counter > 10) {
System.out.println(" //");
counter = 0;
}
ISymbol sym = F.symbol(list.get(i));
if (sym instanceof IBuiltInSymbol) {
IBuiltInSymbol builtin = (IBuiltInSymbol) sym;
IEvaluator eval = builtin.getEvaluator();
if (eval != null && eval != BuiltInSymbol.DUMMY_EVALUATOR) {
Class<? extends IEvaluator> clazz = eval.getClass();
if (//
!clazz.isAnonymousClass() && !clazz.isSynthetic() && !clazz.isInterface() && !clazz.isPrimitive()) {
//
String fileName = buildFileNameL(clazz);
File sourceLocation = new File(fileName);
int lineCounter = lineNumberOfClass(sourceLocation, list.get(i));
System.out.print(lineCounter);
} else {
System.out.print("0");
}
} else {
System.out.print("0");
}
} else {
System.out.print("0");
}
if (i < list.size() - 1) {
System.out.print(",");
}
}
System.out.print("};");
} catch (RuntimeException ex) {
System.out.println();
ex.printStackTrace();
}
}
use of org.matheclipse.core.interfaces.IBuiltInSymbol in project symja_android_library by axkr.
the class ExpressionJSONConvert method exportGraphics3DJSON.
private static JsonNode exportGraphics3DJSON(IExpr data3D) {
if (data3D.isList()) {
IAST list = (IAST) data3D;
ArrayNode temp = JSON_OBJECT_MAPPER.createArrayNode();
for (int i = 1; i < list.size(); i++) {
IExpr arg = list.getAST(i);
if (arg.isAST()) {
IAST ast = (IAST) arg;
if (ast.head().isBuiltInSymbol()) {
StringBuilder buf = new StringBuilder();
IBuiltInSymbol symbol = (IBuiltInSymbol) ast.head();
IEvaluator evaluator = symbol.getEvaluator();
if (evaluator instanceof IGraphics3D) {
// JsonNode n = ((IGraphics3D) evaluator).graphics3D(buf, (IAST) ast);
// temp.add(n);
}
}
}
}
return temp;
}
ArrayNode temp = JSON_OBJECT_MAPPER.createArrayNode();
temp.add(temp.toString());
return temp;
}
use of org.matheclipse.core.interfaces.IBuiltInSymbol in project symja_android_library by axkr.
the class Programming method rememberBlockVariables.
/**
* Remember which local variable names we use in the given <code>assignedValues</code> and <code>
* assignedRules</code>.
*
* @param variablesList initializer variables list from the <code>Block</code> function
* @param assignedValues the variables mapped to their values (IExpr) before evaluating the block
* @param assignedRules the variables mapped to their rules (RulesData) before evaluating the
* block
* @param engine the evaluation engine
*/
public static void rememberBlockVariables(IAST variablesList, final ISymbol[] symbolList, final IExpr[] assignedValues, final RulesData[] assignedRules, final EvalEngine engine) {
ISymbol variableSymbol;
for (int i = 1; i < variablesList.size(); i++) {
if (variablesList.get(i).isSymbol()) {
variableSymbol = (ISymbol) variablesList.get(i);
if (variableSymbol.isBuiltInSymbol()) {
ISymbol substitute = ((IBuiltInSymbol) variableSymbol).mapToGlobal(engine);
if (substitute != null) {
variableSymbol = substitute;
}
}
symbolList[i] = variableSymbol;
assignedValues[i] = variableSymbol.assignedValue();
assignedRules[i] = variableSymbol.getRulesData();
} else if (variablesList.get(i).isAST(S.Set, 3)) {
final IAST setFun = (IAST) variablesList.get(i);
if (setFun.arg1().isSymbol()) {
variableSymbol = (ISymbol) setFun.arg1();
if (variableSymbol.isBuiltInSymbol()) {
ISymbol substitute = ((IBuiltInSymbol) variableSymbol).mapToGlobal(engine);
if (substitute != null) {
variableSymbol = substitute;
}
}
symbolList[i] = variableSymbol;
assignedValues[i] = variableSymbol.assignedValue();
assignedRules[i] = variableSymbol.getRulesData();
}
}
}
for (int i = 1; i < variablesList.size(); i++) {
if (variablesList.get(i).isSymbol()) {
variableSymbol = symbolList[i];
variableSymbol.assignValue(null, false);
variableSymbol.setRulesData(null);
} else {
if (variablesList.get(i).isAST(S.Set, 3)) {
final IAST setFun = (IAST) variablesList.get(i);
if (setFun.arg1().isSymbol()) {
variableSymbol = symbolList[i];
IExpr temp = engine.evaluate(setFun.arg2());
variableSymbol.assignValue(temp, false);
variableSymbol.setRulesData(null);
}
}
}
}
}
use of org.matheclipse.core.interfaces.IBuiltInSymbol in project symja_android_library by axkr.
the class GraphicsFunctions method primitivesDimension.
public static boolean primitivesDimension(IAST list, Dimensions2D dim) {
for (int i = 1; i < list.size(); i++) {
if (list.get(i).isAST()) {
IAST primitive = (IAST) list.get(i);
if (primitive.head().isBuiltInSymbol()) {
IBuiltInSymbol symbol = (IBuiltInSymbol) primitive.head();
IEvaluator evaluator = symbol.getEvaluator();
if (evaluator instanceof IGraphics3D) {
if (!((IGraphics3D) evaluator).graphics2DDimension(primitive, dim)) {
// return false;
}
}
}
}
}
return true;
}
use of org.matheclipse.core.interfaces.IBuiltInSymbol in project symja_android_library by axkr.
the class GraphicsFunctions method exportGraphics3DRecursive.
public static boolean exportGraphics3DRecursive(StringBuilder buf, IAST data3D) {
if (data3D.isList()) {
boolean first = true;
IAST rgbColor = F.NIL;
IExpr opacity = F.NIL;
IAST list = data3D;
for (int i = 1; i < list.size(); i++) {
IExpr arg = list.get(i);
if (arg.isAST()) {
IAST ast = (IAST) arg;
if (ast.isList()) {
StringBuilder primitivesBuffer = new StringBuilder();
if (exportGraphics3DRecursive(primitivesBuffer, ast)) {
if (!first) {
buf.append(",");
}
first = false;
buf.append(primitivesBuffer);
}
} else if (ast.isRGBColor()) {
rgbColor = ast;
} else if (ast.isAST(S.Opacity, 2)) {
opacity = ast.arg1();
} else if (ast.head().isBuiltInSymbol()) {
IBuiltInSymbol symbol = (IBuiltInSymbol) ast.head();
IEvaluator evaluator = symbol.getEvaluator();
if (evaluator instanceof IGraphics3D) {
StringBuilder primitivesBuffer = new StringBuilder();
if (((IGraphics3D) evaluator).graphics3D(primitivesBuffer, ast, rgbColor, opacity)) {
if (!first) {
buf.append(",");
}
first = false;
buf.append(primitivesBuffer);
}
}
}
}
}
return true;
}
return false;
}
Aggregations