@@ -8,9 +8,9 @@ use std::{borrow::Cow, mem::forget, ops::Deref, vec::Vec as StdVec};
88use bumpalo:: { Bump , collections:: Vec } ;
99use either:: Either ;
1010use parser:: {
11- ArrayOperator , Ast , Atom , BinaryOperator , BinaryPlaceOperator , Body , Command , Expr , ExprNode ,
12- Function as AstFunction , FunctionTable , Identifier , MetaId , Place , Rule , RulePattern ,
13- SimpleStatement , Statement , UnaryOperator , UnaryPlaceOperator , Variable ,
11+ ArrayOperator , Ast , Atom , BinaryOperator , BinaryPlaceOperator , Body , BuiltinFunction , Command ,
12+ Expr , ExprNode , Function as AstFunction , FunctionTable , Identifier , MetaId , Place , Rule ,
13+ RulePattern , SimpleStatement , Statement , UnaryOperator , UnaryPlaceOperator , Variable ,
1414} ;
1515
1616use crate :: {
@@ -654,7 +654,31 @@ impl<'a> CodeGen<'a> {
654654 this. emit ( Instruction :: UserCall { dest, start, end, name } ) ;
655655 }
656656 ExprNode :: BuiltinCall ( fun, args) => {
657- let ( start, end, ( ) ) = this. gen_call_convention ( args, |_| ( ) ) ;
657+ // Bypass regular variable lookups on type-info funs.
658+ let ( start, end, _) = match fun {
659+ BuiltinFunction :: Typeof | BuiltinFunction :: Isarray
660+ if let & [ Expr :: Leaf ( Atom :: Variable ( var) , _) ] =
661+ args. as_slice ( ) =>
662+ {
663+ let TypedArg ( arg, ty) =
664+ this. load_place ( dest, & Place :: Variable ( var) ) ;
665+ this. emit ( Instruction :: PureCopy { dest, arg, ty } ) ;
666+ ( dest, Reg ( dest. 0 + 1 ) , ( ) )
667+ }
668+ BuiltinFunction :: Typeof | BuiltinFunction :: Isarray
669+ if let [ expr] = args. as_slice ( ) =>
670+ {
671+ this. lower_expr_into ( expr, dest) ;
672+ ( dest, Reg ( dest. 0 + 1 ) , ( ) )
673+ }
674+ BuiltinFunction :: Typeof
675+ if let & [ Expr :: Leaf ( Atom :: Variable ( _var) , _) , ref _arg2] =
676+ args. as_slice ( ) =>
677+ {
678+ todo ! ( )
679+ }
680+ _ => this. gen_call_convention ( args, |_| ( ) ) ,
681+ } ;
658682 this. emit ( Instruction :: IntrinsicCall { dest, start, end, fun : * fun } ) ;
659683 }
660684 ExprNode :: IndirectCall ( place, args) => {
0 commit comments