public ICallable Instantiate(BindingContext context, IEnumerable <IBoundDecl> typeArgs, IBoundDecl argType) { // should have two args: an int and an array var argTuple = argType as BoundTupleType; if (argTuple == null) { return(null); } if (argTuple.Fields[0] != Decl.Int) { return(null); } var arrayType = argTuple.Fields[1] as BoundArrayType; if (arrayType == null) { return(null); } // make the intrinsic return(new Intrinsic("__Call", OpCode.LoadArray, FuncType.Create(argTuple, arrayType.ElementType))); }
public ICallable Instantiate(BindingContext context, IEnumerable <IBoundDecl> typeArgs, IBoundDecl argType) { // should have three args: an int, an array, and a value var argTuple = argType as BoundTupleType; if (argTuple == null) { return(null); } // index if (argTuple.Fields[0] != Decl.Int) { return(null); } // array var arrayType = argTuple.Fields[1] as BoundArrayType; if (arrayType == null) { return(null); } // value if (!DeclComparer.TypesMatch(argTuple.Fields[2], arrayType.ElementType)) { return(null); } // make the intrinsic return(new Intrinsic("__Call<-", OpCode.StoreArray, FuncType.Create(argTuple, Decl.Unit))); }
public ICallable Instantiate(BindingContext context, IEnumerable <IBoundDecl> typeArgs, IBoundDecl argType) { var arrayType = argType as BoundArrayType; if (arrayType == null) { return(null); } // make the intrinsic return(new Intrinsic("Size", OpCode.SizeArray, FuncType.Create(arrayType, Decl.Int))); }
public static IBoundExpr EqualInt(IBoundExpr left, IBoundExpr right) { var intrinsic = new Intrinsic("=", OpCode.EqualInt, FuncType.Create(Decl.Int, Decl.Int, Decl.Bool)); return(intrinsic.CreateCall(new BoundTupleExpr(new IBoundExpr[] { left, right }))); }
public ForeignFunction(string name, int id, IBoundDecl returnType) : this(name, id, FuncType.Create(returnType)) { }