我怀疑任何人都可以帮助解决这个问题,因为Erlang的编译文档中有以下内容:
请注意,汇编程序文件的格式未记录,并且可能在发行版之间更改 - 此选项主要用于内部调试.
...但为了以防万一,这里是故事的堆栈跟踪:
不幸的是,我只是快速浏览了编译包含以下函数的模块时生成的.S文件,有和没有函数注释掉的第一个表达式:
spawn_worker(Which) ->
%syner:sync_pt(),
case Which of
?NAIVE -> spawn(err1, naive_worker_loop, [])
end.
Run Code Online (Sandbox Code Playgroud)
当我这样做时,我认为唯一改变的是元组:
{call_ext,0,{extfunc,syner,sync_pt,0}}.
...所以我认为在程序集中注入一个函数调用所需的唯一东西就是添加那个元组...但是现在我必须实际注入元组...我看到生成的程序集有一些额外说明:
没有syner:sync_pt():
{function, spawn_worker, 1, 4}.
{label,3}.
{func_info,{atom,err1},{atom,spawn_worker},1}.
{label,4}.
{test,is_eq_exact,{f,5},[{x,0},{atom,naive}]}.
{move,{atom,naive_worker_loop},{x,1}}.
{move,nil,{x,2}}.
{move,{atom,err1},{x,0}}.
{call_ext_only,3,{extfunc,erlang,spawn,3}}.
{label,5}.
{case_end,{x,0}}.
Run Code Online (Sandbox Code Playgroud)
使用syner:sync_pt():
{function, spawn_worker, 1, 4}.
{label,3}.
{func_info,{atom,err1},{atom,spawn_worker},1}.
{label,4}.
{allocate,1,1}.
{move,{x,0},{y,0}}.
{call_ext,0,{extfunc,syner,sync_pt,0}}.
{test,is_eq_exact,{f,5},[{y,0},{atom,naive}]}.
{move,{atom,naive_worker_loop},{x,1}}.
{move,nil,{x,2}}.
{move,{atom,err1},{x,0}}.
{call_ext_last,3,{extfunc,erlang,spawn,3},1}.
{label,5}.
{case_end,{y,0}}.
Run Code Online (Sandbox Code Playgroud)
我不能仅仅得出结论:
{allocate,1,1}.
{move,{x,0},{y,0}}.
{call_ext,0,{extfunc,syner,sync_pt,0}}.
Run Code Online (Sandbox Code Playgroud)
我希望将每个函数注入一个外部函数调用,就可以了.
强烈建议程序员不要进行解析转换,也不要对遇到的问题提供支持.
为什么强烈建议程序员不要使用parse_transform/2?这将不会得到支持吗?除了parse_transform/2之外,是否有一种机制可以在编译之前注入代码(运行时字节码修改)或修改源代码?
我正在使用DrawerNavigator,只要我想导航到一个新的屏幕,一切都很好.
现在我想添加一个抽屉项目,它不会导航到新的屏幕,而只是触发一个动作(一般情况下).具体来说,我想使用'react-native'共享功能.
我让这个工作,但我认为解决方案不是很好.这是我到目前为止所得到的:
const myContentComponent = props => (
<ScrollView alwaysBounceVertical={false}>
<SafeAreaView style={{ flex: 1 }} forceInset={{ top: 'always', horizontal: 'never' }}>
<DrawerItems {...props} />
<TouchableItem
key="share"
onPress={() => {
Share.share(
{
message: 'YO: this will be the text message',
url: 'http://tmp.com',
title: 'This will be the email title/subject',
},
{
// Android only:
dialogTitle: 'This will be the title in the dialog to choose means of sharing',
},
);
props.navigation.navigate('DrawerClose');
}}
delayPressIn={0}
>
<SafeAreaView forceInset={{ left: 'always', right: 'never', …Run Code Online (Sandbox Code Playgroud) 我只想versioneditems在MongoDB中有一个集合,但是我需要同时注册VersionedItem模型和ItemPatch模型,因为我需要创建ItemPatches来填充VersionedItem。
将没有单独的ItemPatch文档(它们嵌入在中VersionedItem)。除了在MongoDB中创建了一个额外的集合外,以下代码可以正常工作:
src / models / versionedItemFactory.js
const VersionedItemSchema = require('../schemas/VersionedItem');
module.exports = (db) => {
var VersionedItemModel = db.model('VersionedItem', VersionedItemSchema);
return VersionedItemModel;
};
Run Code Online (Sandbox Code Playgroud)
src / models / itemPatchFactory.js
const ItemPatchSchema = require('../schemas/ItemPatch');
module.exports = (db) => {
var ItemPatchModel = db.model('ItemPatch', ItemPatchSchema);
return ItemPatchModel;
};
Run Code Online (Sandbox Code Playgroud)
src / schemas / util / asPatch.js
var mongoose = require('mongoose');
module.exports = function _asPatch(schema) {
return new mongoose.Schema({
createdAt: …Run Code Online (Sandbox Code Playgroud) 有没有办法使用匹配规范在函数的不同子句之间进行选择?我已经看到匹配规范仅用于跟踪或匹配ets表中的条目.
我想做的例子:
在用户提供的文件中:
Module(m1),
Function(f1),
Guard([ %% list of match specifications follows:
%% First (and only in this case) match spec:
{ [{score, '$1', '$2', '$3'}, '$4'],
[{is_atom, '$1'}, {is_pid, '$2'}, {is_atom, '$3'}],
[true] }
]).
Run Code Online (Sandbox Code Playgroud)
从这个文件我想生成代码.对我来说重要的是能够使用Guard中的匹配规范来过滤掉f1的子句,这样我就可以知道f1的第一个参数何时是形式的元组{score,First,Second,第三个}和is_atom(第一个),is_pid(第二个),is_atom(第三个).
有没有办法让我生成这样的代码:
case some_unknown_function(MatchSpec, F1Args) of
true ->
%% f1's clause matches the MatchSpec
;
false ->
%% f1's clause does not match the MatchSpec
end.
Run Code Online (Sandbox Code Playgroud)
任何帮助将非常感激.谢谢.
这个差异显着吗?是吗:
\n\n我正在阅读async的文档,并看到到处都有“iteratee”的使用。好吧,它不执行实际的迭代,因此迭代器不是它的正确名称。但根据我对上面“iteratee”的理解,它也不应该是一个函数(在我看来,iteratee = 数据结构 - 如果有的话,迭代器就是执行迭代的函数)。
\n\n如果您不熟悉asynciteratee:它是一个带有 2 个参数的函数,您要迭代的集合中的下一个值,以及一个带有错误值和结果值的函数。您应该在 iteratee 中执行异步操作,然后使用错误或结果调用它的第二个参数(函数(err,结果))。
(然后,您将另一个回调作为参数(除了 iteratee 之外)提供给您正在执行的任何操作(映射、过滤器等\xe2\x80\xa6),以处理在 iteratee 中调用异步操作的结果初始集合的元素)。
\n\n只是好奇:“iteratee”这个名字正确吗?
\n