【问题标题】:invalid target type casting: red-context无效的目标类型转换:红色上下文
【发布时间】:2014-11-28 11:25:55
【问题描述】:

我正在使用--red-only 开关并将详细程度设置为 2,以将一个非常简单的 Red 程序编译为其 Red/System 等效程序。程序是:

Red []

red-load: func [source  [file! url! string! binary!]] [
    load source
]

它产生一定数量的输出,我将其重定向到一个文件。我的目标是为此添加一个 Red/System 标头并构建它。

在去掉一些注释行之后,下一个障碍是这段代码至少没有扩展一些宏,所以我不得不为runtime/macros.reds 添加一个#include。但是后来我在扩展其中一个(宏 TO_CTX)时遇到了这个错误:

*** Compilation Error: invalid target type casting: red-context! 
*** in file: %/home/hostilefork/Projects/red/embedme.reds 
*** in function: f_modulo
*** at line: 11 
*** near: (as red-context! ((as series! ctx15/value) + 1))

我已经看到在 Red 运行时代码中使用了 red-context! 和其他一些 red-*! 数据类型......当 Red/System 需要谈论它从 Red 获得的值时。但他们没有提到in the Red/System spec。它们可以在普通的红色/系统代码中使用,还是有一些“特殊”的东西只允许它们在内部使用?

【问题讨论】:

    标签: red red-system


    【解决方案1】:

    如果您想获得完整的红色/系统输出,详细程度 2 不是正确的设置,详细程度应设置为 3 (-v 3)。我从来没有尝试过实际编译这样的输出,所以我不确定它是否会起作用。 --red-only? 选项用于调试来自高级 Red 编译器的 Red/System 输出。

    red-*! 定义是 Red 内部结构上的宏,它们不是 Red/System 的一部分。它们在红色runtime library 中定义。

    【讨论】:

    • 谢谢,稍作调整即可使用。在这种情况下,只需将 output: 的内容搜索并替换为 ~% => ~percent, ~// => ~slashslash, ~/ => ~slash...然后为red.reds 添加一个#include
    猜你喜欢
    • 2018-08-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多