Add `reource_type` and `resource_id` to point lookup (required for variable MARK AS)
parent
75bbeb7281
commit
539f19c360
|
@ -65,7 +65,6 @@ defmodule FarmbotCeleryScript.Compiler do
|
|||
end
|
||||
|
||||
def compile(%AST{kind: kind} = ast, env) when kind in @valid_entry_points do
|
||||
raise "This is the entrypoint to everything... Figure out where :name, :x, :y, :z come from..."
|
||||
compile_entry_point(compile_ast(ast, env), env, [])
|
||||
end
|
||||
|
||||
|
@ -78,7 +77,9 @@ defmodule FarmbotCeleryScript.Compiler do
|
|||
# TODO: investigate why i have to turn this to a string
|
||||
# before eval ing it?
|
||||
# case Code.eval_quoted(compiled, [], __ENV__) do
|
||||
case Macro.to_string(compiled) |> Code.eval_string(new_env, __ENV__) do
|
||||
result = Macro.to_string(compiled) |> Code.eval_string(new_env, __ENV__)
|
||||
|
||||
case result do
|
||||
{fun, new_env} when is_function(fun, 1) ->
|
||||
env = Keyword.merge(env, new_env)
|
||||
compile_entry_point(rest, env, acc ++ apply(fun, [env]))
|
||||
|
|
|
@ -8,8 +8,18 @@ defmodule FarmbotOS.SysCalls.PointLookup do
|
|||
|
||||
def point(kind, id) do
|
||||
case Asset.get_point(id: id) do
|
||||
nil -> {:error, "#{kind || "point?"} #{id} not found"}
|
||||
%{name: name, x: x, y: y, z: z} -> %{name: name, x: x, y: y, z: z}
|
||||
nil ->
|
||||
{:error, "#{kind || "point?"} #{id} not found"}
|
||||
|
||||
%{name: name, x: x, y: y, z: z} ->
|
||||
%{
|
||||
name: name,
|
||||
resource_type: "Point",
|
||||
resource_id: id,
|
||||
x: x,
|
||||
y: y,
|
||||
z: z
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ defmodule FarmbotOS.SysCalls.PointLookupTest do
|
|||
|
||||
test "failure cases" do
|
||||
err1 = PointLookup.point("GenericPointer", 24)
|
||||
assert {:error, "GenericPointer not found"} == err1
|
||||
assert {:error, "GenericPointer 24 not found"} == err1
|
||||
|
||||
err2 = PointLookup.get_toolslot_for_tool(24)
|
||||
assert {:error, "Could not find point for tool by id: 24"} == err2
|
||||
|
@ -33,7 +33,9 @@ defmodule FarmbotOS.SysCalls.PointLookupTest do
|
|||
name: "test suite III",
|
||||
x: 1.2,
|
||||
y: 3.4,
|
||||
z: 5.6
|
||||
z: 5.6,
|
||||
resource_id: 555,
|
||||
resource_type: "Point"
|
||||
}
|
||||
|
||||
p = point(expected)
|
||||
|
|
Loading…
Reference in New Issue