📄 mathcommands.java
字号:
aEnvironment.iInputStatus.RestoreFrom(oldstatus); } //Return the result } } class LispFromString extends YacasEvalCaller { public void Eval(LispEnvironment aEnvironment,int aStackTop) throws Exception { LispPtr evaluated = new LispPtr(); aEnvironment.iEvaluator.Eval(aEnvironment, evaluated, ARGUMENT(aEnvironment, aStackTop, 1)); // Get file name LispError.CHK_ARG_CORE(aEnvironment,aStackTop,evaluated.Get() != null, 1); String orig = evaluated.Get().String(); LispError.CHK_ARG_CORE(aEnvironment,aStackTop,orig != null, 1); String oper = LispStandard.InternalUnstringify(orig); InputStatus oldstatus = aEnvironment.iInputStatus; aEnvironment.iInputStatus.SetTo("String"); StringInput newInput = new StringInput(new StringBuffer(oper),aEnvironment.iInputStatus); LispInput previous = aEnvironment.iCurrentInput; aEnvironment.iCurrentInput = newInput; try { // Evaluate the body aEnvironment.iEvaluator.Eval(aEnvironment, RESULT(aEnvironment, aStackTop), ARGUMENT(aEnvironment, aStackTop, 2)); } catch (Exception e) { throw e; } finally { aEnvironment.iCurrentInput = previous; aEnvironment.iInputStatus.RestoreFrom(oldstatus); } //Return the result } } class LispRead extends YacasEvalCaller { public void Eval(LispEnvironment aEnvironment,int aStackTop) throws Exception { InfixParser parser = new InfixParser(aEnvironment.iCurrentTokenizer, aEnvironment.iCurrentInput, aEnvironment, aEnvironment.iPrefixOperators, aEnvironment.iInfixOperators, aEnvironment.iPostfixOperators, aEnvironment.iBodiedOperators); // Read expression parser.Parse(RESULT(aEnvironment, aStackTop)); } } class LispReadToken extends YacasEvalCaller { public void Eval(LispEnvironment aEnvironment,int aStackTop) throws Exception { LispTokenizer tok = aEnvironment.iCurrentTokenizer; String result; result = tok.NextToken(aEnvironment.iCurrentInput, aEnvironment.HashTable()); if (result.length() == 0) { RESULT(aEnvironment, aStackTop).Set(aEnvironment.iEndOfFile.Copy(false)); return; } RESULT(aEnvironment, aStackTop).Set(LispAtom.New(aEnvironment,result)); } } class LispToFile extends YacasEvalCaller { public void Eval(LispEnvironment aEnvironment,int aStackTop) throws Exception { LispError.CHK_CORE(aEnvironment, aStackTop,aEnvironment.iSecure == false, LispError.KLispErrSecurityBreach); LispPtr evaluated = new LispPtr(); aEnvironment.iEvaluator.Eval(aEnvironment, evaluated, ARGUMENT(aEnvironment, aStackTop, 1)); // Get file name LispError.CHK_ARG_CORE(aEnvironment,aStackTop,evaluated.Get() != null, 1); String orig = evaluated.Get().String(); LispError.CHK_ARG_CORE(aEnvironment,aStackTop,orig != null, 1); String oper = LispStandard.InternalUnstringify(orig); // Open file for writing FileOutputStream localFP = new FileOutputStream(oper); LispError.CHK_CORE(aEnvironment, aStackTop,localFP != null, LispError.KLispErrFileNotFound); StdFileOutput newOutput = new StdFileOutput(localFP); LispOutput previous = aEnvironment.iCurrentOutput; aEnvironment.iCurrentOutput = newOutput; try { aEnvironment.iEvaluator.Eval(aEnvironment, RESULT(aEnvironment, aStackTop), ARGUMENT(aEnvironment, aStackTop, 2)); } catch (Exception e) { throw e; } finally { aEnvironment.iCurrentOutput = previous; } } } class LispToString extends YacasEvalCaller { public void Eval(LispEnvironment aEnvironment,int aStackTop) throws Exception { StringBuffer oper = new StringBuffer(); StringOutput newOutput = new StringOutput(oper); LispOutput previous = aEnvironment.iCurrentOutput; aEnvironment.iCurrentOutput = newOutput; try { // Evaluate the body aEnvironment.iEvaluator.Eval(aEnvironment, RESULT(aEnvironment, aStackTop), ARGUMENT(aEnvironment, aStackTop, 1)); //Return the result RESULT(aEnvironment, aStackTop).Set(LispAtom.New(aEnvironment,aEnvironment.HashTable().LookUpStringify(oper.toString()))); } catch (Exception e) { throw e; } finally { aEnvironment.iCurrentOutput = previous; } } } class LispToStdout extends YacasEvalCaller { public void Eval(LispEnvironment aEnvironment,int aStackTop) throws Exception { LispOutput previous = aEnvironment.iCurrentOutput; aEnvironment.iCurrentOutput = aEnvironment.iInitialOutput; try { aEnvironment.iEvaluator.Eval(aEnvironment, RESULT(aEnvironment, aStackTop), ARGUMENT(aEnvironment, aStackTop, 1)); } catch (Exception e) { throw e; } finally { aEnvironment.iCurrentOutput = previous; } } } class LispLoad extends YacasEvalCaller { public void Eval(LispEnvironment aEnvironment,int aStackTop) throws Exception { LispError.CHK_CORE(aEnvironment, aStackTop,aEnvironment.iSecure == false, LispError.KLispErrSecurityBreach); LispPtr evaluated = new LispPtr(); evaluated.Set(ARGUMENT(aEnvironment, aStackTop, 1).Get()); // Get file name LispError.CHK_ARG_CORE(aEnvironment,aStackTop,evaluated.Get() != null, 1); String orig = evaluated.Get().String(); LispError.CHK_ARG_CORE(aEnvironment,aStackTop,orig != null, 1); LispStandard.InternalLoad(aEnvironment,orig); LispStandard.InternalTrue(aEnvironment,RESULT(aEnvironment, aStackTop)); } } class LispSetVar extends YacasEvalCaller { public void Eval(LispEnvironment aEnvironment,int aStackTop) throws Exception { MathCommands.InternalSetVar(aEnvironment, aStackTop, false); } } class LispMacroSetVar extends YacasEvalCaller { public void Eval(LispEnvironment aEnvironment,int aStackTop) throws Exception { MathCommands.InternalSetVar(aEnvironment, aStackTop, true); } } class LispClearVar extends YacasEvalCaller { public void Eval(LispEnvironment aEnvironment,int aStackTop) throws Exception { LispPtr subList = ARGUMENT(aEnvironment, aStackTop, 1).Get().SubList(); if (subList != null) { LispIterator iter = new LispIterator(subList); iter.GoNext(); int nr=1; while (iter.GetObject() != null) { String str; str = iter.GetObject().String(); LispError.CHK_ARG_CORE(aEnvironment,aStackTop,str != null, nr); aEnvironment.UnsetVariable(str); iter.GoNext(); nr++; } } LispStandard.InternalTrue(aEnvironment,RESULT(aEnvironment, aStackTop)); } } class LispNewLocal extends YacasEvalCaller { public void Eval(LispEnvironment aEnvironment,int aStackTop) throws Exception { LispPtr subList = ARGUMENT(aEnvironment, aStackTop, 1).Get().SubList(); if (subList!= null) { LispIterator iter = new LispIterator(subList); iter.GoNext(); int nr = 1; while (iter.GetObject() != null) { String variable = iter.GetObject().String(); LispError.CHK_ARG_CORE(aEnvironment,aStackTop,variable != null,nr); // printf("Variable %s\n",variable.String()); aEnvironment.NewLocal(variable,null); iter.GoNext(); nr++; } } LispStandard.InternalTrue(aEnvironment,RESULT(aEnvironment, aStackTop)); } } class LispHead extends YacasEvalCaller { public void Eval(LispEnvironment aEnvironment,int aStackTop) throws Exception { LispStandard.InternalNth(RESULT(aEnvironment, aStackTop), ARGUMENT(aEnvironment, aStackTop, 1),1); } } class LispNth extends YacasEvalCaller { public void Eval(LispEnvironment aEnvironment,int aStackTop) throws Exception { String str; str = ARGUMENT(aEnvironment, aStackTop, 2).Get().String(); LispError.CHK_ARG_CORE(aEnvironment,aStackTop,str != null,2); LispError.CHK_ARG_CORE(aEnvironment,aStackTop,LispStandard.IsNumber(str,false),2); int index = Integer.parseInt(str); LispStandard.InternalNth(RESULT(aEnvironment, aStackTop), ARGUMENT(aEnvironment, aStackTop, 1), index); } } class LispTail extends YacasEvalCaller { public void Eval(LispEnvironment aEnvironment,int aStackTop) throws Exception { LispPtr first = new LispPtr(); LispStandard.InternalTail(first, ARGUMENT(aEnvironment, aStackTop, 1)); LispStandard.InternalTail(RESULT(aEnvironment, aStackTop), first); LispPtr head = new LispPtr(); head.Set(aEnvironment.iList.Copy(false)); head.Get().Next().Set(RESULT(aEnvironment, aStackTop).Get().SubList().Get()); RESULT(aEnvironment, aStackTop).Get().SubList().Set(head.Get()); } } class LispDestructiveReverse extends YacasEvalCaller { public void Eval(LispEnvironment aEnvironment,int aStackTop) throws Exception { LispPtr reversed = new LispPtr(); reversed.Set(aEnvironment.iList.Copy(false)); LispStandard.InternalReverseList(reversed.Get().Next(), ARGUMENT(aEnvironment, aStackTop, 1).Get().SubList().Get().Next()); RESULT(aEnvironment, aStackTop).Set(LispSubList.New(reve
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -