我正在运行一行包含函数调用和console.log的代码。根据优先级表,函数调用library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity uart is
port ( clk : in std_logic;
rx : in std_logic;
tx : out std_logic);
end uart;
architecture Behavioral of uart is
--fsm for transmission
type fsm is (idle,b1,b2,b3,b4,b5,b6,b7,b8,b9);
signal state : fsm := idle;
--fsm for reception
type fsm1 is (idle1,b11,b21,b31,b41,b51,b61,b71,b81,b91);
signal state1 : fsm1 := idle1;
signal start : std_logic;
signal store : std_logic_vector (7 downto 0) := "00000000";
--store received data
begin
--reception
process(clk)
variable i : integer := 0; --baudtick
begin
if clk'event and clk = '1' then
i := i + 1;
if state1 = idle1 then
start <= rx;
end if;
if start = '0' then --check start bit 0
state1 <= b11;
elsif start = '1' then
state1 <= idle1;
end if;
--store 8 bits
if (state1 = b11) then --1
store(0) <= rx;
if i = 26042 then
state1 <= b21;
i := 0;
end if;
end if;
if (state1 = b21) then --2
store(1) <= rx;
if i = 26042 then
state1 <= b31;
i := 0;
end if;
end if;
if (state1 = b31) then --3
store(2) <= rx;
if i = 26042 then
state1 <= b41;
i := 0;
end if;
end if;
if (state1 = b41) then --4
store(3) <= rx;
if i = 26042 then
state1 <= b51;
i := 0;
end if;
end if;
if (state1 = b51) then --5
store(4) <= rx;
if i = 26042 then
state1 <= b61;
i := 0;
end if;
end if;
if (state1 = b61) then --6
store(5) <= rx;
if i = 26042 then
state1 <= b71;
i := 0;
end if;
end if;
if (state1 = b71) then --7
store(6) <= rx;
if i = 26042 then
state1 <= b81;
i := 0;
end if;
end if;
if (state1 = b81) then --8
store(7) <= rx;
if i = 26042 then
state1 <= idle1;
i := 0;
end if;
end if;
end if;
end process;
--transmission
process(clk)
variable i : integer := 0; --baudtick
begin
if clk'event and clk = '1' then
i := i + 1;
if state = idle then
if start = '0' then --send start bit 0
tx <= '0';
if i = 26042 then
state <= b1;
i := 0;
end if;
elsif start = '1' then
state <= idle;
end if;
end if;
--send 8 bits
if (state = b1) then --1
tx <= store(0);
if i = 26042 then
state <= b2;
i := 0;
end if;
end if;
if (state = b2) then --2
tx <= store(1);
if i = 26042 then
state <= b3;
i := 0;
end if;
end if;
if (state = b3) then --3
tx <= store(2);
if i = 26042 then
state <= b4;
i := 0;
end if;
end if;
if (state = b4) then --4
tx <= store(3);
if i = 26042 then
state <= b5;
i := 0;
end if;
end if;
if (state = b5) then --5
tx <= store(4);
if i = 26042 then
state <= b6;
i := 0;
end if;
end if;
if (state = b6) then --6
tx <= store(5);
if i = 26042 then
state <= b7;
i := 0;
end if;
end if;
if (state = b7) then --7
tx <= store(6);
if i = 26042 then
state <= b8;
i := 0;
end if;
end if;
if (state = b8) then --8
tx <= store(7);
if i = 26042 then
state <= b9;
i := 0;
end if;
end if;
if (state = b9) then --stop
tx <= '1';
if i = 26042 then
state <= idle;
i:= 0;
end if;
end if;
end if;
end process;
end Behavioral;
的运算符值为19,而分组运算符的优先级最高(20)。因此,不是应该先在分组内部做任何事情吗?
()
这将在第一行打印function fn() {
console.log("foo");
}
fn() + (console.log("bar"))
,然后在foo
上打印。
根据this,我应该看到:
bar
bar
我在这里想念什么?
答案 0 :(得分:3)
JS引擎从左到右评估'+'运算符。
构建语法树,fn()是左侧节点,另一个语句是右侧节点。解释器评估左节点并将其放入堆栈中,然后右节点将结果放入堆栈中,然后对堆栈上两个最顶部的元素执行+操作。