Changeset 3310


Ignore:
Timestamp:
Jun 14, 2013, 5:15:28 PM (6 years ago)
Author:
ksherdy
Message:

Type refactoring.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • proto/pabloj/trunk/src/toolchain/pabloS/lang/BuiltinCallUtil.java

    r3301 r3310  
    1010    public static final String BUILTIN_PACKAGE_NAME = "pablo";
    1111       
    12     public static boolean isMask(FuncCallNode node) {
     12    public static boolean isMask(ASTNode node) {
    1313        return isBuiltInCall(node, PabloSBuiltin.MASK);
    1414    } 
    15     public static boolean isAdvance1(FuncCallNode node) {
     15    public static boolean isAdvance1(ASTNode node) {
    1616        return isBuiltInCall(node, PabloSBuiltin.ADVANCE);   
    1717    }   
    18     public static boolean isAdvanceN(FuncCallNode node) {
     18    public static boolean isAdvanceN(ASTNode node) {
    1919        return isBuiltInCall(node, PabloSBuiltin.ADVANCE_N);   
    2020    }
    21     public static boolean isAdvance(FuncCallNode node) {                // Advance(X) || Advance(X,n)
     21    public static boolean isAdvance(ASTNode node) {             // Advance(X) || Advance(X,n)
    2222        return isAdvance1(node) || isAdvanceN(node);   
    2323    }
    2424     
    25     public static boolean isCarry1(FuncCallNode node) {
     25    public static boolean isCarryNone(ASTNode node) {
     26        if(isBuiltInCall(node)) {
     27            PabloSBuiltin builtin = builtin(node);
     28            return builtin.isCarryNone();
     29        }
     30        return false;
     31    }
     32   
     33    public static boolean isCarry1(ASTNode node) {
    2634        if(isBuiltInCall(node)) {
    2735                PabloSBuiltin builtin = builtin(node);
     
    3038        return false;
    3139    }
    32     public static boolean isCarryN(FuncCallNode node) {
     40    public static boolean isCarryN(ASTNode node) {
    3341        if(isBuiltInCall(node)) {
    3442                PabloSBuiltin builtin = builtin(node);
     
    3745        return false;
    3846    }
    39     public static boolean isCarry(FuncCallNode node) {
     47    public static boolean isCarry(ASTNode node) {
    4048        return isCarry1(node) || isCarryN(node);
    4149    }
    4250   
    4351    // guard invocation with isCarryN
    44         public static String carryNValue(FuncCallNode node) {
     52        public static String carryNValue(ASTNode node) {
    4553                assert isCarryN(node);
    46                 List<ASTNode> arguments = Accessors.argsListNode(node).getChildren();
     54                List<ASTNode> arguments = Accessors.argsListNode((FuncCallNode)node).getChildren();
    4755                String value = Accessors.lexeme(arguments.get(1));
    4856                return value;
     
    5361        // guard invocations with isBuiltInCall
    5462        ///////////////////////////////////////////////////////////////////////////////////
    55         public static PabloSBuiltin builtin(FuncCallNode node) {
     63        public static PabloSBuiltin builtin(ASTNode node) {
    5664                assert isBuiltInCall(node);
    57                 CompoundIdentifierNode compound = (CompoundIdentifierNode)Accessors.nameNode(node);
     65                CompoundIdentifierNode compound = (CompoundIdentifierNode)Accessors.nameNode((FuncCallNode)node);
    5866                String builtinName = Accessors.funcName(compound);
    5967                return PabloSBuiltin.forName(builtinName);
     
    6371        // isBuiltinCall(node, builtin) - is this node an invocation of the given builtin?
    6472        ///////////////////////////////////////////////////////////////////////////////////
    65         public static boolean isBuiltInCall(FuncCallNode node, PabloSBuiltin builtin) {
     73        public static boolean isBuiltInCall(ASTNode node, PabloSBuiltin builtin) {
    6674                if(isBuiltInCall(node)) {
    6775                        return builtin(node) == builtin;
     
    7381        // isBuiltinCall(node) - is this node an invocation of a builtin?
    7482        ///////////////////////////////////////////////////////////////////////////////////
    75         public static boolean isBuiltInCall(FuncCallNode node) {
     83        public static boolean isBuiltInCall(ASTNode node) {
     84            if(!(node instanceof FuncCallNode)) {
     85                return false;
     86            }
     87           
    7688                ASTNode nameNode = Accessors.nameNode((FuncCallNode)node);
    7789                return hasPackage(nameNode, BUILTIN_PACKAGE_NAME);
Note: See TracChangeset for help on using the changeset viewer.