public SubLObject eval(final SubLEnvironment env) { Values.resetMultipleValues(); SubLObject operatorSymbol = first(); if (operatorSymbol.isSymbol()) { SubLOperator operator = operatorSymbol.toSymbol().getFunction(); if (operator.isFunction()) { return operator.getFunc().evalViaApply(this.toCons(), env); } if (operator.isSpecial()) { final SubLFunction func = operator.toSpecialOperator().getEvaluationFunction(); final BinaryFunction binFunc = func.getBinaryFunction(); if (binFunc != null) { return binFunc.processItem(toCons(), env); } return func.apply(this.toCons(), env); } if (operator.isMacroOperator()) { return operator .toMacro() .getMacroExpander() .apply(this.asConsList().toCons(), env) .eval(env); // @hack asConsList() call } Errors.error(operatorSymbol + " does not have a function value."); } else if (SubLInterpretedFunction.isPossiblyLambdaExpression(operatorSymbol, true)) { final SubLInterpretedFunction lambda = SubLOperatorFactory.makeInterpretedFunction(operatorSymbol.toCons(), env); return lambda.evalViaApply(this.toCons(), env); } throw new InvalidSubLExpressionException(operatorSymbol + " is not an operator."); }
private final SubLList mapResult(UnaryFunction function, boolean returnConsedResults) { SubLList result = SubLNil.NIL; for (SubLObject cur = this; cur != SubLNil.NIL; cur = cur.rest()) { final SubLObject curResult = function.processItem(cur.first()); if (returnConsedResults) { result = SubLObjectFactory.makeCons(curResult, result); } } if (returnConsedResults) { return result.asConsList().reverse(true).toList(); } return result; }
@SubL(source = "sublisp/condition-macros.lisp", position = 821) public static final SubLObject with_simple_restart(SubLObject macroform, SubLObject environment) { { SubLObject datum = macroform.rest(); SubLObject current = datum; cdestructuring_bind.destructuring_bind_must_consp(current, datum, $list0); { SubLObject temp = current.rest(); current = current.first(); { SubLObject name = NIL; SubLObject format_control = NIL; cdestructuring_bind.destructuring_bind_must_consp(current, datum, $list0); name = current.first(); current = current.rest(); cdestructuring_bind.destructuring_bind_must_consp(current, datum, $list0); format_control = current.first(); current = current.rest(); { SubLObject format_arguments = current; current = temp; { SubLObject body = current; return with_simple_restart_internal(name, format_control, format_arguments, body); } } } } } }
/** Return the value for INDICATOR in PLIST, or DEFAULT if not present */ public final SubLObject getf(SubLObject indicator, SubLObject v_default) { // @todo get rid of duplication with conses_high...this version shoul prevail // @todo hand optimize this code if ((v_default == CommonSymbols.UNPROVIDED)) { v_default = SubLNil.NIL; } SubLObject next = SubLNil.NIL; SubLObject key = SubLNil.NIL; for (next = this, key = ConsesLow.car(next); (SubLNil.NIL == Types.sublisp_null(next)); next = next.rest().rest(), key = ConsesLow.car(next)) { if ((indicator == key)) { return next.second(); } } return v_default; }
/** Execute BODY as an implicit progn, until it either finishes or any error occurs. */ @SubL(source = "sublisp/condition-macros.lisp", position = 3220) public static final SubLObject ignore_errors(SubLObject macroform, SubLObject environment) { { SubLObject datum = macroform.rest(); SubLObject current = datum; SubLObject body = current; return ignore_errors_internal(body); } }
@SubL(source = "cycl/subl-macros.lisp", position = 14186) public static final SubLObject do_sequence_index_doneP( SubLObject index, SubLObject end_index, SubLObject sequence) { if (sequence.isList()) { return Types.sublisp_null(sequence); } else { return Numbers.numE(index, end_index); } }
/** Trampoline CYC-LISP:ERROR to SL:ERROR. */ @SubL(source = "sublisp/condition-macros.lisp", position = 1739) public static final SubLObject with_sublisp_error_handling( SubLObject macroform, SubLObject environment) { { SubLObject datum = macroform.rest(); SubLObject current = datum; SubLObject body = current; return with_sublisp_error_handling_internal(body); } }
public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } SubLObject sublObj = (SubLObject) obj; if (!sublObj.isList()) { return false; } SubLList otherCons = sublObj.toList(); SubLListListIterator iter1 = null; SubLListListIterator iter2 = null; Resourcer resourcer = Resourcer.getInstance(); try { iter1 = resourcer.acquireSubLListListIterator(this); iter2 = resourcer.acquireSubLListListIterator(otherCons); while (iter1.hasNext() && (!iter1.isNextImproperElement())) { if ((!iter2.hasNext()) || (iter2.isNextImproperElement())) { return false; } if (!iter1.next().equals(iter2.next())) { return false; } } if (iter1.isNextImproperElement()) { if (iter2.isNextImproperElement()) { return iter1.getDottedElement().equals(iter2.getDottedElement()); } return false; } else if (iter2.hasNext()) { // iter1 is prefix of iter2 case return false; } // they should be equal at this point return true; } finally { resourcer.releaseSubLListListIterator(iter1); resourcer.releaseSubLListListIterator(iter2); } }
/** Return a plist which has no value stored for INDICATOR in PLIST */ public final SubLList remf(SubLObject indicator) { // @todo get rid of duplication with conses_high...this version shoul prevail // @todo hand optimize this code SubLObject back = SubLNil.NIL; SubLObject next = SubLNil.NIL; SubLObject key = SubLNil.NIL; for (back = SubLNil.NIL, next = this, key = ConsesLow.car(next); (SubLNil.NIL == Types.sublisp_null(next)); back = ConsesLow.cdr(next), next = next.rest().rest(), key = ConsesLow.car(next)) { if ((indicator == key)) { if ((SubLNil.NIL != back)) { ConsesLow.rplacd(back, next.rest().rest()); return this; } else { return next.rest().rest().toList(); } } } return this; }
@SubL(source = "cycl/constant-completion.lisp", position = 2143) public static final SubLObject compute_bogus_constant_names_in_code() { { final SubLThread thread = SubLProcess.currentSubLThread(); if ((NIL != $constant_names_in_code$.getGlobalValue())) { { SubLObject _prev_bind_0 = utilities_macros.$noting_progress_start_time$.currentBinding(thread); try { utilities_macros.$noting_progress_start_time$.bind(Time.get_universal_time(), thread); utilities_macros.noting_progress_preamble($str4$Computing_bogus_constant_names_in); $bogus_constant_names_in_code$.setGlobalValue(NIL); { SubLObject cdolist_list_var = $constant_names_in_code$.getGlobalValue(); SubLObject name = NIL; for (name = cdolist_list_var.first(); (NIL != cdolist_list_var); cdolist_list_var = cdolist_list_var.rest(), name = cdolist_list_var.first()) { { SubLObject constant = constants_high.find_constant(name); if ((NIL != constants_high.uninstalled_constant_p(constant))) { $bogus_constant_names_in_code$.setGlobalValue( cons(name, $bogus_constant_names_in_code$.getGlobalValue())); } } } } $bogus_constant_names_in_code$.setGlobalValue( Sort.sort( $bogus_constant_names_in_code$.getGlobalValue(), Symbols.symbol_function($sym3$STRING_), UNPROVIDED)); utilities_macros.noting_progress_postamble(); } finally { utilities_macros.$noting_progress_start_time$.rebind(_prev_bind_0, thread); } } } return Sequences.length($bogus_constant_names_in_code$.getGlobalValue()); } }
@SubL(source = "cycl/constant-completion.lisp", position = 1600) public static final SubLObject initialize_constant_names_in_code() { if (ZERO_INTEGER.numE(constant_handles.constant_count())) { $constant_names_in_code$.setGlobalValue(NIL); { SubLObject cdolist_list_var = constant_handles.invalid_constant_names(); SubLObject invalid_constant_name = NIL; for (invalid_constant_name = cdolist_list_var.first(); (NIL != cdolist_list_var); cdolist_list_var = cdolist_list_var.rest(), invalid_constant_name = cdolist_list_var.first()) { $constant_names_in_code$.setGlobalValue( cons(invalid_constant_name, $constant_names_in_code$.getGlobalValue())); } } $constant_names_in_code$.setGlobalValue( Sort.sort( $constant_names_in_code$.getGlobalValue(), Symbols.symbol_function($sym3$STRING_), UNPROVIDED)); } return Sequences.length($constant_names_in_code$.getGlobalValue()); }
/** * Generate a KB SBHL caching policy proposal for sticky SBHL caching that for all passed link * predicates. * * @param WITH-PREFETCH-P determines whether the prefetch will be all or none * @return the policies */ @SubL(source = "cycl/builder-utilities.lisp", position = 38500) public static final SubLObject propose_all_sticky_kb_sbhl_caching_policies( SubLObject link_predicates, SubLObject with_prefetch_p) { if ((NIL == link_predicates)) { link_predicates = get_all_sbhl_module_link_predicates(); } { SubLObject prefetch = ((NIL != with_prefetch_p) ? ((SubLObject) $kw58$ALL) : NIL); SubLObject policies = NIL; SubLObject cdolist_list_var = link_predicates; SubLObject link_predicate = NIL; for (link_predicate = cdolist_list_var.first(); (NIL != cdolist_list_var); cdolist_list_var = cdolist_list_var.rest(), link_predicate = cdolist_list_var.first()) { { SubLObject legacy_policy = sbhl_caching_policies.create_sbhl_caching_policy_from_term_recommendation_list( link_predicate, $kw56$STICKY, $kw57$UNDEFINED, NIL, $kw58$ALL, prefetch); policies = cons(legacy_policy, policies); } } return Sequences.nreverse(policies); } }